Skip to content

Latest commit

 

History

History
91 lines (76 loc) · 3.09 KB

README.md

File metadata and controls

91 lines (76 loc) · 3.09 KB

Image Loader

Release Android Arsenal API

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)

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {

    repositories {

        maven { url 'https://jitpack.io' }
   }
}

or in settings.gradle file:

dependencyResolutionManagement {

    repositories {

        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add dependency:

dependencies {
    implementation 'com.github.yuriy-budiyev:image-loader:2.5.8'
}

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