Code example for BitmapDrawable

Methods: getPaint, setAlpha

0
			if (isFromMemCache) {
				mBitmapDrawable = new BitmapDrawable(bitmap);
				setImageDrawable(mBitmapDrawable);
				invalidate();
			} else { 
				mBitmapDrawable = new BitmapDrawable(bitmap);
				mBitmapDrawable.setAlpha(0);
				setImageDrawable(mBitmapDrawable);
				invalidate();
				mFadeRunnable.start();
			} 
		} 
	} 
 
	public void loadOnlyIfInMemCache(BitmapSource bitmapSource, int position) {		
		mCurrentImageSource = bitmapSource;
		Bitmap bitmap = BitmapCache.getInstance().getFromMemory(bitmapSource.getAbsoluteFileName(Type.THM));
		if (bitmap != null && (mBitmapDrawable == null || mBitmapDrawable.getBitmap() != bitmap)) {
			mBitmapDrawable = new BitmapDrawable(bitmap);
			setImageDrawable(mBitmapDrawable);
			invalidate();
		} 
	} 
	 
	public void cancelLoading() { 
		mBitmapLoader.cancel();
		if (mFadeRunnable.isFading()) {
			mFadeRunnable.stop();
		} 
	} 
	 
	public void resumeLoading() { 
		if (mFadeRunnable.isFading()) {
			return; 
		} 
		if (mCurrentImageSource != null) {
			if (mBitmapDrawable != null) {
				mBitmapDrawable.setAlpha(255);
				invalidate();
			} else { 
				mBitmapLoader.loadAsync(mCurrentImageSource, Type.THM, Config.RGB_565, Volatility.DEFAULT, this);
			} 
		} 
	} 
	 
	@Override 
	public void onFailure(Exception e) {
		DebugLog.d(TAG, "onFailure: %s", e);
 
		setImageResource(android.R.color.white);
	} 
 
	public void reset() { 
		mFadeRunnable.stop();
		mBitmapDrawable = null;
		setImageDrawable(null);
		invalidate();
	} 
	 
	public void resetIfWrongSource(BitmapSource bitmapSource) {
		if (mCurrentImageSource == null || !bitmapSource.getAbsoluteFileName(Type.THM).equals(mCurrentImageSource.getAbsoluteFileName(Type.THM))) {
			reset(); 
		} 
	} 
	 
	private FadeRunnable mFadeRunnable = new FadeRunnable();
	private static final int FADE_DURATION = 400;
	private class FadeRunnable implements Runnable {
		private boolean mIsRunning;
		private long mStartTime;
		 
		public void start() { 
			if (mBitmapDrawable.getPaint().getAlpha() == 255) {
				return; 
			} 
			 
			if (mIsRunning) {
				return;