Merge "Close popup window before fragment is destroyed."
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index bb63b2e..916ae70 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -85,6 +85,7 @@
import com.android.contacts.common.util.AccountsListAdapter.AccountListFilter;
import com.android.contacts.util.ContactPhotoUtils;
import com.android.contacts.util.HelpUtils;
+import com.android.contacts.util.UiClosables;
import com.google.common.collect.ImmutableList;
import java.io.File;
@@ -290,7 +291,7 @@
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final AggregationSuggestionView suggestionView = (AggregationSuggestionView) view;
suggestionView.handleItemClickEvent();
- mAggregationSuggestionPopup.dismiss();
+ UiClosables.closeQuietly(mAggregationSuggestionPopup);
mAggregationSuggestionPopup = null;
}
};
@@ -330,6 +331,9 @@
@Override
public void onStop() {
super.onStop();
+
+ UiClosables.closeQuietly(mAggregationSuggestionPopup);
+
// If anything was left unsaved, save it now but keep the editor open.
if (!getActivity().isChangingConfigurations() && mStatus == Status.EDITING) {
save(SaveMode.RELOAD);
@@ -915,7 +919,7 @@
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
- popup.dismiss();
+ UiClosables.closeQuietly(popup);
AccountWithDataSet newAccount = adapter.getItem(position);
if (!newAccount.equals(currentAccount)) {
rebindEditorsForNewContact(currentState, currentAccount, newAccount);
@@ -1435,9 +1439,7 @@
return;
}
- if (mAggregationSuggestionPopup != null && mAggregationSuggestionPopup.isShowing()) {
- mAggregationSuggestionPopup.dismiss();
- }
+ UiClosables.closeQuietly(mAggregationSuggestionPopup);
if (mAggregationSuggestionEngine.getSuggestedContactCount() == 0) {
return;
diff --git a/src/com/android/contacts/util/UiClosables.java b/src/com/android/contacts/util/UiClosables.java
new file mode 100644
index 0000000..66ab6cd
--- /dev/null
+++ b/src/com/android/contacts/util/UiClosables.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.contacts.util;
+
+import android.widget.ListPopupWindow;
+
+/**
+ * Methods for closing various objects
+ */
+public class UiClosables {
+
+ /**
+ * Close a {@link ListPopupWindow}.
+ *
+ * @param popup The popup window to close.
+ */
+ public static void closeQuietly(ListPopupWindow popup) {
+ if (popup != null && popup.isShowing()) {
+ popup.dismiss();
+ }
+ }
+}