diff options
author | Tony Mantler <nicoya@google.com> | 2013-10-15 14:53:00 -0700 |
---|---|---|
committer | Tony Mantler <nicoya@google.com> | 2013-10-15 14:53:00 -0700 |
commit | eaf43ea2c3b00af22f0aa106fd3dde142f52d471 (patch) | |
tree | 6b0c668032fd4ddeffb6cef4d68ed5f2fbbc155a | |
parent | da5cd8c434eb4a4c5083a0ad0e2808c5ced58ea0 (diff) | |
download | android_frameworks_ex-eaf43ea2c3b00af22f0aa106fd3dde142f52d471.tar.gz android_frameworks_ex-eaf43ea2c3b00af22f0aa106fd3dde142f52d471.tar.bz2 android_frameworks_ex-eaf43ea2c3b00af22f0aa106fd3dde142f52d471.zip |
Don't show pop-ups and dialogs if we're not attached to a valid window.
b/11229200
Change-Id: Ic44da79e441017ac4ccdb4a254c13965da0cc2f9
-rw-r--r-- | chips/src/com/android/ex/chips/RecipientEditTextView.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index fefd273..5022acf 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -252,6 +252,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements private int mActionBarHeight; + private boolean mAttachedToWindow; + public RecipientEditTextView(Context context, AttributeSet attrs) { super(context, attrs); setChipDimensions(context, attrs); @@ -294,6 +296,16 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements } @Override + protected void onDetachedFromWindow() { + mAttachedToWindow = false; + } + + @Override + protected void onAttachedToWindow() { + mAttachedToWindow = true; + } + + @Override public boolean onEditorAction(TextView view, int action, KeyEvent keyEvent) { if (action == EditorInfo.IME_ACTION_DONE) { if (commitDefault()) { @@ -1463,6 +1475,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements @Override protected void onPostExecute(final ListAdapter result) { + if (!mAttachedToWindow) { + return; + } int line = getLayout().getLineForOffset(getChipStart(currentChip)); int bottom; if (line == getLineCount() -1) { @@ -2036,6 +2051,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements private void showAddress(final DrawableRecipientChip currentChip, final ListPopupWindow popup, int width) { + if (!mAttachedToWindow) { + return; + } int line = getLayout().getLineForOffset(getChipStart(currentChip)); int bottom = calculateOffsetFromBottom(line); // Align the alternates popup with the left side of the View, @@ -2816,6 +2834,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements } private void showCopyDialog(final String address) { + if (!mAttachedToWindow) { + return; + } mCopyAddress = address; mCopyDialog.setTitle(address); mCopyDialog.setContentView(R.layout.copy_chip_dialog_layout); |