android - How to access Drawable when using Picasso? -


i'm using picasso framework handle image loading in android app. after image loaded, need access drawable apply masking operations. issue picasso converts drawable picassodrawable, , simple cast drawable not work.

this code have:

        picasso.with(mcontext).load(image.getpath()).into(mimageview, new callback() {              @override             public void onsuccess() {                  util.applymask(imageview);             }              @override             public void onerror() {             }         });  

and util.applymask(imageview) method:

public static void applymask(imageview imageview) {      // class cast exception happens since it's picassodrawable , not drawable     bitmap mainimage = ((bitmapdrawable) imageview.getdrawable()).getbitmap();  // ...  } 

a possible solution given jake wharton in github issue: https://github.com/square/picasso/issues/38

to sum up, solution is: "if want access bitmap directly you'll need use target callbacks. picassodrawable used allow fading , debug indicator."

i'm not sure how access target callback. knows how solve this?

thanks.

this answered @ github (https://github.com/square/picasso/issues/38):

private target target = new target() {       @override       public void onbitmaploaded(bitmap bitmap, picasso.loadedfrom from) {              }        @override       public void onbitmapfailed() {       }     }  private void loadbitmap() {    picasso.with(this).load("url").into(target); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -