Java Code Examples for android.graphics.drawable.Drawable#setDither()

The following examples show how to use android.graphics.drawable.Drawable#setDither() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 6 votes vote down vote up
public static View createImageTileView(LayoutInflater layoutInflater,
        View convertView, ViewGroup parent, Drawable thumb) {
    View view;

    if (convertView == null) {
        view = layoutInflater.inflate(R.layout.wallpaper_picker_item, parent, false);
    } else {
        view = convertView;
    }

    setWallpaperItemPaddingToZero((FrameLayout) view);

    ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image);

    if (thumb != null) {
        image.setImageDrawable(thumb);
        thumb.setDither(true);
    }

    return view;
}
 
Example 2
Source File: DrawableProperties.java    From fresco with MIT License 6 votes vote down vote up
@SuppressLint("Range")
public void applyTo(Drawable drawable) {
  if (drawable == null) {
    return;
  }
  if (mAlpha != UNSET) {
    drawable.setAlpha(mAlpha);
  }
  if (mIsSetColorFilter) {
    drawable.setColorFilter(mColorFilter);
  }
  if (mDither != UNSET) {
    drawable.setDither(mDither != 0);
  }
  if (mFilterBitmap != UNSET) {
    drawable.setFilterBitmap(mFilterBitmap != 0);
  }
}
 
Example 3
Source File: ImageViewTouchBase.java    From Pi-Locker with GNU General Public License v2.0 6 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {

        super.setImageBitmap(bitmap);
        Drawable d = getDrawable();
        if (d != null) {
            d.setDither(true);
        }

        Bitmap old = mBitmapDisplayed.getBitmap();
        mBitmapDisplayed.setBitmap(bitmap);
        mBitmapDisplayed.setRotation(rotation);

        if (old != null && old != bitmap && mRecycler != null) {
            mRecycler.recycle(old);
        }
    }
 
Example 4
Source File: WallpaperPickerActivity.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
public static View createImageTileView(LayoutInflater layoutInflater,
        View convertView, ViewGroup parent, Drawable thumb) {
    View view;

    if (convertView == null) {
        view = layoutInflater.inflate(R.layout.wallpaper_picker_item, parent, false);
    } else {
        view = convertView;
    }

    ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image);

    if (thumb != null) {
        image.setImageDrawable(thumb);
        thumb.setDither(true);
    }

    return view;
}
 
Example 5
Source File: ImageViewTouchBase.java    From memoir with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = mBitmapDisplayed.getBitmap();
    mBitmapDisplayed.setBitmap(bitmap);
    mBitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && mRecycler != null) {
        mRecycler.recycle(old);
    }
}
 
Example 6
Source File: ImageViewTouchBase.java    From GalleryFinal with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = bitmapDisplayed.getBitmap();
    bitmapDisplayed.setBitmap(bitmap);
    bitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && recycler != null) {
        recycler.recycle(old);
    }
}
 
Example 7
Source File: ImageViewTouchBase.java    From WifiChat with GNU General Public License v2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = mBitmapDisplayed.getBitmap();
    mBitmapDisplayed.setBitmap(bitmap);
    mBitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && mRecycler != null) {
        mRecycler.recycle(old);
    }
}
 
Example 8
Source File: LayerDrawable.java    From Carbon with Apache License 2.0 5 votes vote down vote up
@Override
public void setDither(boolean dither) {
    final ChildDrawable[] array = mLayerState.mChildren;
    final int N = mLayerState.mNum;
    for (int i = 0; i < N; i++) {
        final Drawable dr = array[i].mDrawable;
        if (dr != null) {
            dr.setDither(dither);
        }
    }
}
 
Example 9
Source File: ImageViewTouchBase.java    From Android-RTEditor with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = mBitmapDisplayed.getBitmap();
    mBitmapDisplayed.setBitmap(bitmap);
    mBitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && mRecycler != null) {
        mRecycler.recycle(old);
    }
}
 
Example 10
Source File: ImageViewTouchBase.java    From droidddle with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = mBitmapDisplayed.getBitmap();
    mBitmapDisplayed.setBitmap(bitmap);
    mBitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && mRecycler != null) {
        mRecycler.recycle(old);
    }
}
 
Example 11
Source File: ImageViewTouchBase.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
	super.setImageBitmap(bitmap);
	Drawable d = getDrawable();
	if (d != null) {
		d.setDither(true);
	}

	Bitmap old = mBitmapDisplayed.getBitmap();
	mBitmapDisplayed.setBitmap(bitmap);
	mBitmapDisplayed.setRotation(rotation);

	if (old != null && old != bitmap && mRecycler != null) {
	//	mRecycler.recycle(old);
	}
}
 
Example 12
Source File: ImageViewTouchBase.java    From reader with MIT License 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = mBitmapDisplayed.getBitmap();
    mBitmapDisplayed.setBitmap(bitmap);
    mBitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && mRecycler != null) {
        mRecycler.recycle(old);
    }
}
 
Example 13
Source File: ImageViewTouchBase.java    From memoir with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = mBitmapDisplayed.getBitmap();
    mBitmapDisplayed.setBitmap(bitmap);
    mBitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && mRecycler != null) {
        mRecycler.recycle(old);
    }
}
 
Example 14
Source File: ImageViewTouchBase.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = bitmapDisplayed.getBitmap();
    bitmapDisplayed.setBitmap(bitmap);
    bitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && recycler != null) {
        recycler.recycle(old);
    }
}
 
Example 15
Source File: ImageViewTouchBase.java    From CloudPan with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = bitmapDisplayed.getBitmap();
    bitmapDisplayed.setBitmap(bitmap);
    bitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && recycler != null) {
        recycler.recycle(old);
    }
}
 
Example 16
Source File: ImageViewTouchBase.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = bitmapDisplayed.getBitmap();
    bitmapDisplayed.setBitmap(bitmap);
    bitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && recycler != null) {
        recycler.recycle(old);
    }
}
 
Example 17
Source File: ImageViewTouchBase.java    From yiim_v2 with GNU General Public License v2.0 5 votes vote down vote up
public void setImageBitmap(Bitmap bitmap) {
	super.setImageBitmap(bitmap);
	Drawable d = getDrawable();
	if (d != null) {
		d.setDither(true);
	}

	Bitmap old = mBitmapDisplayed;
	mBitmapDisplayed = bitmap;

	// if (old != null && old != bitmap && mRecycler != null) {
	// mRecycler.recycle(old);
	// }
}
 
Example 18
Source File: ImageViewTouchBase.java    From LockDemo with Apache License 2.0 5 votes vote down vote up
private void setImageBitmap(Bitmap bitmap, int rotation) {
    super.setImageBitmap(bitmap);
    Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }

    Bitmap old = bitmapDisplayed.getBitmap();
    bitmapDisplayed.setBitmap(bitmap);
    bitmapDisplayed.setRotation(rotation);

    if (old != null && old != bitmap && recycler != null) {
        recycler.recycle(old);
    }
}
 
Example 19
Source File: ImageViewTouchBase.java    From fanfouapp-opensource with Apache License 2.0 5 votes vote down vote up
/**
 * This is the ultimate method called when a new bitmap is set
 * 
 * @param bitmap
 * @param rotation
 */
protected void setImageBitmap(final Bitmap bitmap, final int rotation) {
    super.setImageBitmap(bitmap);
    final Drawable d = getDrawable();
    if (d != null) {
        d.setDither(true);
    }
    this.mBitmapDisplayed.setBitmap(bitmap);
    this.mBitmapDisplayed.setRotation(rotation);
}
 
Example 20
Source File: DrawableContainerCompat.java    From MaterialProgressBar with Apache License 2.0 4 votes vote down vote up
/**
 * Initializes a drawable for display in this container.
 *
 * @param d The drawable to initialize.
 */
private void initializeDrawableForDisplay(Drawable d) {
    if (mBlockInvalidateCallback == null) {
        mBlockInvalidateCallback = new BlockInvalidateCallback();
    }
    // Temporary fix for suspending callbacks during initialization. We
    // don't want any of these setters causing an invalidate() since that
    // may call back into DrawableContainer.
    d.setCallback(mBlockInvalidateCallback.wrap(d.getCallback()));
    try {
        if (mDrawableContainerState.mEnterFadeDuration <= 0 && mHasAlpha) {
            d.setAlpha(mAlpha);
        }
        if (mDrawableContainerState.mHasColorFilter) {
            // Color filter always overrides tint.
            d.setColorFilter(mDrawableContainerState.mColorFilter);
        } else {
            if (mDrawableContainerState.mHasTintList) {
                DrawableCompat.setTintList(d, mDrawableContainerState.mTintList);
            }
            if (mDrawableContainerState.mHasTintMode) {
                DrawableCompat.setTintMode(d, mDrawableContainerState.mTintMode);
            }
        }
        d.setVisible(isVisible(), true);
        d.setDither(mDrawableContainerState.mDither);
        d.setState(getState());
        d.setLevel(getLevel());
        d.setBounds(getBounds());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            d.setLayoutDirection(getLayoutDirection());
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
        }
        final Rect hotspotBounds = mHotspotBounds;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && hotspotBounds != null) {
            d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
                    hotspotBounds.right, hotspotBounds.bottom);
        }
    } finally {
        d.setCallback(mBlockInvalidateCallback.unwrap());
    }
}