A more controllable MediaLoader contains Image, Movie that load bitmap, gif from anywhere with both disk and mem cache, and a lot of ui effects.
- Vector support.
- Mipmap support.
- Use the shared(single) instance
public class MyApp {
@Override
public void onCreate() {
super.onCreate();
// Create the shared instance
MediaAccessory.createShared(getApplicationContext(), AccessoryConfig.builder()
.queuePolicy(QueuePolicy.LIFO)
.cachePolicy(CachePolicy.builder()
.enableMemCache()
.enableDiskCache()
.enableStorageStats()
.cacheDirName("dis.cache.tests")
.preferredLocation(CachePolicy.Location.EXTERNAL)
.compressFormat(Bitmap.CompressFormat.PNG)
.build())
.networkPolicy(NetworkPolicy.builder()
.onlyOnWifi()
.enableTrafficStats().build())
.debugLevel(Log.VERBOSE)
.build());
// Some works
MediaAccessory.shared().works...
}
}- Create a new accessory with new config
public class Z {
@Override
public void onCreate() {
super.onCreate();
// Fork a new instance
MediaAccessory newOne = MediaAccessory.shared().fork(AccessoryConfig.builder()
.cachePolicy(CachePolicy.builder()
.enableMemCache()
.enableDiskCache()
.cachingThreads(Runtime.getRuntime().availableProcessors())
.cacheDirName("dis.cache.tests.content")
.preferredLocation(CachePolicy.Location.INTERNAL)
.compressFormat(Bitmap.CompressFormat.JPEG)
.build())
.networkPolicy(NetworkPolicy.builder().enableTrafficStats().build())
.build());
// Some works
accessory.works...
}
} MediaAccessory.shared()
.loadBitmap()
.from(urlDrawable)
.listener(listener)
.option(DisplayOption.builder()...) // Ignore this param if your just want to load a bitmap.
.into(imageView) // Ignore this param if your just want to load a bitmap.
.start();class CustomView implements MediaHolder<X> {}MediaAccessory.shared()
.loadMovie()
.from(urlDrawable)
.listener(listener)
.option(DisplayOption.builder()...)
.into(new CustomView())
.start();mMediaAccessory.cancel(ImageView/ImageSettable/Url); @Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
mMediaAccessory.clearMemCache();
}@Override
protected void onDestroy() {
super.onDestroy();
mMediaAccessory.clearAllCache();
}- http://
- https://
- file://
- content://
- drawable://
- mipmap://
- assets://
- All image formats android supported.
- Video
- Gif
