Image Loader
Image loader library for Android.
Deprecated. See Glide.
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
sample)
Usage (Add dependency:
dependencies {
implementation 'com.budiyev.android:image-loader:2.5.6'
}
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();
}
}