am a41a6d0e: am 926c9905: am e444c661: am eaf43ea2: Don\'t show pop-ups and dialogs if we\'re not attached to a valid window.

* commit 'a41a6d0e4a840ce23a9fe12e5b27c477fa7b05b8':
  Don't show pop-ups and dialogs if we're not attached to a valid window.
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 2c4553f..ffd81a2 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -252,6 +252,8 @@
 
     private int mActionBarHeight;
 
+    private boolean mAttachedToWindow;
+
     public RecipientEditTextView(Context context, AttributeSet attrs) {
         super(context, attrs);
         setChipDimensions(context, attrs);
@@ -294,6 +296,16 @@
     }
 
     @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()) {
@@ -1462,6 +1474,9 @@
 
             @Override
             protected void onPostExecute(final ListAdapter result) {
+                if (!mAttachedToWindow) {
+                    return;
+                }
                 int line = getLayout().getLineForOffset(getChipStart(currentChip));
                 int bottom;
                 if (line == getLineCount() -1) {
@@ -2034,6 +2049,9 @@
 
     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,
@@ -2808,6 +2826,9 @@
     }
 
     private void showCopyDialog(final String address) {
+        if (!mAttachedToWindow) {
+            return;
+        }
         mCopyAddress = address;
         mCopyDialog.setTitle(address);
         mCopyDialog.setContentView(R.layout.copy_chip_dialog_layout);