Advertisement
dzikovskyy

Create Bitmap with Picasso, Android

May 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. // make sure to set Target as strong reference
  2. private Target loadtarget;
  3.  
  4. public void loadBitmap(String url) {
  5.  
  6.     if (loadtarget == null) loadtarget = new Target() {
  7.         @Override
  8.         public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
  9.             // do something with the Bitmap
  10.             handleLoadedBitmap(bitmap);
  11.         }
  12.  
  13.         @Override
  14.         public void onBitmapFailed() {
  15.  
  16.         }
  17.     };
  18.  
  19.     Picasso.with(this).load(url).into(loadtarget);
  20. }
  21.  
  22. public void handleLoadedBitmap(Bitmap b) {
  23.     // do something here
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement