Revert "Add support for setTint in all Drawables, clean up lint warnings"

This reverts commit 381f83b613f7b6e71180983dbb992ff62f8dd6e3.

Change-Id: I1181f436c647216ac46162260d9d886197b24568
This commit is contained in:
Jeff Brown
2014-06-14 02:16:41 +00:00
parent 4b17118aca
commit cda212d79d
19 changed files with 152 additions and 347 deletions

View File

@@ -31,7 +31,6 @@ import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.ColorDrawable.ColorState;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.Shader;
@@ -619,11 +618,9 @@ public class BitmapDrawable extends Drawable {
@Override
public void setTint(ColorStateList tint, PorterDuff.Mode tintMode) {
final BitmapState state = mBitmapState;
state.mTint = tint;
state.mTintMode = tintMode;
mTintFilter = updateTintFilter(mTintFilter, tint, tintMode);
mBitmapState.mTint = tint;
mBitmapState.mTintMode = tintMode;
computeTintFilter();
invalidateSelf();
}
@@ -641,6 +638,21 @@ public class BitmapDrawable extends Drawable {
return mBitmapState.mTintMode;
}
private void computeTintFilter() {
final BitmapState state = mBitmapState;
if (state.mTint != null && state.mTintMode != null) {
final int color = state.mTint.getColorForState(getState(), 0);
if (mTintFilter != null) {
mTintFilter.setColor(color);
mTintFilter.setMode(state.mTintMode);
} else {
mTintFilter = new PorterDuffColorFilter(color, state.mTintMode);
}
} else {
mTintFilter = null;
}
}
/**
* @hide Candidate for future API inclusion
*/
@@ -667,11 +679,17 @@ public class BitmapDrawable extends Drawable {
@Override
protected boolean onStateChange(int[] stateSet) {
final BitmapState state = mBitmapState;
if (state.mTint != null && state.mTintMode != null) {
mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
return true;
final ColorStateList tint = mBitmapState.mTint;
if (tint != null) {
final int newColor = tint.getColorForState(stateSet, 0);
final int oldColor = mTintFilter.getColor();
if (oldColor != newColor) {
mTintFilter.setColor(newColor);
invalidateSelf();
return true;
}
}
return false;
}