Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. public void loadPostPhotoAsync(final String url, ImageSize imageSize, final ImageLoadCallback imageLoadCallback) {
  2. Log.d(TAG, "try to load image with url = " + url);
  3. if (imageSize.getWidth() == 0 || imageSize.getHeight() == 0) {
  4. imageSize = new ImageSize(100, 100);
  5. }
  6. final NonViewAware imageAware = new NonViewAware(imageSize, ViewScaleType.CROP) {
  7. @Override
  8. public boolean setImageBitmap(Bitmap bitmap) {
  9. imageLoadCallback.onLoad(url, bitmap);
  10. return super.setImageBitmap(bitmap);
  11. }
  12. };
  13. ImageDataLoader.getInstance().getImageLoader().displayImage(url, imageAware);
  14. }
  15.  
  16. public void loadPostPhotoAsync(String url, final ImageLoadCallback imageLoadCallback) {
  17. Log.d(TAG, "try to load image with url = " + url);
  18. ImageDataLoader.getInstance().getImageLoader().loadImage(url, ImageDataLoader.getInstance().getDisplayImageOptions(), new ImageLoadingListener() {
  19. @Override
  20. public void onLoadingStarted(String s, View view) {
  21.  
  22. }
  23.  
  24. @Override
  25. public void onLoadingFailed(final String s, View view, FailReason failReason) {
  26. Log.i(TAG, "onLoadingFailed with url = " + s);
  27. new Handler(Looper.getMainLooper()).post(new Runnable() {
  28. @Override
  29. public void run() {
  30. imageLoadCallback.onLoadError(s);
  31. }
  32. });
  33. }
  34.  
  35. @Override
  36. public void onLoadingComplete(final String s, View view, final Bitmap bitmap) {
  37. Log.i(TAG, "onLoadingComplete with url = " + s + " bitmap is null = " + String.valueOf(bitmap == null));
  38. new Handler(Looper.getMainLooper()).post(new Runnable() {
  39. @Override
  40. public void run() {
  41. imageLoadCallback.onLoad(s, bitmap);
  42. }
  43. });
  44. }
  45.  
  46. @Override
  47. public void onLoadingCancelled(String s, View view) {
  48. Log.i(TAG, "onLoadingCancelled with url = " + s);
  49. }
  50. });
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement