diff options
author | Winson Chung <winsonc@google.com> | 2012-01-23 14:45:13 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2012-01-24 13:15:23 -0800 |
commit | e4e506660ba93ae2c4f1cb0b41378cf148c85e2b (patch) | |
tree | 54f745d045c344b2f8d5e925b14cbb49e2d9eefa /src/com/android/launcher2/PagedViewIcon.java | |
parent | 28c1854896bfd39d850d4ad562361fcc1651516c (diff) | |
download | android_packages_apps_Trebuchet-e4e506660ba93ae2c4f1cb0b41378cf148c85e2b.tar.gz android_packages_apps_Trebuchet-e4e506660ba93ae2c4f1cb0b41378cf148c85e2b.tar.bz2 android_packages_apps_Trebuchet-e4e506660ba93ae2c4f1cb0b41378cf148c85e2b.zip |
Locking pressed state for AllApps icons.
- Setting workaround for transition state bug until b/5897600 is fixed.
Change-Id: Icb29a4cd7bfaf527a9db5b853e7fb24c63b58b30
Diffstat (limited to 'src/com/android/launcher2/PagedViewIcon.java')
-rw-r--r-- | src/com/android/launcher2/PagedViewIcon.java | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java index 548b39458..00f9321c6 100644 --- a/src/com/android/launcher2/PagedViewIcon.java +++ b/src/com/android/launcher2/PagedViewIcon.java @@ -26,7 +26,16 @@ import android.widget.TextView; * drawables on the top). */ public class PagedViewIcon extends TextView { + /** A simple callback interface to allow a PagedViewIcon to notify when it has been pressed */ + public static interface PressedCallback { + void iconPressed(PagedViewIcon icon); + } + private static final String TAG = "PagedViewIcon"; + private static final float PRESS_ALPHA = 0.4f; + + private PagedViewIcon.PressedCallback mPressedCallback; + private boolean mResetDrawableState = false; private Bitmap mIcon; @@ -42,15 +51,38 @@ public class PagedViewIcon extends TextView { super(context, attrs, defStyle); } - public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp) { + public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp, + PagedViewIcon.PressedCallback cb) { mIcon = info.iconBitmap; + mPressedCallback = cb; setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null); setText(info.title); setTag(info); } + public void resetDrawableState() { + mResetDrawableState = true; + post(new Runnable() { + @Override + public void run() { + refreshDrawableState(); + } + }); + } + protected void drawableStateChanged() { - setAlpha(isPressed() ? 0.5f : 1f); super.drawableStateChanged(); + + // We keep in the pressed state until resetDrawableState() is called to reset the press + // feedback + if (isPressed()) { + setAlpha(PRESS_ALPHA); + if (mPressedCallback != null) { + mPressedCallback.iconPressed(this); + } + } else if (mResetDrawableState) { + setAlpha(1f); + mResetDrawableState = false; + } } } |