diff options
author | Scott Kennedy <skennedy@google.com> | 2014-12-12 22:36:19 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-12-12 22:36:19 +0000 |
commit | ef862b79ffd6a272ccadf2872c977dd7d16da199 (patch) | |
tree | 0c4dc64a3c7050165e34eb3f4703a84b26a978f8 | |
parent | bf01ce471e52042bb4c072c4f8e5abb05f4b60f3 (diff) | |
parent | 654c967e9560ccb40a465a78e3296980f530ed55 (diff) | |
download | chips-ef862b79ffd6a272ccadf2872c977dd7d16da199.tar.gz |
am 654c967e: Prevent infinite posting of Runnables
* commit '654c967e9560ccb40a465a78e3296980f530ed55':
Prevent infinite posting of Runnables
-rw-r--r-- | src/com/android/ex/chips/RecipientEditTextView.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index bcb7736..f1d49c6 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -201,6 +201,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements private int mCheckedItem; private boolean mNoChips = false; private boolean mShouldShrink = true; + private boolean mRequiresShrinkWhenNotGone = false; // VisibleForTesting ArrayList<DrawableRecipientChip> mTemporaryRecipients; @@ -593,13 +594,20 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements clearSelectedChip(); } else { if (getWidth() <= 0) { - // We don't have the width yet which means the view hasn't been drawn yet - // and there is no reason to attempt to commit chips yet. - // This focus lost must be the result of an orientation change - // or an initial rendering. - // Re-post the shrink for later. mHandler.removeCallbacks(mDelayedShrink); - mHandler.post(mDelayedShrink); + + if (getVisibility() == GONE) { + // We aren't going to have a width any time soon, so defer + // this until we're not GONE. + mRequiresShrinkWhenNotGone = true; + } else { + // We don't have the width yet which means the view hasn't been drawn yet + // and there is no reason to attempt to commit chips yet. + // This focus lost must be the result of an orientation change + // or an initial rendering. + // Re-post the shrink for later. + mHandler.post(mDelayedShrink); + } return; } // Reset any pending chips as they would have been handled @@ -3195,6 +3203,16 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements mAlternatePopupAnchor = v; } + @Override + public void setVisibility(int visibility) { + super.setVisibility(visibility); + + if (visibility != GONE && mRequiresShrinkWhenNotGone) { + mRequiresShrinkWhenNotGone = false; + mHandler.post(mDelayedShrink); + } + } + private static class ChipBitmapContainer { Bitmap bitmap; // information used for positioning the loaded icon |