com.bumptech.glide.load.model.stream.StreamUriLoader Java Examples

The following examples show how to use com.bumptech.glide.load.model.stream.StreamUriLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestFragment_Inclusive.java    From glide-support with The Unlicense 6 votes vote down vote up
@Override public void onAttach(Context context) {
	super.onAttach(context);
	BitmapPool pool = Glide.get(context).getBitmapPool();
	StreamBitmapDecoder bitmapDecoder = new StreamBitmapDecoder(Downsampler.AT_LEAST, pool, DecodeFormat.DEFAULT);
	paletteLoad = Glide
			.with(this)
			.using(new StreamUriLoader(context), InputStream.class)
			.from(Uri.class)
			.as(PaletteBitmap.class)
			.diskCacheStrategy(DiskCacheStrategy.ALL)
			.encoder(new PaletteBitmapEncoder(new BitmapEncoder(), new PaletteEncoder()))
			.sourceEncoder(new StreamEncoder())
			.cacheDecoder(new FileToStreamDecoder<>(
					new PaletteBitmapDecoder(pool, bitmapDecoder, new PaletteDecoder())))
			.dontAnimate()
			.skipMemoryCache(true) // debug to always go for disk
	;
}
 
Example #2
Source File: TestFragment_Separate.java    From glide-support with The Unlicense 6 votes vote down vote up
@Override public void onAttach(Context context) {
	super.onAttach(context);
	paletteLoad = Glide
			.with(this)
			.using(new StreamUriLoader(context), InputStream.class)
			.from(Uri.class)
			.as(Palette.class)
			.diskCacheStrategy(DiskCacheStrategy.ALL)
			.encoder(new PaletteCacheEncoder(new PaletteEncoder()))
			.sourceEncoder(new StreamEncoder())
			.cacheDecoder(new FileToStreamDecoder<>(
					new PaletteCacheDecoder(new PaletteDecoder(), new StreamBitmapDecoder(
							Downsampler.AT_MOST, Glide.get(context).getBitmapPool(), DecodeFormat.DEFAULT))))
			.override(256, 256) // rough size of the Bitmap to generate Palette from 
			.dontTransform() // default, but be explicit
			.dontAnimate() // default, but be explicit
			.skipMemoryCache(true) // debug to always go for disk
	;
}
 
Example #3
Source File: TestFragment.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override public void onAttach(Context context) {
	super.onAttach(context);
	SIZE_REQUEST = Glide
			.with(this)
			.using(new StreamUriLoader(context), InputStream.class)
			.from(Uri.class)
			.as(Options.class)
			.transcode(new OptionsSizeResourceTranscoder(), Size.class)
			.sourceEncoder(new StreamEncoder())
			.cacheDecoder(new BitmapSizeDecoder())
			.diskCacheStrategy(DiskCacheStrategy.SOURCE)
			.listener(new LoggingListener<Uri, Size>());
}
 
Example #4
Source File: Glide.java    From giffun with Apache License 2.0 4 votes vote down vote up
Glide(Engine engine, MemoryCache memoryCache, BitmapPool bitmapPool, Context context, DecodeFormat decodeFormat, DiskCache.Factory diskCacheFactory) {
    this.engine = engine;
    this.bitmapPool = bitmapPool;
    this.memoryCache = memoryCache;
    this.decodeFormat = decodeFormat;
    this.diskCacheFactory = diskCacheFactory;
    loaderFactory = new GenericLoaderFactory(context);
    mainHandler = new Handler(Looper.getMainLooper());
    bitmapPreFiller = new BitmapPreFiller(memoryCache, bitmapPool, decodeFormat);

    dataLoadProviderRegistry = new DataLoadProviderRegistry();

    StreamBitmapDataLoadProvider streamBitmapLoadProvider =
            new StreamBitmapDataLoadProvider(bitmapPool, decodeFormat);
    dataLoadProviderRegistry.register(InputStream.class, Bitmap.class, streamBitmapLoadProvider);

    FileDescriptorBitmapDataLoadProvider fileDescriptorLoadProvider =
            new FileDescriptorBitmapDataLoadProvider(bitmapPool, decodeFormat);
    dataLoadProviderRegistry.register(ParcelFileDescriptor.class, Bitmap.class, fileDescriptorLoadProvider);

    ImageVideoDataLoadProvider imageVideoDataLoadProvider =
            new ImageVideoDataLoadProvider(streamBitmapLoadProvider, fileDescriptorLoadProvider);
    dataLoadProviderRegistry.register(ImageVideoWrapper.class, Bitmap.class, imageVideoDataLoadProvider);

    GifDrawableLoadProvider gifDrawableLoadProvider =
            new GifDrawableLoadProvider(context, bitmapPool);
    dataLoadProviderRegistry.register(InputStream.class, GifDrawable.class, gifDrawableLoadProvider);

    dataLoadProviderRegistry.register(ImageVideoWrapper.class, GifBitmapWrapper.class,
            new ImageVideoGifDrawableLoadProvider(imageVideoDataLoadProvider, gifDrawableLoadProvider, bitmapPool));

    dataLoadProviderRegistry.register(InputStream.class, File.class, new StreamFileDataLoadProvider());

    register(File.class, ParcelFileDescriptor.class, new FileDescriptorFileLoader.Factory());
    register(File.class, InputStream.class, new StreamFileLoader.Factory());
    register(int.class, ParcelFileDescriptor.class, new FileDescriptorResourceLoader.Factory());
    register(int.class, InputStream.class, new StreamResourceLoader.Factory());
    register(Integer.class, ParcelFileDescriptor.class, new FileDescriptorResourceLoader.Factory());
    register(Integer.class, InputStream.class, new StreamResourceLoader.Factory());
    register(String.class, ParcelFileDescriptor.class, new FileDescriptorStringLoader.Factory());
    register(String.class, InputStream.class, new StreamStringLoader.Factory());
    register(Uri.class, ParcelFileDescriptor.class, new FileDescriptorUriLoader.Factory());
    register(Uri.class, InputStream.class, new StreamUriLoader.Factory());
    register(URL.class, InputStream.class, new StreamUrlLoader.Factory());
    register(GlideUrl.class, InputStream.class, new HttpUrlGlideUrlLoader.Factory());
    register(byte[].class, InputStream.class, new StreamByteArrayLoader.Factory());

    transcoderRegistry.register(Bitmap.class, GlideBitmapDrawable.class,
            new GlideBitmapDrawableTranscoder(context.getResources(), bitmapPool));
    transcoderRegistry.register(GifBitmapWrapper.class, GlideDrawable.class,
            new GifBitmapWrapperDrawableTranscoder(
                    new GlideBitmapDrawableTranscoder(context.getResources(), bitmapPool)));

    bitmapCenterCrop = new CenterCrop(bitmapPool);
    drawableCenterCrop = new GifBitmapWrapperTransformation(bitmapPool, bitmapCenterCrop);

    bitmapFitCenter = new FitCenter(bitmapPool);
    drawableFitCenter = new GifBitmapWrapperTransformation(bitmapPool, bitmapFitCenter);
}