我正在从毕加索转向格莱德.一切正常,除了我找不到一个方法来获得错误回调.我想检索一个Bitmap,传递它并从中生成一个
Android Palette.此外,虽然可以将errorDrawable提供给加载调用,但在使用SimpleTarget时它不会显示在onResourceReady中.
在毕加索我做到了这样:
- target = new Target() {
- @Override
- public void onBitmapLoaded(Bitmap bitmap,Picasso.LoadedFrom from) {
- //handle Bitmap,generate Palette etc.
- }
- @Override
- public void onBitmapFailed(final Drawable errorDrawable) {
- // use errorDrawable to generate Palette
- }
- @Override
- public void onPrepareLoad(final Drawable placeHolderDrawable) {
- }
- };
- int width = (int) DisplayUnitsConverter.dpToPx(this,120);
- int height = (int) DisplayUnitsConverter.dpToPx(this,40);
- Picasso.with(this).load(config.getPathTologo()).resize(width,height).error(errorDrawableId).into(target);
我的滑动代码如下所示:
- Glide.with(context)
- .load(config.getPathTologo())
- .asBitmap()
- .into(new SimpleTarget<Bitmap>(width,height) {
- @Override
- public void onResourceReady(Bitmap resource,GlideAnimation glideAnimation) {
- //handle Bitmap,generate Palette etc.
- }
- });
谢谢.