Skip to content

Latest commit

 

History

History
68 lines (61 loc) · 3.09 KB

README.md

File metadata and controls

68 lines (61 loc) · 3.09 KB

Image Loader

Download Android Arsenal API Codacy Badge

Image loader library for Android.

Features

  • Image transformations
  • Automatic memory and storage caching
  • Ability to load images from any custom data type
  • Both synchronous and asynchronous image loading modes
  • Almost unlimited customization

Usage (sample)

Add dependency:

dependencies {
    implementation 'com.budiyev.android:image-loader:2.5.5'
}

And load images simply:

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView view = findViewById(R.id.image_view);

        // Simply load image from URL into view
        ImageLoader.with(this).from("https://some.url/image").load(view);

        // Advanced usage
        ImageLoader.with(this)
                /*Create new load request for specified data.
                  Data types supported by default: URIs (remote and local), 
                  files, file descriptors, resources and byte arrays.*/
                .from("https://some.url/image")
                /*Required image size (to load sampled bitmaps)*/
                .size(1000, 1000)
                /*Display loaded image with rounded corners, optionally, specify corner radius*/
                .roundCorners()
                /*Placeholder drawable*/
                .placeholder(new ColorDrawable(Color.LTGRAY))
                /*Error drawable*/
                .errorDrawable(new ColorDrawable(Color.RED))
                /*Apply transformations*/
                .transform(ImageUtils.cropCenter())
                .transform(ImageUtils.convertToGrayScale())
                /*Load image into view*/
                .load(view);
                /*Also, load, error and display callbacks can be specified for each request*/

        // Load image asynchronously without displaying it
        ImageLoader.with(this).from("https://some.url/image").onLoaded(new LoadCallback() {
            @Override
            public void onLoaded(@NonNull Bitmap image) {
                // Do something with image here
            }
        }).load();

        // Load image synchronously (on current thread), should be executed on a worker thread
        //Bitmap image = ImageLoader.with(this).from("https://some.url/image").loadSync();                 
    }
}