• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileToStreamDecoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.bumptech.glide.load.resource.file.FileToStreamDecoder的典型用法代码示例。如果您正苦于以下问题:Java FileToStreamDecoder类的具体用法?Java FileToStreamDecoder怎么用?Java FileToStreamDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileToStreamDecoder类属于com.bumptech.glide.load.resource.file包,在下文中一共展示了FileToStreamDecoder类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadFallbackPicture

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的package包/类
private void loadFallbackPicture(Address address, ImageView imageView) {
    Context context = imageView.getContext();

    Glide.with(context)
            .using(new FallbackGlideModelLoader(), FallbackGlideParams.class)
            .from(FallbackGlideParams.class)
            .as(Bitmap.class)
            .transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)
            .decoder(new FallbackGlideBitmapDecoder(context))
            .encoder(new BitmapEncoder(Bitmap.CompressFormat.PNG, 0))
            .cacheDecoder(new FileToStreamDecoder<>(new StreamBitmapDecoder(context)))
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .load(new FallbackGlideParams(address))
            // for some reason, following 2 lines fix loading issues.
            .dontAnimate()
            .override(mPictureSizeInPx, mPictureSizeInPx)
            .into(imageView);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:ContactPictureLoader.java


示例2: load

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override protected void load(Context context) {
	GenericRequestBuilder<Bitmap, Bitmap, Bitmap, Bitmap> glide = Glide
			.with(context)
			.using(new PassthroughModelLoader<Bitmap, Bitmap>(), Bitmap.class)
			.from(Bitmap.class)
			.as(Bitmap.class)
			.decoder(new BitmapBitmapResourceDecoder(context))
			.cacheDecoder(new FileToStreamDecoder<Bitmap>(new StreamBitmapDecoder(context)))
			.encoder(new BitmapEncoder())
			// or .diskCacheStrategy(DiskCacheStrategy.NONE) instead of last 2
			;

	// simulate a bitmap input
	Drawable drawable = ContextCompat.getDrawable(context, android.R.drawable.sym_def_app_icon);
	Bitmap bitmap = Bitmap.createBitmap(
			drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888);
	Canvas canvas = new Canvas(bitmap);
	drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
	drawable.draw(canvas);

	glide
			.clone()
			.load(bitmap)
			.signature(new StringSignature("android.R.drawable.sym_def_app_icon")) // required for caching
			.diskCacheStrategy(DiskCacheStrategy.NONE) // but can't really cache it, see #122 comments
			.transform(new CenterCrop(context))
			.into(imageView)
	;
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:31,代码来源:TestFragment.java


示例3: onAttach

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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
	;
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:19,代码来源:TestFragment_Inclusive.java


示例4: onAttach

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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
	;
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:20,代码来源:TestFragment_Separate.java


示例5: GeneratingAdapter

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的package包/类
public GeneratingAdapter(final Context context) {
	generator = Glide // this part should be cleaner in Glide 4.0, but that's not released yet
	                  .with(context)
	                  .using(new GeneratePassthroughModelLoader(), GenerateParams.class)          // custom class
	                  .from(GenerateParams.class)
	                  .as(Bitmap.class)
	                  .transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)     // builtin
	                  .decoder(new GenerateBitmapResourceDecoder(context))                        // custom class
	                  .encoder(new BitmapEncoder(Bitmap.CompressFormat.PNG, 0/*ignored for lossless*/)) // builtin
	                  .cacheDecoder(new FileToStreamDecoder<Bitmap>(new StreamBitmapDecoder(context)))  // builtin
	//.placeholder(new ColorDrawable(Color.YELLOW)) // you can pre-set placeholder and error
	//.error(new ColorDrawable(Color.RED))          // so it's easier when binding
	//.diskCacheStrategy(DiskCacheStrategy.NONE)    // only for debugging to always regenerate
	//.skipMemoryCache(true)                        // only for debugging to always regenerate
	;
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:17,代码来源:GeneratingAdapter.java


示例6: attachView

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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);

}
 
开发者ID:apache,项目名称:incubator-taverna-mobile,代码行数:21,代码来源:ImageZoomPresenter.java


示例7: ContentBlock3ViewHolder

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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>());
}
 
开发者ID:xamoom,项目名称:xamoom-android-sdk,代码行数:26,代码来源:ContentBlock3ViewHolder.java


示例8: getInstance

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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;
}
 
开发者ID:amrendra18,项目名称:udacity-p3,代码行数:16,代码来源:SvgImageLoader.java


示例9: CountriesAdapter

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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>( ) );
}
 
开发者ID:tecruz,项目名称:AndroidBaseApplication,代码行数:19,代码来源:CountriesAdapter.java


示例10: load

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的package包/类
@Override protected void load(Context context) throws Exception {
	String model = "http://.../....dng";
	//File model = ...;
	Glide
			.with(context)
			.load(model)
			.asBitmap()
			.imageDecoder(new RawStreamDecoder(context))
			.encoder(new RawStreamEncoder())
			.cacheDecoder(new FileToStreamDecoder<>(new RawStreamDecoder(context)))
			.into(imageView)
	;
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:14,代码来源:TestFragment.java


示例11: provideGifRequestBuilder

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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()));
}
 
开发者ID:xdtianyu,项目名称:Gallery,代码行数:15,代码来源:ViewerModule.java


示例12: create

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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());
}
 
开发者ID:StepicOrg,项目名称:stepik-android,代码行数:13,代码来源:GlideSvgRequestFactory.java


示例13: provideGifRequestBuilder

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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()));
}
 
开发者ID:kurumi-moe,项目名称:MoeGallery,代码行数:15,代码来源:MainModule.java


示例14: instantiateItem

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {

    final ImageViewerLayout imageLayout = new ImageViewerLayout(mActivity);
    final ContentImg contentImg = mImages.get(position);
    final String imageUrl = contentImg.getContent();
    ImageInfo imageInfo = ImageContainer.getImageInfo(imageUrl);

    //ScaleImageView has about 100ms delay, so show image with normal ImageView first
    if (mFirstShow) {
        mFirstShow = false;
        if (!imageInfo.isGif() && GlideHelper.isOkToLoad(mActivity)) {
            ImageInfo thumbInfo = ImageContainer.getImageInfo(contentImg.getThumbUrl());
            ImageInfo info = thumbInfo.isReady() ? thumbInfo : imageInfo;
            //load argument must match ThreadDetailFragment to hit memory cache
            if (info.isReady()) {
                Glide.with(mActivity)
                        .load(info.getUrl())
                        .asBitmap()
                        .cacheDecoder(new FileToStreamDecoder<>(new ThreadImageDecoder(imageInfo)))
                        .imageDecoder(new ThreadImageDecoder(imageInfo))
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(new GlideBitmapTarget(imageLayout.getGlideImageView(), info.getDisplayWidth(), info.getDisplayHeight()));
            }
        }
    }

    if (!imageInfo.isReady() || !(new File(imageInfo.getPath())).exists()) {
        imageLayout.getProgressBar().setVisibility(View.VISIBLE);
        imageLayout.getProgressBar().setIndeterminate(true);
        JobMgr.addJob(new GlideImageJob(imageUrl, JobMgr.PRIORITY_HIGH, mSessionId, true));
    } else {
        displayImage(imageLayout, imageUrl);
    }
    imageLayout.setUrl(imageUrl);
    container.addView(imageLayout);
    imageViewMap.put(imageUrl, imageLayout);
    return imageLayout;
}
 
开发者ID:GreenSkinMonster,项目名称:hipda,代码行数:40,代码来源:ImageViewerAdapter.java


示例15: loadImage

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的package包/类
private void loadImage() {
    ImageInfo imageInfo = ImageContainer.getImageInfo(mUrl);
    mProgressBar.setVisibility(View.GONE);
    if (imageInfo.getStatus() == ImageInfo.SUCCESS) {
        mTextView.setVisibility(GONE);
        if (getLayoutParams().height != imageInfo.getDisplayHeight()) {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, imageInfo.getDisplayHeight());
            setLayoutParams(params);
        }
        if (imageInfo.getWidth() >= MIN_WIDTH || imageInfo.isGif()) {
            mImageView.setOnLongClickListener(new OnLongClickListener() {
                @Override
                public boolean onLongClick(View view) {
                    showImageActionDialog();
                    return true;
                }
            });
        }

        if (imageInfo.isGif()) {
            mRequestManager
                    .load(mUrl)
                    .asBitmap()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .transform(new GifTransformation(getContext()))
                    .into(new GlideBitmapTarget(mImageView, imageInfo.getDisplayWidth(), imageInfo.getDisplayHeight()));
        } else {
            mRequestManager
                    .load(mUrl)
                    .asBitmap()
                    .cacheDecoder(new FileToStreamDecoder<>(new ThreadImageDecoder(imageInfo)))
                    .imageDecoder(new ThreadImageDecoder(imageInfo))
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(new GlideBitmapTarget(mImageView, imageInfo.getDisplayWidth(), imageInfo.getDisplayHeight()));
        }
    } else {
        mImageView.setImageResource(R.drawable.image_broken);
    }
}
 
开发者ID:GreenSkinMonster,项目名称:hipda,代码行数:40,代码来源:ThreadImageLayout.java


示例16: onAttach

import com.bumptech.glide.load.resource.file.FileToStreamDecoder; //导入依赖的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();
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:52,代码来源:TestFragment.java



注:本文中的com.bumptech.glide.load.resource.file.FileToStreamDecoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConstantDouble类代码示例发布时间:2022-05-22
下一篇:
Java Jar类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap