当前位置: 首页>>代码示例>>Java>>正文


Java GlideBitmapDrawable类代码示例

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


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

示例1: getShareIntentForImage

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Nullable
private Intent getShareIntentForImage(String sharingText) {
    File cachedImage = null;
    if (mImageResource instanceof GlideBitmapDrawable) {
        cachedImage = getCachedBitmap(((GlideBitmapDrawable) mImageResource).getBitmap());
    } else if (mImageResource instanceof GifDrawable) {
        cachedImage = getCachedGif((GifDrawable) mImageResource);
    }
    if (cachedImage != null) {
        Uri sharedUri = StreamProvider.getUriForFile("derpibooru.derpy.ui.ImageActivity", cachedImage);
        if (sharedUri != null) {
            return new Intent()
                    .setAction(Intent.ACTION_SEND)
                    .putExtra(Intent.EXTRA_SUBJECT, sharingText)
                    .putExtra(Intent.EXTRA_STREAM, sharedUri)
                    .setDataAndType(sharedUri, mContext.getContentResolver().getType(sharedUri))
                    .setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
    }
    return null;
}
 
开发者ID:deliciousblackink,项目名称:Derpibooru,代码行数:22,代码来源:ImageShare.java

示例2: bindView

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
protected void bindView(Meal contentItem) {
    SimpleTarget entreeTarget = new SimpleTarget<GlideBitmapDrawable>() {
        @Override
        public void onResourceReady(GlideBitmapDrawable glideBitmapDrawable, GlideAnimation glideAnimation) {
            Palette palette = Palette.from(glideBitmapDrawable.getBitmap()).generate();
            getRootView().setBackgroundColor(palette.getVibrantColor(0x000000));
            entree.setImageBitmap( glideBitmapDrawable.getBitmap() );
        }
    };
    Glide.with(this.getRootView().getContext()).load(contentItem.getEntree().imageUrl).into(entreeTarget);
    Glide.with(this.getRootView().getContext()).load(contentItem.getAppetizer().imageUrl).into(appetizer);
    Glide.with(this.getRootView().getContext()).load(contentItem.getDessert().imageUrl).into(dessert);
    Glide.with(this.getRootView().getContext()).load(contentItem.getBevevage().imageUrl).into(beverage);

    appetizer.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The appetizer ", contentItem.getAppetizer().name, String.valueOf(contentItem.getAppetizer().price)));
    entree.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The entree ", contentItem.getEntree().name, String.valueOf(contentItem.getEntree().price)));
    dessert.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The dessert ", contentItem.getDessert().name, String.valueOf(contentItem.getDessert().price)));
    beverage.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The beverage ", contentItem.getBevevage().name, String.valueOf(contentItem.getBevevage().price)));

    labelPrice.setText(this.getRootView().getContext().getString(R.string.total_price,
            this.getRootView().getContext().getString(R.string.currency_soles)));
    price.setText(CurrencyTools.getPrice(contentItem.getImmutablePrice()));
}
 
开发者ID:Danihelsan,项目名称:MikuyConcept,代码行数:25,代码来源:RequestHistoryAdapter.java

示例3: saveImage

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Nullable
public File saveImage(){

    Drawable drawable = getDrawable();
    Bitmap bitmap = null;

    if(drawable instanceof BitmapDrawable){
        bitmap = ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof GlideDrawable){
        bitmap = ((GlideBitmapDrawable)drawable.getCurrent()).getBitmap();
    }

    File output = new ImageSaver(getContext())
            .setExternal(true)
            .setDirectoryName(Configuration.DOWNLOAD_FOLDER)
            .setFileName(getContext().getString(R.string.app_name) + "-" + System.currentTimeMillis())
            .save(bitmap);

    if(output != null){
        return output;
    }
    return null;
}
 
开发者ID:HugoGresse,项目名称:Anecdote,代码行数:24,代码来源:CustomImageView.java

示例4: rotation

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
/**
 * 旋转操作
 *
 * @param angle 旋转角度
 */
@Deprecated
private void rotation(int angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    Drawable drawable = mBannerImg.getDrawable();
    if (drawable != null) {
        Bitmap bm;
        if (drawable instanceof BitmapDrawable) {
            bm = ((BitmapDrawable) drawable).getBitmap();
        } else if (drawable instanceof GlideBitmapDrawable) {
            bm = ((GlideBitmapDrawable) drawable).getBitmap();
        } else {
            Drawable d = ((TransitionDrawable) drawable).getDrawable(1);
            bm = ((BitmapDrawable) d).getBitmap();
        }
        int bW = bm.getWidth();
        int bH = bm.getHeight();
        Bitmap resizeBm = Bitmap.createBitmap(bm, 0, 0, bW, bH, matrix, true);
        mBannerImg.setScaleType(ImageView.ScaleType.FIT_XY);
        mBannerImg.setImageBitmap(resizeBm);
        mBannerImg.requestLayout();
    }
}
 
开发者ID:AriaLyy,项目名称:DGameDetail,代码行数:29,代码来源:ScreenshotFragment.java

示例5: setImageDrawable

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public void setImageDrawable(Drawable drawable){
    Drawable d = drawable;
    if (drawable != null) {
        Bitmap bitmap;
        if (drawable instanceof GlideBitmapDrawable)
            bitmap = ((GlideBitmapDrawable) drawable).getBitmap();
        else if (drawable instanceof BitmapDrawable)
            bitmap = ((BitmapDrawable) drawable).getBitmap();
        else
            bitmap = null;
        if (bitmap != null) {
            Bitmap clipped = circularClipBitmap(bitmap);
            d = new BitmapDrawable(getResources(), clipped);
        }
    }
    super.setImageDrawable(d);
}
 
开发者ID:warnerbros,项目名称:cpe-manifest-android-experience,代码行数:19,代码来源:CircularClippedImageView.java

示例6: setImageDrawable

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public void setImageDrawable(Drawable drawable){
    Drawable d = drawable;
    if (drawable != null) {
        Bitmap bitmap;
        if (drawable instanceof GlideBitmapDrawable)
            bitmap = ((GlideBitmapDrawable) drawable).getBitmap();
        else if (drawable instanceof BitmapDrawable)
            bitmap = ((BitmapDrawable) drawable).getBitmap();
        else
            bitmap = null;
        if (bitmap != null) {
            Bitmap clipped = overlayBitmap(bitmap);
            d = new BitmapDrawable(getResources(), clipped);
        }
    }
    super.setImageDrawable(d);
}
 
开发者ID:warnerbros,项目名称:cpe-manifest-android-experience,代码行数:19,代码来源:SelectedOverlayImageView.java

示例7: getCropBitmap

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
/**
 * @param expectWidth     期望的宽度
 * @param exceptHeight    期望的高度
 * @param isSaveRectangle 是否按矩形区域保存图片
 * @return 裁剪后的Bitmap
 */
public Bitmap getCropBitmap(int expectWidth, int exceptHeight, boolean isSaveRectangle) {
    if (expectWidth <= 0 || exceptHeight < 0) return null;

    Bitmap srcBitmap = null;
    Drawable drawable = getDrawable();
    if (drawable instanceof BitmapDrawable) {
        srcBitmap = ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof GlideBitmapDrawable) {
        srcBitmap = ((GlideBitmapDrawable) drawable).getBitmap();
    }
    if (srcBitmap == null) {
        return null;
    }
    srcBitmap = rotate(srcBitmap, sumRotateLevel * 90);  //最好用level,因为角度可能不是90的整数
    if (srcBitmap == null) {
        return null;
    }
    return makeCropBitmap(srcBitmap, mFocusRect, getImageMatrixRect(), expectWidth, exceptHeight, isSaveRectangle);
}
 
开发者ID:sundevin,项目名称:PicturePicker,代码行数:26,代码来源:CropImageView.java

示例8: downloadPicture

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
public void downloadPicture(
        @NonNull final GlideBitmapDrawable glideBitmapDrawable,
        @NonNull final Context context, @NonNull final Application application) {
    this.mCompositeSubscription.add(
            this.getSavePictureObservable(glideBitmapDrawable, context, application)
                .subscribe(new Subscriber<String>() {
                    @Override public void onCompleted() {
                        PicturePresenter.this.mCompositeSubscription.remove(this);
                    }


                    @Override public void onError(Throwable e) {
                        if (PicturePresenter.this.getMvpView() != null) {
                            PicturePresenter.this.getMvpView().onFailure(e);
                        }
                    }


                    @Override public void onNext(String s) {
                        if (PicturePresenter.this.getMvpView() != null) {
                            PicturePresenter.this.getMvpView().onDownloadSuccess(s);
                        }
                    }
                }));
}
 
开发者ID:CaMnter,项目名称:EasyGank,代码行数:26,代码来源:PicturePresenter.java

示例9: sharePicture

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
public void sharePicture(
        @NonNull final GlideBitmapDrawable glideBitmapDrawable,
        @NonNull final Context context, @NonNull final Application application) {
    this.mCompositeSubscription.add(
            this.getSavePictureObservable(glideBitmapDrawable, context, application)
                .subscribe(new Subscriber<String>() {
                    @Override public void onCompleted() {
                        PicturePresenter.this.mCompositeSubscription.remove(this);
                    }


                    @Override public void onError(Throwable e) {
                        if (PicturePresenter.this.getMvpView() != null) {
                            PicturePresenter.this.getMvpView().onFailure(e);
                        }
                    }


                    @Override public void onNext(String s) {
                        if (PicturePresenter.this.getMvpView() != null) {
                            Uri uri = Uri.parse("file://" + s);
                            PicturePresenter.this.getMvpView().onShare(uri);
                        }
                    }
                }));
}
 
开发者ID:CaMnter,项目名称:EasyGank,代码行数:27,代码来源:PicturePresenter.java

示例10: loadNet

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public void loadNet(Context context, String url, Options options, final LoadCallback callback) {
    DrawableTypeRequest request = getRequestManager(context).load(url);
    if (options == null) options = Options.defaultOptions();

    if (options.loadingResId != Options.RES_NONE) {
        request.placeholder(options.loadingResId);
    }
    if (options.loadErrorResId != Options.RES_NONE) {
        request.error(options.loadErrorResId);
    }

    wrapScaleType(request, options)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .crossFade()
            .into(new SimpleTarget<GlideBitmapDrawable>() {

                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    if (callback != null) {
                        callback.onLoadFailed(e);
                    }
                }

                @Override
                public void onResourceReady(GlideBitmapDrawable resource, GlideAnimation<? super GlideBitmapDrawable> glideAnimation) {
                    if (resource != null && resource.getBitmap() != null) {
                        if (callback != null) {
                            callback.onLoadReady(resource.getBitmap());
                        }
                    }
                }

            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:GlideLoader.java

示例11: loadNet

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public void loadNet(Context context, String url, Options options, final LoadCallback callback) {
    DrawableTypeRequest request = getRequestManager(context).load(url);
    if (options == null) options = Options.defaultOptions();

    if (options.loadingResId != Options.RES_NONE) {
        request.placeholder(options.loadingResId);
    }
    if (options.loadErrorResId != Options.RES_NONE) {
        request.error(options.loadErrorResId);
    }

    request.diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .crossFade()
            .into(new SimpleTarget<GlideBitmapDrawable>() {

                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    if (callback != null) {
                        callback.onLoadFailed(e);
                    }
                }

                @Override
                public void onResourceReady(GlideBitmapDrawable resource, GlideAnimation<? super GlideBitmapDrawable> glideAnimation) {
                    if (resource != null && resource.getBitmap() != null) {
                        if (callback != null) {
                            callback.onLoadReady(resource.getBitmap());
                        }
                    }
                }

            });
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:36,代码来源:GlideLoader.java

示例12: saveImage

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public void saveImage(final PhotoView photoViewTemp) {
    if (photoViewTemp != null) {
        GlideBitmapDrawable glideBitmapDrawable = (GlideBitmapDrawable) photoViewTemp.getDrawable();
        if (glideBitmapDrawable == null) {
            return;
        }
        Bitmap bitmap = glideBitmapDrawable.getBitmap();
        if (bitmap == null) {
            return;
        }
        mView.startLoading();
        FileUtils.saveImage(photoViewTemp.getContext(), bitmap, new FileUtils.SaveResultCallback() {
            @Override
            public void onSavedSuccess() {
                photoViewTemp.post(new Runnable() {
                    @Override
                    public void run() {
                        mView.stopLoading();
                        mView.onSaveImageSucceed();
                    }
                });
            }

            @Override
            public void onSavedFailed() {
                photoViewTemp.post(new Runnable() {
                    @Override
                    public void run() {
                        mView.stopLoading();
                        mView.onSaveImageFailed("保存失败");
                    }
                });
            }
        });
    }
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:38,代码来源:ViewImagePresenter.java

示例13: onShareClick

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public void onShareClick(Photo photo, ImageView img) {
    Bitmap bitmap = ((GlideBitmapDrawable)img.getDrawable()).getBitmap();
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/jpeg");

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    String path = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), bitmap, null, null);
    Uri imageUri =  Uri.parse(path);

    share.putExtra(Intent.EXTRA_STREAM, imageUri);
    startActivity(Intent.createChooser(share, getString(R.string.photolist_message_share)));
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:15,代码来源:PhotoListFragment.java

示例14: bindView

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
protected void bindView(Meal contentItem) {

    SimpleTarget entreeTarget = new SimpleTarget<GlideBitmapDrawable>() {
        @Override
        public void onResourceReady(GlideBitmapDrawable glideBitmapDrawable, GlideAnimation glideAnimation) {
            Palette palette = Palette.from(glideBitmapDrawable.getBitmap()).generate();
            getRootView().setBackgroundColor(palette.getVibrantColor(0x000000));
            entree.setImageBitmap( glideBitmapDrawable.getBitmap() );
        }
    };
    Glide.with(this.getRootView().getContext()).load(contentItem.getAppetizer().imageUrl).dontAnimate().into(appetizer);
    Glide.with(this.getRootView().getContext()).load(contentItem.getEntree().imageUrl).into(entreeTarget);
    Glide.with(this.getRootView().getContext()).load(contentItem.getDessert().imageUrl).dontAnimate().into(dessert);
    Glide.with(this.getRootView().getContext()).load(contentItem.getBevevage().imageUrl).dontAnimate().into(beverage);
    labelPrice.setText(this.getRootView().getContext().getString(R.string.total_price,
            this.getRootView().getContext().getString(R.string.currency_soles)));
    price.setText(CurrencyTools.getPrice(contentItem.getImmutablePrice()));

    appetizer.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The appetizer ", contentItem.getAppetizer().name, String.valueOf(contentItem.getAppetizer().price)));
    entree.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The entree ", contentItem.getEntree().name, String.valueOf(contentItem.getEntree().price)));
    dessert.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The dessert ", contentItem.getDessert().name, String.valueOf(contentItem.getDessert().price)));
    beverage.setContentDescription(getRootView().getContext().getString(R.string.detail_description, "The beverage ", contentItem.getBevevage().name, String.valueOf(contentItem.getBevevage().price)));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        appetizer.setTransitionName(MealDetailFragment.KEY_APPETIZER + contentItem.getAppetizer().type + contentItem.getAppetizer().productId);
        entree.setTransitionName(MealDetailFragment.KEY_ENTREE + contentItem.getEntree().type + contentItem.getEntree().productId);
        dessert.setTransitionName(MealDetailFragment.KEY_DESSERT + contentItem.getDessert().type + contentItem.getDessert().productId);
        beverage.setTransitionName(MealDetailFragment.KEY_BEVERAGE + contentItem.getBevevage().type + contentItem.getBevevage().productId);
    }
}
 
开发者ID:Danihelsan,项目名称:MikuyConcept,代码行数:32,代码来源:RequestTodayAdapter.java

示例15: onResourceReady

import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable; //导入依赖的package包/类
@Override
public boolean onResourceReady(GlideBitmapDrawable resource, String model, Target<GlideBitmapDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    dissProgress();
    Log.d(TAG, "onResourceReady: " + isFromMemoryCache);
    if (isFromMemoryCache) {
        mIvShow.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.scale));
    }
    return false;
}
 
开发者ID:zhouruikevin,项目名称:ImageLoadPK,代码行数:10,代码来源:SimpleActivity.java


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