本文整理汇总了Java中com.bumptech.glide.load.model.StreamEncoder类的典型用法代码示例。如果您正苦于以下问题:Java StreamEncoder类的具体用法?Java StreamEncoder怎么用?Java StreamEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StreamEncoder类属于com.bumptech.glide.load.model包,在下文中一共展示了StreamEncoder类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAttach
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@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
;
}
示例2: onAttach
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@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
;
}
示例3: attachView
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@Override
public void attachView(ImageZoomMvpView mvpView) {
super.attachView(mvpView);
requestBuilder = Glide.with(getMvpView().getAppContext())
.using(Glide.buildStreamModelLoader(Uri.class,
getMvpView().getAppContext()), InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder()))
.decoder(new SvgDecoder())
.placeholder(R.drawable.placeholder)
.error(R.drawable.placeholder)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.animate(android.R.anim.fade_in);
}
示例4: ContentBlock3ViewHolder
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
public ContentBlock3ViewHolder(View itemView, Context context,
OnContentBlock3ViewHolderInteractionListener listener) {
super(itemView);
mContext = context;
mTitleTextView = (TextView) itemView.findViewById(R.id.titleTextView);
mCopyrightTextView = (TextView) itemView.findViewById(R.id.copyrightTextView);
mImageView = (ImageView) itemView.findViewById(R.id.imageImageView);
mImageProgressBar = (ProgressBar) itemView.findViewById(R.id.imageProgressBar);
mListener = listener;
mFileManager = FileManager.getInstance(context);
SvgDrawableTranscoder svgDrawableTranscoder = new SvgDrawableTranscoder();
svgDrawableTranscoder.setmDeviceWidth(mContext.getResources().getDisplayMetrics().widthPixels);
requestBuilder = Glide.with(mContext)
.using(Glide.buildStreamModelLoader(Uri.class, mContext), InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(svgDrawableTranscoder, PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
.decoder(new SvgDecoder())
.listener(new SvgSoftwareLayerSetter<Uri>());
}
示例5: gifPlus
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
/**
* Gif增强
*
* @return
*/
public GlidePlus gifPlus() {
mRequestBuilder = Glide.with(mContext)
.using(new StreamStringLoader(mContext), InputStream.class)
.from(String.class)
.as(ImageWrapper.class)
.transcode(new ImageWrapperDrawableTranscoder(mContext), Drawable.class)
.decoder(new ImageWrapperStreamResourceDecoder(mContext))
.cacheDecoder(new ImageWrapperFileToStreamDecoder(mContext))
.sourceEncoder(new StreamEncoder())
.animate(new DrawableCrossFadeAnimator())
.diskCacheStrategy(DiskCacheStrategy.SOURCE);
return this;
}
示例6: getInstance
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
public static SvgImageLoader getInstance(Context context) {
if (mInstance == null) {
mInstance = new SvgImageLoader();
genericRequestBuilder = Glide.with(context)
.using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
.decoder(new SvgDecoder())
.listener(new SvgSoftwareLayerSetter<>());
}
return mInstance;
}
示例7: CountriesAdapter
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@Inject
public CountriesAdapter (@ApplicationContext Context applicationContext)
{
countryList = new ArrayList<>( );
context = applicationContext;
requestBuilder = Glide.with( context )
.using( Glide.buildStreamModelLoader( Uri.class, context ), InputStream.class )
.from( Uri.class )
.as( SVG.class )
.transcode( new SvgDrawableTranscoder( ), PictureDrawable.class )
.sourceEncoder( new StreamEncoder( ) )
.cacheDecoder( new FileToStreamDecoder<SVG>( new SvgDecoder( ) ) )
.decoder( new SvgDecoder( ) )
.placeholder( R.mipmap.ic_launcher )
.error( android.R.drawable.stat_notify_error )
.animate( android.R.anim.fade_in )
.listener( new SvgSoftwareLayerSetter<Uri>( ) );
}
示例8: onAttach
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@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>());
}
示例9: provideGifRequestBuilder
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@Singleton
@Provides
GenericRequestBuilder<Media, InputStream, byte[], GifDrawable> provideGifRequestBuilder(
RequestManager requestManager) {
return requestManager.using(new MediaLoader(mView), InputStream.class)
.from(Media.class)
.as(byte[].class)
.transcode(new GifDrawableBytesTranscoder(), GifDrawable.class)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.decoder(new StreamByteArrayResourceDecoder())
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new StreamByteArrayResourceDecoder()));
}
示例10: create
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
public static GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> create(Context context, Drawable placeholder) {
return Glide.with(context.getApplicationContext())
.using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
.decoder(new SvgDecoder())
.placeholder(placeholder)
.listener(new SvgSoftwareLayerSetter());
}
示例11: provideGifRequestBuilder
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@Singleton
@Provides
GenericRequestBuilder<GlideUrl, InputStream, byte[], GifDrawable> provideGifRequestBuilder(
RequestManager requestManager, OkHttpClient okHttpClient) {
return requestManager.using(new OkHttpUrlLoader(okHttpClient), InputStream.class)
.from(GlideUrl.class)
.as(byte[].class)
.transcode(new GifDrawableBytesTranscoder(), GifDrawable.class)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.decoder(new StreamByteArrayResourceDecoder())
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(new StreamByteArrayResourceDecoder()));
}
示例12: onAttach
import com.bumptech.glide.load.model.StreamEncoder; //导入依赖的package包/类
@Override public void onAttach(Context context) {
super.onAttach(context);
BitmapPool pool = Glide.get(context).getBitmapPool();
// default decoder, this is the base complexity Glide.with.load.into() hides from you
GifBitmapWrapperStreamResourceDecoder decoder = new GifBitmapWrapperStreamResourceDecoder(
new GifBitmapWrapperResourceDecoder(
new ImageVideoBitmapDecoder(
new StreamBitmapDecoder(pool),
new FileDescriptorBitmapDecoder(context)
),
new GifResourceDecoder(context, pool),
pool
)
);
// all the defaults hardcoded here in order to end up with a normal Drawable instead of a GlideDrawable
urlGlide = Glide
.with(this)
.using(new StreamStringLoader(getActivity()), InputStream.class)
.from(String.class)
.as(GifBitmapWrapper.class)
.transcode(new GeneralizingTranscoder<GifBitmapWrapper, GlideDrawable, Drawable>(
new GifBitmapWrapperDrawableTranscoder(new GlideBitmapDrawableTranscoder(context))),
Drawable.class)
.decoder(decoder)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(decoder))
.animate(new AlwaysCrossFade<>(true))
.encoder(new GifBitmapWrapperResourceEncoder(new BitmapEncoder(), new GifResourceEncoder(pool)))
.diskCacheStrategy(DiskCacheStrategy.ALL) // just to demonstrate it's working, pick your preference
.transform(new GifBitmapWrapperTransformation(pool, new FitCenter(context))) // == .fitCenter()
.listener(new LoggingListener<String, Drawable>("url")) // debug
;
// see https://github.com/bumptech/glide/issues/122#issuecomment-99629392
drawableGlide = Glide
.with(this)
.using(new PassthroughModelLoader<Drawable, Drawable>(), Drawable.class)
.from(Drawable.class)
.as(Drawable.class)
// this works even if the drawables don't behave well regarding constantState.newDrawable
// Beware: might be problematic if constant state is supported, but altered (e.g. color filters)
.decoder(new SimpleResourceDecoder<Drawable>()) // prefer DrawableResourceDecoder if possible!
.animate(new AlwaysCrossFade<>(true))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.listener(new LoggingListener<Drawable, Drawable>("drawable")) // debug
;
// prevents null check the first time
// don't forge to null everything out explicitly (error/placeholder/fallback/thumbnail), if they're set above
lastLoad = urlGlide.clone().load(null).listener(null).dontAnimate();
}