Java 类com.bumptech.glide.load.resource.transcode.BitmapToGlideDrawableTranscoder 实例源码

项目:q-mail    文件:ContactPictureLoader.java   
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);
}
项目:hintcase    文件:FullHintActivity.java   
@NonNull
private ImageView getGifLoadedUsingGlide() {
    ImageView animatedImageView = new ImageView(getActivity());
    animatedImageView.setMaxHeight(900);
    Glide.with(getActivity())
            .load(R.drawable.animated_image)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .thumbnail(Glide.with(getActivity())
                    .load(R.drawable.animated_image)
                    .asBitmap()
                    .transcode(new BitmapToGlideDrawableTranscoder(getActivity()), GlideDrawable.class)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
            )
            .into(animatedImageView);
    return animatedImageView;
}
项目:glide-support    文件:GeneratingAdapter.java   
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
    ;
}
项目:glide-support    文件:GlideImageGetter.java   
private GenericRequestBuilder<String, ?, ?, GlideDrawable> createGlideRequest(RequestManager glide,
        boolean animated) {
    GenericRequestBuilder<String, ?, ?, GlideDrawable> load;
    if (animated) {
        load = glide
                .fromString()
                //".asDrawable()" default loading handles animated GIFs and still images as well
                .diskCacheStrategy(DiskCacheStrategy.SOURCE) // animated GIFs need source cache
                // show full image when animating
                .fitCenter()
        ;
    } else {
        load = glide
                .fromString()
                // force still images
                .asBitmap()
                // make compatible with target
                .transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)
                // cache resized images (RESULT), and re-use SOURCE cached GIFs if any
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                // show part of the image when still
                .centerCrop()
        ;
    }
    return load
            // common settings
            .listener(new LoggingListener<String, GlideDrawable>())
            ;
}