1a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng/* 2a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Copyright (C) 2012 The Android Open Source Project 3a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * 4a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 5a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * you may not use this file except in compliance with the License. 6a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * You may obtain a copy of the License at 7a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * 8a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 9a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * 10a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Unless required by applicable law or agreed to in writing, software 11a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 12a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * See the License for the specific language governing permissions and 14a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * limitations under the License 15a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 16a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 17a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengpackage com.android.contacts.common.dialog; 18a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 19a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.app.Dialog; 20a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.app.DialogFragment; 21a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.app.FragmentManager; 22a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.app.ProgressDialog; 23a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.content.DialogInterface; 24a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.os.Bundle; 25a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengimport android.os.Handler; 26a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 27a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng/** 28a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Indeterminate progress dialog wrapped up in a DialogFragment to work even when the device 29a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * orientation is changed. Currently, only supports adding a title and/or message to the progress 30a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * dialog. There is an additional parameter of the minimum amount of time to display the progress 31a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * dialog even after a call to dismiss the dialog {@link #dismiss()} or 32a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * {@link #dismissAllowingStateLoss()}. 33a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * <p> 34a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * To create and show the progress dialog, use 35a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * {@link #show(FragmentManager, CharSequence, CharSequence, long)} and retain the reference to the 36a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * IndeterminateProgressDialog instance. 37a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * <p> 38a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * To dismiss the dialog, use {@link #dismiss()} or {@link #dismissAllowingStateLoss()} on the 39a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * instance. The instance returned by 40a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * {@link #show(FragmentManager, CharSequence, CharSequence, long)} is guaranteed to be valid 41a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * after a device orientation change because the {@link #setRetainInstance(boolean)} is called 42a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * internally with true. 43a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 44a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Chengpublic class IndeterminateProgressDialog extends DialogFragment { 45a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private static final String TAG = IndeterminateProgressDialog.class.getSimpleName(); 46a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 47a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private CharSequence mTitle; 48a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private CharSequence mMessage; 49a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private long mMinDisplayTime; 50a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private long mShowTime = 0; 51a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private boolean mActivityReady = false; 52a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private Dialog mOldDialog; 53a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private final Handler mHandler = new Handler(); 54a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private boolean mCalledSuperDismiss = false; 55a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private boolean mAllowStateLoss; 56a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private final Runnable mDismisser = new Runnable() { 57a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 58a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void run() { 59a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng superDismiss(); 60a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 61a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng }; 62a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 63a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 64a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Creates and shows an indeterminate progress dialog. Once the progress dialog is shown, it 65a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * will be shown for at least the minDisplayTime (in milliseconds), so that the progress dialog 66a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * does not flash in and out to quickly. 67a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 68a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public static IndeterminateProgressDialog show(FragmentManager fragmentManager, 69a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng CharSequence title, CharSequence message, long minDisplayTime) { 70a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng IndeterminateProgressDialog dialogFragment = new IndeterminateProgressDialog(); 71a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialogFragment.mTitle = title; 72a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialogFragment.mMessage = message; 73a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialogFragment.mMinDisplayTime = minDisplayTime; 74a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialogFragment.show(fragmentManager, TAG); 75a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialogFragment.mShowTime = System.currentTimeMillis(); 76a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialogFragment.setCancelable(false); 77a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 78a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng return dialogFragment; 79a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 80a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 81a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 82a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void onCreate(Bundle savedInstanceState) { 83a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.onCreate(savedInstanceState); 84a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng setRetainInstance(true); 85a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 86a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 87a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 88a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public Dialog onCreateDialog(Bundle savedInstanceState) { 89a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // Create the progress dialog and set its properties 90a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng final ProgressDialog dialog = new ProgressDialog(getActivity()); 91a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialog.setIndeterminate(true); 92a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialog.setIndeterminateDrawable(null); 93a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialog.setTitle(mTitle); 94a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dialog.setMessage(mMessage); 95a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 96a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng return dialog; 97a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 98a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 99a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 100a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void onStart() { 101a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.onStart(); 102a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mActivityReady = true; 103a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 104a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // Check if superDismiss() had been called before. This can happen if in a long 105a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // running operation, the user hits the home button and closes this fragment's activity. 106a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // Upon returning, we want to dismiss this progress dialog fragment. 107a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng if (mCalledSuperDismiss) { 108a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng superDismiss(); 109a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 110a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 111a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 112a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 113a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void onStop() { 114a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.onStop(); 115a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mActivityReady = false; 116a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 117a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 118a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 119a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * There is a race condition that is not handled properly by the DialogFragment class. 120a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * If we don't check that this onDismiss callback isn't for the old progress dialog from before 121a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * the device orientation change, then this will cause the newly created dialog after the 122a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * orientation change to be dismissed immediately. 123a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 124a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 125a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void onDismiss(DialogInterface dialog) { 126a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng if (mOldDialog != null && mOldDialog == dialog) { 127a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // This is the callback from the old progress dialog that was already dismissed before 128a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // the device orientation change, so just ignore it. 129a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng return; 130a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 131a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.onDismiss(dialog); 132a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 133a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 134a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 135a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Save the old dialog that is about to get destroyed in case this is due to a change 136a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * in device orientation. This will allow us to intercept the callback to 137a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * {@link #onDismiss(DialogInterface)} in case the callback happens after a new progress dialog 138a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * instance was created. 139a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 140a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 141a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void onDestroyView() { 142a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mOldDialog = getDialog(); 143a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.onDestroyView(); 144a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 145a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 146a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 147a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * This tells the progress dialog to dismiss itself after guaranteeing to be shown for the 148a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * specified time in {@link #show(FragmentManager, CharSequence, CharSequence, long)}. 149a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 150a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 151a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void dismiss() { 152a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mAllowStateLoss = false; 153a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dismissWhenReady(); 154a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 155a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 156a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 157a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * This tells the progress dialog to dismiss itself (with state loss) after guaranteeing to be 158a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * shown for the specified time in 159a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * {@link #show(FragmentManager, CharSequence, CharSequence, long)}. 160a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 161a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng @Override 162a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng public void dismissAllowingStateLoss() { 163a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mAllowStateLoss = true; 164a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng dismissWhenReady(); 165a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 166a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 167a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 168a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Tells the progress dialog to dismiss itself after guaranteeing that the dialog had been 169a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * showing for at least the minimum display time as set in 170a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * {@link #show(FragmentManager, CharSequence, CharSequence, long)}. 171a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 172a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private void dismissWhenReady() { 173a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // Compute how long the dialog has been showing 174a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng final long shownTime = System.currentTimeMillis() - mShowTime; 175a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng if (shownTime >= mMinDisplayTime) { 176a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // dismiss immediately 177a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mHandler.post(mDismisser); 178a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } else { 179a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // Need to wait some more, so compute the amount of time to sleep. 180a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng final long sleepTime = mMinDisplayTime - shownTime; 181a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mHandler.postDelayed(mDismisser, sleepTime); 182a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 183a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 184a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng 185a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng /** 186a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng * Actually dismiss the dialog fragment. 187a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng */ 188a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng private void superDismiss() { 189a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng mCalledSuperDismiss = true; 190a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng if (mActivityReady) { 191a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // The fragment is either in onStart or past it, but has not gotten to onStop yet. 192a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // It is safe to dismiss this dialog fragment. 193a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng if (mAllowStateLoss) { 194a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.dismissAllowingStateLoss(); 195a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } else { 196a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng super.dismiss(); 197a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 198a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 199a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // If mActivityReady is false, then this dialog fragment has already passed the onStop 200a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // state. This can happen if the user hit the 'home' button before this dialog fragment was 201a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // dismissed or if there is a configuration change. 202a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // In the event that this dialog fragment is re-attached and reaches onStart (e.g., 203a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // because the user returns to this fragment's activity or the device configuration change 204a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // has re-attached this dialog fragment), because the mCalledSuperDismiss flag was set to 205a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // true, this dialog fragment will be dismissed within onStart. So, there's nothing else 206a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng // that needs to be done. 207a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng } 208a8feb7b88f2f67d8a80762dc54d336f1ea3a22d3Chiao Cheng} 209