Skip to content

NickAndroid/Accessories_Android

Repository files navigation

Project STOPPED :(

MediaAccessories

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.

Arts

Video 1

Usage

Change log

  • Vector support.
  • Mipmap support.

Samples

How to init/get the accessory:

  • 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...
    }
}

Loading or Display:

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

CustomView support:

class CustomView implements MediaHolder<X> {}
MediaAccessory.shared()
                .loadMovie()
                .from(urlDrawable)
                .listener(listener)
                .option(DisplayOption.builder()...)
                .into(new CustomView())
                .start();

Cancel tasks:

mMediaAccessory.cancel(ImageView/ImageSettable/Url);

Clear cache:

 @Override
    public void onTrimMemory(int level) {
        super.onTrimMemory(level);
        mMediaAccessory.clearMemCache();
    }
@Override
    protected void onDestroy() {
        super.onDestroy();
        mMediaAccessory.clearAllCache();
    }

Supported url:

  • http://
  • https://
  • file://
  • content://
  • drawable://
  • mipmap://
  • assets://

Supported media format:

  • All image formats android supported.
  • Video
  • Gif

Contact me

nick.guo.dev@icloud.com 📧

About

Android image loader library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages