Java 类com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable 实例源码

项目:Derpibooru    文件:ImageShare.java   
@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;
}
项目:MikuyConcept    文件:RequestHistoryAdapter.java   
@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()));
}
项目:Anecdote    文件:CustomImageView.java   
@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;
}
项目:DGameDetail    文件:ScreenshotFragment.java   
/**
 * 旋转操作
 *
 * @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();
    }
}
项目:cpe-manifest-android-experience    文件:CircularClippedImageView.java   
@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);
}
项目:cpe-manifest-android-experience    文件:SelectedOverlayImageView.java   
@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);
}
项目:PicturePicker    文件:CropImageView.java   
/**
 * @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);
}
项目:EasyGank    文件:PicturePresenter.java   
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);
                        }
                    }
                }));
}
项目:EasyGank    文件:PicturePresenter.java   
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);
                        }
                    }
                }));
}
项目:GitHub    文件:GlideLoader.java   
@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());
                        }
                    }
                }

            });
}
项目:19porn    文件:GlideLoader.java   
@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());
                        }
                    }
                }

            });
}
项目:guanggoo-android    文件:ViewImagePresenter.java   
@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("保存失败");
                    }
                });
            }
        });
    }
}
项目:androidadvanced    文件:PhotoListFragment.java   
@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)));
}
项目:XDroidMvp    文件:GlideLoader.java   
@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());
                        }
                    }
                }

            });
}
项目:MikuyConcept    文件:RequestTodayAdapter.java   
@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);
    }
}
项目:ImageLoadPK    文件:SimpleActivity.java   
@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;
}
项目:Amumu    文件:DribbbleTarget.java   
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable>
        animation) {
    super.onResourceReady(resource, animation);
    if (!autoplayGifs) {
        resource.stop();
    }

    BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
    if (resource instanceof GlideBitmapDrawable) {
        Palette.from(((GlideBitmapDrawable) resource).getBitmap())
                .clearFilters()
                .generate(this);
    } else if (resource instanceof GifDrawable) {
        Bitmap image = ((GifDrawable) resource).getFirstFrame();
        Palette.from(image).clearFilters().generate(this);

        // look at the corner to determine the gif badge color
        int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics
                ().scaledDensity);
        Bitmap corner = Bitmap.createBitmap(image,
                image.getWidth() - cornerSize,
                image.getHeight() - cornerSize,
                cornerSize, cornerSize);
        boolean isDark = ColorUtils.isDark(corner);
        corner.recycle();
        badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(),
                isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
    }
}
项目:Amumu    文件:GlideUtils.java   
public static Bitmap getBitmap(GlideDrawable glideDrawable) {
    if (glideDrawable instanceof GlideBitmapDrawable) {
        return ((GlideBitmapDrawable) glideDrawable).getBitmap();
    } else if (glideDrawable instanceof GifDrawable) {
        return ((GifDrawable) glideDrawable).getFirstFrame();
    }
    return null;
}
项目:RecipeFinderJavaVersion    文件:RecipeListFragment.java   
@Override
public void onItemClicked(Recipe recipe, RecipeListItemBinding itemBinding) {
    Bundle recipeData = new Bundle();
    Fragment fragment = new RecipeDetailsFragment();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setSharedElementReturnTransition(TransitionInflater.from(getActivity())
                .inflateTransition(R.transition.change_image_transform));
        setExitTransition(new Fade());

        fragment.setSharedElementEnterTransition(TransitionInflater.from(getActivity())
                .inflateTransition(R.transition.change_image_transform));
        fragment.setEnterTransition(new Fade());
    }

    recipeData.putSerializable(Extras.DATA, recipe);

    if (itemBinding.ivRecipeImage.getDrawable() != null) {
        Bitmap bitmapImage = itemBinding.ivRecipeImage.getDrawable() instanceof GlideBitmapDrawable ?
                ((GlideBitmapDrawable) itemBinding.ivRecipeImage.getDrawable()).getBitmap() :
                ((BitmapDrawable) itemBinding.ivRecipeImage.getDrawable()).getBitmap();
        recipeData.putParcelable(Extras.IMAGE_DATA, bitmapImage);
    }

    recipeData.putString(Extras.IMAGE_TRANSITION_NAME, ViewCompat.getTransitionName(itemBinding.ivRecipeImage));

    fragment.setArguments(recipeData);

    getFragmentManager()
            .beginTransaction()
            .addToBackStack("RecipeDetails")
            .replace(R.id.fl_content, fragment)
            .addSharedElement(itemBinding.ivRecipeImage, ViewCompat.getTransitionName(itemBinding.ivRecipeImage))
            .commit();
}
项目:MaterialHome    文件:EBookSeriesCeilHolder.java   
private void initEvent() {
    Glide.with(UIUtils.getContext())
            .load(EBookUtils.getImageUrl(tagBook.getCover()))
            .into(iv_book_img);
    float ratio = 0;
    try {
        ratio = Float.parseFloat(tagBook.getRetentionRatio()) / 20;
    } catch (Exception e) {
        e.printStackTrace();
    }
    tv_title.setText(tagBook.getTitle());
    ratingBar_hots.setRating(ratio);
    tv_hots_num.setText(tagBook.getLatelyFollower() + "人在追");
    mContentView.setOnClickListener(v -> {
        Bundle b = new Bundle();
        b.putParcelable("BookDetail", tagBook);
        b.putString("bookId", tagBook.getId());
        Bitmap bitmap;
        GlideBitmapDrawable imageDrawable = (GlideBitmapDrawable) iv_book_img.getDrawable();
        if (imageDrawable != null) {
            bitmap = imageDrawable.getBitmap();
            b.putParcelable("book_img", bitmap);
        }
        Intent intent = new Intent(UIUtils.getContext(), EBookDetailActivity.class);
        intent.putExtras(b);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (BaseActivity.activity == null) {
                UIUtils.startActivity(intent);
                return;
            }
            ActivityOptionsCompat options = ActivityOptionsCompat.
                    makeSceneTransitionAnimation(BaseActivity.activity, iv_book_img, "book_img");
            BaseActivity.activity.startActivity(intent, options.toBundle());
        } else {
            UIUtils.startActivity(intent);
        }
    });
}
项目:MaterialHome    文件:BookSeriesCeilHolder.java   
private void initEvent() {
    Glide.with(UIUtils.getContext())
            .load(mBookInfoResponse.getImages().getLarge())
            .into(iv_book_img);
    tv_title.setText(mBookInfoResponse.getTitle());
    ratingBar_hots.setRating(Float.valueOf(mBookInfoResponse.getRating().getAverage()) / 2);
    tv_hots_num.setText(mBookInfoResponse.getRating().getAverage());
    mContentView.setOnClickListener(v -> {
        Bundle b = new Bundle();
        b.putSerializable(BookInfoResponse.serialVersionName, mBookInfoResponse);
        Bitmap bitmap;

        bitmap = ((GlideBitmapDrawable) (iv_book_img.getDrawable())).getBitmap();
        b.putParcelable("book_img", bitmap);
        Intent intent = new Intent(UIUtils.getContext(), BookDetailActivity.class);
        intent.putExtras(b);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (BaseActivity.activity == null) {
                UIUtils.startActivity(intent);
                return;
            }
            ActivityOptionsCompat options = ActivityOptionsCompat.
                    makeSceneTransitionAnimation(BaseActivity.activity, iv_book_img, "book_img");
            BaseActivity.activity.startActivity(intent, options.toBundle());
        } else {
            UIUtils.startActivity(intent);
        }
    });
}
项目:MaterialHome    文件:BookListAdapter.java   
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof BookListHolder) {
        final BookInfoResponse bookInfo = bookInfoResponses.get(position);
        Glide.with(mContext)
                .load(bookInfo.getImages().getLarge())
                .into(((BookListHolder) holder).iv_book_img);
        ((BookListHolder) holder).tv_book_title.setText(bookInfo.getTitle());
        ((BookListHolder) holder).ratingBar_hots.setRating(Float.valueOf(bookInfo.getRating().getAverage()) / 2);
        ((BookListHolder) holder).tv_hots_num.setText(bookInfo.getRating().getAverage());
        ((BookListHolder) holder).tv_book_info.setText(bookInfo.getInfoString());
        ((BookListHolder) holder).tv_book_description.setText("\u3000" + bookInfo.getSummary());
        ((BookListHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle b = new Bundle();
                b.putSerializable(BookInfoResponse.serialVersionName, bookInfo);
                Bitmap bitmap;
                GlideBitmapDrawable imageDrawable = (GlideBitmapDrawable) ((BookListHolder) holder).iv_book_img.getDrawable();
                if (imageDrawable != null) {
                    bitmap = imageDrawable.getBitmap();
                    b.putParcelable("book_img", bitmap);
                }
                Intent intent = new Intent(UIUtils.getContext(), BookDetailActivity.class);
                intent.putExtras(b);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if (BaseActivity.activity == null) {
                        UIUtils.startActivity(intent);
                        return;
                    }
                    ActivityOptionsCompat options = ActivityOptionsCompat.
                            makeSceneTransitionAnimation(BaseActivity.activity, ((BookListHolder) holder).iv_book_img, "book_img");
                    BaseActivity.activity.startActivity(intent, options.toBundle());
                } else {
                    UIUtils.startActivity(intent);
                }
            }
        });
    }
}
项目:EasyGank    文件:PicturePresenter.java   
public Observable<String> getSavePictureObservable(
        @NonNull final GlideBitmapDrawable glideBitmapDrawable,
        @NonNull final Context context, @NonNull final Application application) {
    return Observable.create(new Observable.OnSubscribe<String>() {
        @Override public void call(Subscriber<? super String> subscriber) {
            try {
                String dirPath = DeviceUtils.createAPPFolder(
                        context.getString(R.string.app_name), application);
                File downloadFile = new File(new File(dirPath),
                        UUID.randomUUID().toString().replace("-", "") + ".jpg");
                if (!downloadFile.exists()) {
                    File parent = downloadFile.getParentFile();
                    if (parent != null && !parent.exists()) parent.mkdirs();
                }
                FileOutputStream output = new FileOutputStream(downloadFile);
                glideBitmapDrawable.getBitmap()
                                   .compress(Bitmap.CompressFormat.JPEG, 100, output);
                output.close();

                // 更新相册
                Uri uri = Uri.fromFile(downloadFile);
                Intent scannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
                context.sendBroadcast(scannerIntent);
                subscriber.onNext(downloadFile.getPath());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }).compose(RxUtils.applyIOToMainThreadSchedulers());
}
项目:android-proguards    文件:DribbbleTarget.java   
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable>
        animation) {
    super.onResourceReady(resource, animation);
    if (!autoplayGifs) {
        resource.stop();
    }

    BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
    if (resource instanceof GlideBitmapDrawable) {
        Palette.from(((GlideBitmapDrawable) resource).getBitmap())
                .clearFilters()
                .generate(this);
    } else if (resource instanceof GifDrawable) {
        Bitmap image = ((GifDrawable) resource).getFirstFrame();
        Palette.from(image).clearFilters().generate(this);

        // look at the corner to determine the gif badge color
        int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics
                ().scaledDensity);
        Bitmap corner = Bitmap.createBitmap(image,
                image.getWidth() - cornerSize,
                image.getHeight() - cornerSize,
                cornerSize, cornerSize);
        boolean isDark = ColorUtils.isDark(corner);
        corner.recycle();
        badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(),
                isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
    }
}
项目:android-proguards    文件:GlideUtils.java   
public static Bitmap getBitmap(GlideDrawable glideDrawable) {
    if (glideDrawable instanceof GlideBitmapDrawable) {
        return ((GlideBitmapDrawable) glideDrawable).getBitmap();
    } else if (glideDrawable instanceof GifDrawable) {
        return ((GifDrawable) glideDrawable).getFirstFrame();
    }
    return null;
}
项目:OldDriver-master    文件:DribbbleTarget.java   
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable>
        animation) {
    super.onResourceReady(resource, animation);
    if (!autoplayGifs) {
        resource.stop();
    }

    BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView();
    if (resource instanceof GlideBitmapDrawable) {
        Palette.from(((GlideBitmapDrawable) resource).getBitmap())
                .clearFilters()
                .generate(this);
    } else if (resource instanceof GifDrawable) {
        Bitmap image = ((GifDrawable) resource).getFirstFrame();
        Palette.from(image).clearFilters().generate(this);

        // look at the corner to determine the gif badge color
        int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics
                ().scaledDensity);
        Bitmap corner = Bitmap.createBitmap(image,
                image.getWidth() - cornerSize,
                image.getHeight() - cornerSize,
                cornerSize, cornerSize);
        boolean isDark = ColorUtils.isDark(corner);
        corner.recycle();
        badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(),
                isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image));
    }
}
项目:OldDriver-master    文件:GlideUtils.java   
public static Bitmap getBitmap(GlideDrawable glideDrawable) {
    if (glideDrawable instanceof GlideBitmapDrawable) {
        return ((GlideBitmapDrawable) glideDrawable).getBitmap();
    } else if (glideDrawable instanceof GifDrawable) {
        return ((GifDrawable) glideDrawable).getFirstFrame();
    }
    return null;
}
项目:PEP---Notes    文件:DetailFragment.java   
private void replacePlayingAudioBitmap (View v) {
    Drawable d = ((ImageView) v.findViewById(R.id.gridview_item_picture)).getDrawable();
    if (BitmapDrawable.class.isAssignableFrom(d.getClass())) {
        recordingBitmap =  ((BitmapDrawable) d).getBitmap();
    } else {
        recordingBitmap =  ((GlideBitmapDrawable)d.getCurrent()).getBitmap();
    }
    ((ImageView) v.findViewById(R.id.gridview_item_picture)).setImageBitmap(ThumbnailUtils
            .extractThumbnail(BitmapFactory.decodeResource(mainActivity.getResources(),
                    R.drawable.stop), Constants.THUMBNAIL_SIZE, Constants.THUMBNAIL_SIZE));
}
项目:GlidePlus    文件:ImageWrapperDrawableTranscoder.java   
public ImageWrapperDrawableTranscoder(
        ResourceTranscoder<Bitmap, GlideBitmapDrawable> bitmapDrawableResourceTranscoder) {
    this.bitmapDrawableResourceTranscoder = bitmapDrawableResourceTranscoder;
}
项目:ReadMark    文件:BookListAdapter.java   
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if(holder instanceof BookListHolder){
        final BookInfoResponse bookInfo = bookInfoResponses.get(position);
        Glide.with(mContext)
                .load(bookInfo.getImages().getLarge())
                .into(((BookListHolder) holder).iv_book_img);
        ((BookListHolder) holder).tv_book_title.setText(bookInfo.getTitle());
        ((BookListHolder) holder).ratingBar_hots.setRating(Float.valueOf(bookInfo.getRating().getAverage()) / 2);
        ((BookListHolder) holder).tv_hots_num.setText(bookInfo.getRating().getAverage());
        ((BookListHolder) holder).tv_book_info.setText(bookInfo.getInfoString());
        ((BookListHolder) holder).tv_book_description.setText("\u3000" + bookInfo.getSummary());
        ((BookListHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle b = new Bundle();
                b.putSerializable("book_info", bookInfo);
                GlideBitmapDrawable drawable = (GlideBitmapDrawable) ((BookListHolder) holder).iv_book_img.getDrawable();
                Bitmap bitmap = drawable.getBitmap();
                b.putParcelable("book_image", bitmap);
                Intent intent = new Intent(UIUtils.getContext(), BookDetailActivity.class);
                intent.putExtras(b);

                //如果版本大于5.0
                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
                    if(BaseActivity.activity == null){
                        UIUtils.startActivity(intent);
                        return;
                    }
                    ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
                            .makeSceneTransitionAnimation(BaseActivity.activity
                                    , ((BookListHolder) holder).iv_book_img
                                    , "book_img");
                    BaseActivity.activity.startActivity(intent, optionsCompat.toBundle());
                }else{
                    //如果版本小于5.0,直接启动,无过渡动画
                    UIUtils.startActivity(intent);
                }
            }
        });

    }
}
项目:gigigo-imageLoader-library-android    文件:ImageLoaderBuilderImp.java   
public void into(final ImageLoaderCallback imageLoaderCallback, final ImageView imageView) {
  this.imageview = imageView;
  DrawableRequestBuilder drawableRequestBuilder =
      build();

  drawableRequestBuilder.into(new SimpleTarget<Object>() {

    @Override public void onLoadStarted(Drawable placeholder) {
      super.onLoadStarted(placeholder);
      if (imageLoaderCallback != null) {
        imageLoaderCallback.onLoading();
      }
    }

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

    }

    @Override
    public void onResourceReady(Object resource, GlideAnimation<? super Object> glideAnimation) {
      if (imageLoaderCallback == null) {
        if (resource instanceof GifDrawable) {
          mGifRequest.into(imageView);
        } else if (resource instanceof GlideBitmapDrawable) {
          imageView.setImageDrawable((GlideBitmapDrawable) resource);
        }
      } else if (imageView == null) {
        if (resource instanceof GifDrawable) {
          imageLoaderCallback.onSuccess(((GifDrawable) resource).getFirstFrame());
        } else if (resource instanceof GlideBitmapDrawable) {

          imageLoaderCallback.onSuccess(((GlideBitmapDrawable) resource).getBitmap());
        }
      } else {
        if (resource instanceof GifDrawable) {
          mGifRequest.into(imageView);
          imageLoaderCallback.onSuccess(((GifDrawable) resource).getFirstFrame());
        } else if (resource instanceof GlideBitmapDrawable) {
          imageView.setImageBitmap(((GlideBitmapDrawable) resource).getBitmap());
          imageLoaderCallback.onSuccess(((GlideBitmapDrawable) resource).getBitmap());
        }
      }
    }
  });
}
项目:tribbble    文件:ShotActivity.java   
@Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
  super.onResourceReady(resource, animation);
  callback.call(((GlideBitmapDrawable) resource).getBitmap());
}
项目:ImageLoadPK    文件:SimpleActivity.java   
@Override
public boolean onException(Exception e, String model, Target<GlideBitmapDrawable> target, boolean isFirstResource) {
    return false;
}
项目:ImageLoadPK    文件:SimpleActivity.java   
@Override
public boolean onResourceReady(GlideBitmapDrawable resource, String model, Target<GlideBitmapDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    dissProgress();
    return false;
}
项目:ImageLoadPK    文件:SimpleActivity.java   
@Override
public boolean onException(Exception e, String model, Target<GlideBitmapDrawable> target, boolean isFirstResource) {
    return false;
}
项目:android_image_loader    文件:ImageTask.java   
/**
 */
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    callback.onImageLoadFinished(task, ((GlideBitmapDrawable) resource).getBitmap());
    return false;
}
项目:fast-dev-library    文件:SmoothImageView.java   
private void initTransform() {
    if (getDrawable() == null) {
        return;
    }

    if (getDrawable() instanceof ColorDrawable) return;

    if (mBitmap == null || mBitmap.isRecycled()) {
        if (getDrawable() instanceof BitmapDrawable) {
            mBitmap = ((BitmapDrawable) getDrawable()).getBitmap();
        } else if (getDrawable() instanceof GlideBitmapDrawable) {
            mBitmap = ((GlideBitmapDrawable) getDrawable()).getBitmap();
        } else if (getDrawable() instanceof GifDrawable) {
            mBitmap = ((GifDrawable) getDrawable()).getFirstFrame();
        } else {
            return;
        }
    }

    if (mTransfrom != null) {
        return;
    }
    if (getWidth() == 0 || getHeight() == 0) {
        return;
    }
    mTransfrom = new Transfrom();

    float xSScale = mOriginalWidth / ((float) mBitmap.getWidth());
    float ySScale = mOriginalHeight / ((float) mBitmap.getHeight());
    float startScale = xSScale > ySScale ? xSScale : ySScale;
    mTransfrom.startScale = startScale;

    float xEScale = getWidth() / ((float) mBitmap.getWidth());
    float yEScale = getHeight() / ((float) mBitmap.getHeight());
    float endScale = xEScale < yEScale ? xEScale : yEScale;
    mTransfrom.endScale = endScale;

    mTransfrom.startRect = new LocationSizeF();
    mTransfrom.startRect.left = mOriginalLocationX;
    mTransfrom.startRect.top = mOriginalLocationY;
    mTransfrom.startRect.width = mOriginalWidth;
    mTransfrom.startRect.height = mOriginalHeight;

    mTransfrom.endRect = new LocationSizeF();
    float bitmapEndWidth = mBitmap.getWidth() * mTransfrom.endScale;
    float bitmapEndHeight = mBitmap.getHeight() * mTransfrom.endScale;
    mTransfrom.endRect.left = (getWidth() - bitmapEndWidth) / 2;
    mTransfrom.endRect.top = (getHeight() - bitmapEndHeight) / 2;
    mTransfrom.endRect.width = bitmapEndWidth;
    mTransfrom.endRect.height = bitmapEndHeight;

    mTransfrom.rect = new LocationSizeF();
}
项目:MaterialHome    文件:EBookListAdapter.java   
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof EBookListHolder) {
        final BookDetail bookInfo = bookInfoResponses.get(position);
        Glide.with(mContext)
                .load(EBookUtils.getImageUrl(bookInfo.getCover()))
                .into(((EBookListHolder) holder).iv_book_img);
        ((EBookListHolder) holder).tv_book_title.setText(bookInfo.getTitle());
        float ratio = 0;
        try {
            ratio = Float.parseFloat(bookInfo.getRetentionRatio()) / 20;
        } catch (Exception e) {
            e.printStackTrace();
        }
        ((EBookListHolder) holder).ratingBar_hots.setRating(ratio);
        ((EBookListHolder) holder).tv_hots_num.setText(bookInfo.getLatelyFollower() + "人在追");
        ((EBookListHolder) holder).tv_book_info.setText(bookInfo.getBookInfoString());
        ((EBookListHolder) holder).tv_book_description.setText("\u3000" + bookInfo.getShortIntro());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle b = new Bundle();
                b.putParcelable("BookDetail", bookInfo);
                b.putString("bookId", bookInfo.getId());
                Bitmap bitmap;
                GlideBitmapDrawable imageDrawable = (GlideBitmapDrawable) ((EBookListHolder) holder).iv_book_img.getDrawable();
                if (imageDrawable != null) {
                    bitmap = imageDrawable.getBitmap();
                    b.putParcelable("book_img", bitmap);
                }
                Intent intent = new Intent(mContext, EBookDetailActivity.class);
                intent.putExtras(b);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if (BaseActivity.activity == null) {
                        UIUtils.startActivity(intent);
                        return;
                    }
                    ActivityOptionsCompat options = ActivityOptionsCompat.
                            makeSceneTransitionAnimation(BaseActivity.activity, ((EBookListHolder) holder).iv_book_img, "book_img");
                    BaseActivity.activity.startActivity(intent, options.toBundle());
                } else {
                    UIUtils.startActivity(intent);
                }
            }
        });
    }
}
项目:ReadMark    文件:BookListAdapter.java   
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if(holder instanceof BookListHolder){
        final BookInfoResponse bookInfo = bookInfoResponses.get(position);
        Glide.with(mContext)
                .load(bookInfo.getImages().getLarge())
                .into(((BookListHolder) holder).iv_book_img);
        ((BookListHolder) holder).tv_book_title.setText(bookInfo.getTitle());
        ((BookListHolder) holder).ratingBar_hots.setRating(Float.valueOf(bookInfo.getRating().getAverage()) / 2);
        ((BookListHolder) holder).tv_hots_num.setText(bookInfo.getRating().getAverage());
        ((BookListHolder) holder).tv_book_info.setText(bookInfo.getInfoString());
        ((BookListHolder) holder).tv_book_description.setText("\u3000" + bookInfo.getSummary());
        ((BookListHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle b = new Bundle();
                b.putSerializable("book_info", bookInfo);
                GlideBitmapDrawable drawable = (GlideBitmapDrawable) ((BookListHolder) holder).iv_book_img.getDrawable();
                Bitmap bitmap = drawable.getBitmap();
                b.putParcelable("book_image", bitmap);
                Intent intent = new Intent(UIUtils.getContext(), BookDetailActivity.class);
                intent.putExtras(b);

                //如果版本大于5.0
                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
                    if(BaseActivity.activity == null){
                        UIUtils.startActivity(intent);
                        return;
                    }
                    ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
                            .makeSceneTransitionAnimation(BaseActivity.activity
                                    , ((BookListHolder) holder).iv_book_img
                                    , "book_img");
                    BaseActivity.activity.startActivity(intent, optionsCompat.toBundle());
                }else{
                    //如果版本小于5.0,直接启动,无过渡动画
                    UIUtils.startActivity(intent);
                }
            }
        });

    }
}
项目:q-municate-android    文件:BaseChatMessagesAdapter.java   
@Override
public boolean onResourceReady(GlideBitmapDrawable loadedBitmap, String imageUri, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
    initMaskedImageView(loadedBitmap.getBitmap());
    fileUtils.checkExistsFile(imageUri, loadedBitmap.getBitmap());
    return false;
}