summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2014-12-12 14:24:17 -0800
committerScott Kennedy <skennedy@google.com>2014-12-12 14:24:17 -0800
commit654c967e9560ccb40a465a78e3296980f530ed55 (patch)
treecde962ce3a1be5a5b7115d9bc658bc49165077dc
parentcb11fced23f3a08ad68ea61719d7f0fdeb0f7279 (diff)
downloadandroid_frameworks_opt_chips-654c967e9560ccb40a465a78e3296980f530ed55.tar.gz
android_frameworks_opt_chips-654c967e9560ccb40a465a78e3296980f530ed55.tar.bz2
android_frameworks_opt_chips-654c967e9560ccb40a465a78e3296980f530ed55.zip
Prevent infinite posting of Runnables
If shrink() is called when the View's width is 0, and it's GONE, its width will never be greater than 0, so it just keeps posting the Runnable forever. Bug: 18613863 Change-Id: I1b2fa598826b6fa47996597c835533de3a4af220
-rw-r--r--src/com/android/ex/chips/RecipientEditTextView.java30
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 6541180..bae6058 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;
@@ -594,13 +595,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
@@ -3202,6 +3210,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