Advertisement
inf926k

Untitled

Jan 1st, 2017
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1.  
  2. if (mMainImageView.getWidth() > 0) { // View is laid out
  3. Log.d(TAG, "VIEW WIDTH: " + mMainImageView.getWidth());
  4.  
  5. Picasso
  6. .with(mContext)
  7. .load(file)
  8. .into(mMainImageView);
  9. }
  10. else
  11. mMainImageView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  12. @Override
  13. public void onGlobalLayout() {
  14. Log.d(TAG, "VIEW WIDTH: " + mMainImageView.getWidth());
  15.  
  16. Picasso
  17. .with(mContext)
  18. .load(file)
  19. .into(mMainImageView);
  20. // mMainImageView.setImageBitmap(
  21. // InfUtils.getSampledBitmapByWidth(
  22. // mMainImageView.getWidth(),
  23. // file
  24. // )
  25. // );
  26. // Picasso
  27. // .with(mContext)
  28. // .load(file)
  29. // .fit()
  30. // .centerInside()
  31. // .placeholder(R.drawable.doc_placeholder)
  32. // .into(mMainImageView);
  33. // FIXME: 31.12.2016 blink
  34. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
  35. mMainImageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
  36. }
  37. else {
  38. mMainImageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
  39. }
  40.  
  41. }
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement