diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-05-20 16:40:30 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-05-20 16:41:08 -0700 |
commit | e0cab303b8cf1fd00b152219aa56663608582f5a (patch) | |
tree | 28531c99964c0d292a9c5abdbf74b0ada42c8735 /src/com | |
parent | 20812e96402900d3ac0e007b5b63faaf1b06e5f9 (diff) | |
download | android_packages_apps_Trebuchet-e0cab303b8cf1fd00b152219aa56663608582f5a.tar.gz android_packages_apps_Trebuchet-e0cab303b8cf1fd00b152219aa56663608582f5a.tar.bz2 android_packages_apps_Trebuchet-e0cab303b8cf1fd00b152219aa56663608582f5a.zip |
Setting drawable to droptarget in the code to avoid multiple drawable inflation
Change-Id: Ib713b3051e2707d46a4ee0090aed2db1d2e641b9
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/ButtonDropTarget.java | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index b8214d1ef..80b542f1d 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -23,7 +23,6 @@ import android.content.res.ColorStateList; import android.content.res.Configuration; import android.graphics.PointF; import android.graphics.Rect; -import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.util.AttributeSet; @@ -85,21 +84,15 @@ public abstract class ButtonDropTarget extends TextView @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) protected void setDrawable(int resId) { - // Get the hover color - mDrawable = (TransitionDrawable) getCurrentDrawable(); - - if (mDrawable == null) { - // TODO: investigate why this is ever happening. Presently only on one known device. - mDrawable = (TransitionDrawable) getResources().getDrawable(resId); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null); - } else { - setCompoundDrawablesWithIntrinsicBounds(mDrawable, null, null, null); - } - } + // We do not set the drawable in the xml as that inflates two drawables corresponding to + // drawableLeft and drawableStart. + mDrawable = (TransitionDrawable) getResources().getDrawable(resId); + mDrawable.setCrossFadeEnabled(true); - if (null != mDrawable) { - mDrawable.setCrossFadeEnabled(true); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null); + } else { + setCompoundDrawablesWithIntrinsicBounds(mDrawable, null, null, null); } } @@ -111,16 +104,6 @@ public abstract class ButtonDropTarget extends TextView mSearchDropTargetBar = searchDropTargetBar; } - protected Drawable getCurrentDrawable() { - Drawable[] drawables = getCompoundDrawables(); - for (int i = 0; i < drawables.length; ++i) { - if (drawables[i] != null) { - return drawables[i]; - } - } - return null; - } - @Override public void onFlingToDelete(DragObject d, PointF vec) { } |