Skip to content

yuriy-budiyev/image-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 6, 2018
2e6d7aa · Apr 6, 2018
Apr 6, 2018
Mar 6, 2018
Oct 24, 2017
Feb 16, 2018
Apr 6, 2018
Apr 6, 2018
Oct 24, 2017
Apr 6, 2018
Apr 6, 2018
Oct 24, 2017

Repository files navigation

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();                 
    }
}