Example #1
0
 private void clearDrawable() {
   Drawable drawable = getDrawable();
   if (drawable instanceof ImageDrawable) {
     ((ImageDrawable) drawable).recycle();
   }
   setDrawable(null);
 }
Example #2
0
  @Override
  public boolean onGetValue(@NonNull ImageBitmap value, int source) {
    ImageDrawable drawable;
    try {
      drawable = new ImageDrawable(value);
    } catch (RecycledException e) {
      Log.d(TAG, "The ImageBitmap is recycled", e);
      return false;
    }

    clearDrawable();

    setDrawable(drawable);
    drawable.start();

    return true;
  }