summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-20 23:50:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-20 23:51:35 +0000
commitdb092a331ceb9b6cc72fd9b1a593cd77068bb66a (patch)
treed5eb47ffd24bc3a39cf8a05a166399cf1e05253e /src
parent3e4d5f20ba9128fcbe77b220380129be773887b3 (diff)
parente0cab303b8cf1fd00b152219aa56663608582f5a (diff)
downloadandroid_packages_apps_Trebuchet-db092a331ceb9b6cc72fd9b1a593cd77068bb66a.tar.gz
android_packages_apps_Trebuchet-db092a331ceb9b6cc72fd9b1a593cd77068bb66a.tar.bz2
android_packages_apps_Trebuchet-db092a331ceb9b6cc72fd9b1a593cd77068bb66a.zip
Merge "Setting drawable to droptarget in the code to avoid multiple drawable inflation" into ub-launcher3-burnaby
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java33
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) { }