diff options
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 5dc3b1239..3b3b9bf9f 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -28,11 +28,13 @@ import android.graphics.Region; import android.graphics.drawable.Drawable; import android.os.Build; import android.util.AttributeSet; +import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ViewConfiguration; +import android.view.ViewParent; import android.widget.TextView; import com.android.launcher3.IconCache.IconLoadRequest; @@ -76,6 +78,7 @@ public class BubbleTextView extends TextView { private boolean mStayPressed; private boolean mIgnorePressedStateChange; + private boolean mDisableRelayout = false; private IconLoadRequest mIconLoadRequest; @@ -274,9 +277,10 @@ public class BubbleTextView extends TextView { } // Only show the shadow effect when persistent pressed state is set. - if (getParent() instanceof ShortcutAndWidgetContainer) { - CellLayout layout = (CellLayout) getParent().getParent(); - layout.setPressedIcon(this, mPressedBackground); + ViewParent parent = getParent(); + if (parent != null && parent.getParent() instanceof BubbleTextShadowHandler) { + ((BubbleTextShadowHandler) parent.getParent()).setPressedIcon( + this, mPressedBackground); } updateIconState(); @@ -464,12 +468,20 @@ public class BubbleTextView extends TextView { return icon; } + @Override + public void requestLayout() { + if (!mDisableRelayout) { + super.requestLayout(); + } + } + /** * Applies the item info if it is same as what the view is pointing to currently. */ public void reapplyItemInfo(final ItemInfo info) { if (getTag() == info) { mIconLoadRequest = null; + mDisableRelayout = true; if (info instanceof AppInfo) { applyFromApplicationInfo((AppInfo) info); } else if (info instanceof ShortcutInfo) { @@ -478,6 +490,7 @@ public class BubbleTextView extends TextView { } else if (info instanceof PackageItemInfo) { applyFromPackageItemInfo((PackageItemInfo) info); } + mDisableRelayout = false; } } @@ -509,4 +522,11 @@ public class BubbleTextView extends TextView { } } } + + /** + * Interface to be implemented by the grand parent to allow click shadow effect. + */ + public static interface BubbleTextShadowHandler { + void setPressedIcon(BubbleTextView icon, Bitmap background); + } } |