Mirage { public MirageRequest load(String uri) { if (TextUtils.isEmpty(uri)) return load((Uri)null); return load(Uri.parse(uri)); } Mirage(Context applicationContext); synchronized static void set(Mirage mirage); synchronized static Mirage get(Context context); void dispose(); MirageRequest load(String uri); MirageRequest load(File file); MirageRequest load(@AnyRes int resId); MirageRequest load(BitmapProvider provider); MirageRequest load(Uri uri); @MainThread MirageTask go(MirageRequest request); MirageTask<Void, Void, Bitmap> createGoTask(MirageRequest request); MirageTask<Void, Void, Bitmap> executeGoTask(MirageTask<Void, Void, Bitmap> task, MirageRequest request); @WorkerThread Bitmap goSync(MirageRequest request); MirageTask downloadOnly(MirageRequest request); File downloadOnlySync(MirageRequest request); void cancelRequest(Target target); void cancelRequest(View view); void clearCache(); void removeFromCache(MirageRequest request); void clearMemoryCache(); void clearDiskCache(); void setDefaultUrlConnectionFactory(UrlFactory defaultUrlConnectionFactory); Executor getDefaultExecutor(); Mirage setDefaultExecutor(Executor defaultExecutor); Mirage setDefaultMemoryCache(MemoryCache<String, Bitmap> defaultMemoryCache); MemoryCache<String, Bitmap> getDefaultMemoryCache(); Mirage setDefaultDiskCache(DiskCache defaultDiskCache); DiskCache getDefaultDiskCache(); static final Executor THREAD_POOL_EXECUTOR; }
@Test public void testLoadFile() throws Exception { Mirage mirage = new Mirage(RuntimeEnvironment.application); File file = new File(RuntimeEnvironment.application.getCacheDir(), "file.jpg"); MirageRequest request = mirage.load(file); Assert.assertEquals(Uri.fromFile(file), request.uri()); }
@Test public void testLoadString() throws Exception { Mirage mirage = new Mirage(RuntimeEnvironment.application); MirageRequest request = mirage.load("http: Assert.assertEquals(Uri.parse("http: request = mirage.load("file: Assert.assertEquals(Uri.parse("file: request = mirage.load("content: Assert.assertEquals(Uri.parse("content: }
@Test public void testLoadUri() throws Exception { Mirage mirage = new Mirage(RuntimeEnvironment.application); MirageRequest request = mirage.load(Uri.parse("http: Assert.assertEquals(Uri.parse("http: request = mirage.load(Uri.parse("file: Assert.assertEquals(Uri.parse("file: request = mirage.load(Uri.parse("content: Assert.assertEquals(Uri.parse("content: }