1cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/* 2cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Copyright (C) 2011 The Android Open Source Project 3cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 4cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 5cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * you may not use this file except in compliance with the License. 6cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * You may obtain a copy of the License at 7cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 8cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 9cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 10cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Unless required by applicable law or agreed to in writing, software 11cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 12cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * See the License for the specific language governing permissions and 14cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * limitations under the License. 15cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 16cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 17cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpackage android.support.v4.app; 18cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 19ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powellimport android.app.Activity; 20cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.app.Dialog; 21cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.content.Context; 22cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.content.DialogInterface; 23cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.os.Bundle; 24cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.view.LayoutInflater; 25cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.view.View; 26cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.view.ViewGroup; 27cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.view.Window; 28cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornimport android.view.WindowManager; 29cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 30cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/** 31cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Static library support version of the framework's {@link android.app.DialogFragment}. 32cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Used to write apps that run on platforms prior to Android 3.0. When running 33cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * on Android 3.0 or above, this implementation is still used; it does not try 34cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * to switch to the framework's implementation. See the framework SDK 35cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * documentation for a class overview. 36cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 37cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpublic class DialogFragment extends Fragment 38cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener { 39cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 40cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 41cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Style for {@link #setStyle(int, int)}: a basic, 42cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * normal dialog. 43cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 44cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public static final int STYLE_NORMAL = 0; 45cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 46cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 47cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Style for {@link #setStyle(int, int)}: don't include 48cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * a title area. 49cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 50cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public static final int STYLE_NO_TITLE = 1; 51cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 52cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 53cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Style for {@link #setStyle(int, int)}: don't draw 54cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * any frame at all; the view hierarchy returned by {@link #onCreateView} 55cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * is entirely responsible for drawing the dialog. 56cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 57cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public static final int STYLE_NO_FRAME = 2; 58cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 59cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 60cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Style for {@link #setStyle(int, int)}: like 61cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link #STYLE_NO_FRAME}, but also disables all input to the dialog. 62cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * The user can not touch it, and its window will not receive input focus. 63cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 64cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public static final int STYLE_NO_INPUT = 3; 65cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 66cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn private static final String SAVED_DIALOG_STATE_TAG = "android:savedDialogState"; 67cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn private static final String SAVED_STYLE = "android:style"; 68cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn private static final String SAVED_THEME = "android:theme"; 69cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn private static final String SAVED_CANCELABLE = "android:cancelable"; 70cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn private static final String SAVED_SHOWS_DIALOG = "android:showsDialog"; 71cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn private static final String SAVED_BACK_STACK_ID = "android:backStackId"; 72cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 73cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn int mStyle = STYLE_NORMAL; 74cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn int mTheme = 0; 75cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn boolean mCancelable = true; 76cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn boolean mShowsDialog = true; 77cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn int mBackStackId = -1; 78cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 79cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn Dialog mDialog; 80ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell boolean mViewDestroyed; 81ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell boolean mDismissed; 82ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell boolean mShownByMe; 83cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 84cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public DialogFragment() { 85cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 86cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 87cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 88cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Call to customize the basic appearance and behavior of the 89cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * fragment's dialog. This can be used for some common dialog behaviors, 90cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * taking care of selecting flags, theme, and other options for you. The 91cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * same effect can be achieve by manually setting Dialog and Window 92cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * attributes yourself. Calling this after the fragment's Dialog is 93cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * created will have no effect. 94cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 95cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param style Selects a standard style: may be {@link #STYLE_NORMAL}, 96cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link #STYLE_NO_TITLE}, {@link #STYLE_NO_FRAME}, or 97cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link #STYLE_NO_INPUT}. 98cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param theme Optional custom theme. If 0, an appropriate theme (based 99cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * on the style) will be selected for you. 100cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 101cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void setStyle(int style, int theme) { 102cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mStyle = style; 103cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mStyle == STYLE_NO_FRAME || mStyle == STYLE_NO_INPUT) { 104cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mTheme = android.R.style.Theme_Panel; 105cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 106cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (theme != 0) { 107cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mTheme = theme; 108cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 109cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 110cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 111cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 112cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Display the dialog, adding the fragment to the given FragmentManager. This 113cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * is a convenience for explicitly creating a transaction, adding the 114cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * fragment to it with the given tag, and committing it. This does 115cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * <em>not</em> add the transaction to the back stack. When the fragment 116cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * is dismissed, a new transaction will be executed to remove it from 117cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * the activity. 118cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param manager The FragmentManager this fragment will be added to. 119cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param tag The tag for this fragment, as per 120cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link FragmentTransaction#add(Fragment, String) FragmentTransaction.add}. 121cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 122cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void show(FragmentManager manager, String tag) { 123ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mDismissed = false; 124ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mShownByMe = true; 125cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn FragmentTransaction ft = manager.beginTransaction(); 126cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn ft.add(this, tag); 127cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn ft.commit(); 128cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 129cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 130cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 131cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Display the dialog, adding the fragment using an existing transaction 132cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * and then committing the transaction. 133cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param transaction An existing transaction in which to add the fragment. 134cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param tag The tag for this fragment, as per 135cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link FragmentTransaction#add(Fragment, String) FragmentTransaction.add}. 136cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @return Returns the identifier of the committed transaction, as per 137cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link FragmentTransaction#commit() FragmentTransaction.commit()}. 138cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 139cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public int show(FragmentTransaction transaction, String tag) { 140ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mDismissed = false; 141ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mShownByMe = true; 142cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn transaction.add(this, tag); 143ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mViewDestroyed = false; 144cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mBackStackId = transaction.commit(); 145cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return mBackStackId; 146cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 147cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 148cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 149cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Dismiss the fragment and its dialog. If the fragment was added to the 150cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * back stack, all back stack state up to and including this entry will 151cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * be popped. Otherwise, a new transaction will be committed to remove 152cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * the fragment. 153cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 154cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void dismiss() { 155cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn dismissInternal(false); 156cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 157cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 158ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell /** 159ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell * Version of {@link #dismiss()} that uses 160ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell * {@link FragmentTransaction#commitAllowingStateLoss() 161ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell * FragmentTransaction.commitAllowingStateLoss()}. See linked 162ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell * documentation for further details. 163ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell */ 164ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell public void dismissAllowingStateLoss() { 165ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell dismissInternal(true); 166ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 167ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell 168cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn void dismissInternal(boolean allowStateLoss) { 169ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell if (mDismissed) { 170ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell return; 171ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 172ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mDismissed = true; 173ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mShownByMe = false; 174cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mDialog != null) { 175cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.dismiss(); 176cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog = null; 177cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 178ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mViewDestroyed = true; 179cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mBackStackId >= 0) { 180cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn getFragmentManager().popBackStack(mBackStackId, 181cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn FragmentManager.POP_BACK_STACK_INCLUSIVE); 182cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mBackStackId = -1; 183cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } else { 184cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn FragmentTransaction ft = getFragmentManager().beginTransaction(); 185cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn ft.remove(this); 186cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (allowStateLoss) { 187cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn ft.commitAllowingStateLoss(); 188cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } else { 189cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn ft.commit(); 190cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 191cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 192cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 193cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 194cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public Dialog getDialog() { 195cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return mDialog; 196cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 197cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 198cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public int getTheme() { 199cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return mTheme; 200cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 201cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 202cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 203cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Control whether the shown Dialog is cancelable. Use this instead of 204cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * directly calling {@link Dialog#setCancelable(boolean) 205cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Dialog.setCancelable(boolean)}, because DialogFragment needs to change 206cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * its behavior based on this. 207cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 208cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param cancelable If true, the dialog is cancelable. The default 209cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * is true. 210cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 211cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void setCancelable(boolean cancelable) { 212cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mCancelable = cancelable; 213cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mDialog != null) mDialog.setCancelable(cancelable); 214cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 215cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 216cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 217cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Return the current value of {@link #setCancelable(boolean)}. 218cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 219cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public boolean isCancelable() { 220cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return mCancelable; 221cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 222cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 223cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 224cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Controls whether this fragment should be shown in a dialog. If not 225cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * set, no Dialog will be created in {@link #onActivityCreated(Bundle)}, 226cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * and the fragment's view hierarchy will thus not be added to it. This 227cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * allows you to instead use it as a normal fragment (embedded inside of 228cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * its activity). 229cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 230cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * <p>This is normally set for you based on whether the fragment is 231cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * associated with a container view ID passed to 232cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link FragmentTransaction#add(int, Fragment) FragmentTransaction.add(int, Fragment)}. 233cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * If the fragment was added with a container, setShowsDialog will be 234cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * initialized to false; otherwise, it will be true. 235cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 236cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param showsDialog If true, the fragment will be displayed in a Dialog. 237cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * If false, no Dialog will be created and the fragment's view hierarchly 238cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * left undisturbed. 239cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 240cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void setShowsDialog(boolean showsDialog) { 241cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mShowsDialog = showsDialog; 242cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 243cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 244cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 245cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Return the current value of {@link #setShowsDialog(boolean)}. 246cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 247cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public boolean getShowsDialog() { 248cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return mShowsDialog; 249cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 250cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 251cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 252ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell public void onAttach(Activity activity) { 253ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell super.onAttach(activity); 254ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell if (!mShownByMe) { 255ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell // If not explicitly shown through our API, take this as an 256ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell // indication that the dialog is no longer dismissed. 257ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mDismissed = false; 258ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 259ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 260ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell 261ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell @Override 262ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell public void onDetach() { 263ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell super.onDetach(); 264ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell if (!mShownByMe && !mDismissed) { 265ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell // The fragment was not shown by a direct call here, it is not 266ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell // dismissed, and now it is being detached... well, okay, thou 267ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell // art now dismissed. Have fun. 268ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mDismissed = true; 269ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 270ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 271ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell 272ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell @Override 273cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onCreate(Bundle savedInstanceState) { 274cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn super.onCreate(savedInstanceState); 275cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 276cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mShowsDialog = mContainerId == 0; 277cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 278cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (savedInstanceState != null) { 279cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mStyle = savedInstanceState.getInt(SAVED_STYLE, STYLE_NORMAL); 280cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mTheme = savedInstanceState.getInt(SAVED_THEME, 0); 281cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mCancelable = savedInstanceState.getBoolean(SAVED_CANCELABLE, true); 282cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mShowsDialog = savedInstanceState.getBoolean(SAVED_SHOWS_DIALOG, mShowsDialog); 283cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mBackStackId = savedInstanceState.getInt(SAVED_BACK_STACK_ID, -1); 284cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 285cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 286cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 287cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 288cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** @hide */ 289cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 290cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public LayoutInflater getLayoutInflater(Bundle savedInstanceState) { 291cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (!mShowsDialog) { 292cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return super.getLayoutInflater(savedInstanceState); 293cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 294cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 295cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog = onCreateDialog(savedInstanceState); 296cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn switch (mStyle) { 297cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn case STYLE_NO_INPUT: 298cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.getWindow().addFlags( 299cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | 300cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); 301cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // fall through... 302cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn case STYLE_NO_FRAME: 303cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn case STYLE_NO_TITLE: 304cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 305cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 306ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell if (mDialog != null) { 307ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell return (LayoutInflater) mDialog.getContext().getSystemService( 308ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell Context.LAYOUT_INFLATER_SERVICE); 309ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell } 310ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell return (LayoutInflater) mActivity.getSystemService( 311cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn Context.LAYOUT_INFLATER_SERVICE); 312cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 313cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 314cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 315cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Override to build your own custom Dialog container. This is typically 316cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * used to show an AlertDialog instead of a generic Dialog; when doing so, 317cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)} does not need 318cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * to be implemented since the AlertDialog takes care of its own content. 319cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 320cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * <p>This method will be called after {@link #onCreate(Bundle)} and 321cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * before {@link #onCreateView(LayoutInflater, ViewGroup, Bundle)}. The 322cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * default implementation simply instantiates and returns a {@link Dialog} 323cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * class. 324cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 325cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * <p><em>Note: DialogFragment own the {@link Dialog#setOnCancelListener 326cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Dialog.setOnCancelListener} and {@link Dialog#setOnDismissListener 327cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Dialog.setOnDismissListener} callbacks. You must not set them yourself.</em> 328cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * To find out about these events, override {@link #onCancel(DialogInterface)} 329cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * and {@link #onDismiss(DialogInterface)}.</p> 330cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 331cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @param savedInstanceState The last saved instance state of the Fragment, 332cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * or null if this is a freshly created Fragment. 333cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 334cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * @return Return a new Dialog instance to be displayed by the Fragment. 335cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 336cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public Dialog onCreateDialog(Bundle savedInstanceState) { 337cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return new Dialog(getActivity(), getTheme()); 338cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 339cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 340cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onCancel(DialogInterface dialog) { 341cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 342cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 343cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onDismiss(DialogInterface dialog) { 344ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell if (!mViewDestroyed) { 345cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // Note: we need to use allowStateLoss, because the dialog 346cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // dispatches this asynchronously so we can receive the call 347cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // after the activity is paused. Worst case, when the user comes 348cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // back to the activity they see the dialog again. 349cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn dismissInternal(true); 350cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 351cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 352cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 353cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 354cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onActivityCreated(Bundle savedInstanceState) { 355cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn super.onActivityCreated(savedInstanceState); 356cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 357cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (!mShowsDialog) { 358cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn return; 359cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 360cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 361cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn View view = getView(); 362cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (view != null) { 363cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (view.getParent() != null) { 364cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn throw new IllegalStateException("DialogFragment can not be attached to a container view"); 365cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 366cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.setContentView(view); 367cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 368cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.setOwnerActivity(getActivity()); 369cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.setCancelable(mCancelable); 370cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.setOnCancelListener(this); 371cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.setOnDismissListener(this); 372cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (savedInstanceState != null) { 373cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn Bundle dialogState = savedInstanceState.getBundle(SAVED_DIALOG_STATE_TAG); 374cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (dialogState != null) { 375cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.onRestoreInstanceState(dialogState); 376cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 377cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 378cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 379cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 380cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 381cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onStart() { 382cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn super.onStart(); 383cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mDialog != null) { 384ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mViewDestroyed = false; 385cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.show(); 386cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 387cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 388cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 389cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 390cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onSaveInstanceState(Bundle outState) { 391cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn super.onSaveInstanceState(outState); 392cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mDialog != null) { 393cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn Bundle dialogState = mDialog.onSaveInstanceState(); 394cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (dialogState != null) { 395cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn outState.putBundle(SAVED_DIALOG_STATE_TAG, dialogState); 396cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 397cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 398cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mStyle != STYLE_NORMAL) { 399cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn outState.putInt(SAVED_STYLE, mStyle); 400cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 401cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mTheme != 0) { 402cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn outState.putInt(SAVED_THEME, mTheme); 403cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 404cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (!mCancelable) { 405cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn outState.putBoolean(SAVED_CANCELABLE, mCancelable); 406cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 407cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (!mShowsDialog) { 408cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn outState.putBoolean(SAVED_SHOWS_DIALOG, mShowsDialog); 409cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 410cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mBackStackId != -1) { 411cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn outState.putInt(SAVED_BACK_STACK_ID, mBackStackId); 412cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 413cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 414cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 415cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 416cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onStop() { 417cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn super.onStop(); 418cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mDialog != null) { 419cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.hide(); 420cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 421cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 422cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 423cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn /** 424cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Remove dialog. 425cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 426cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn @Override 427cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public void onDestroyView() { 428cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn super.onDestroyView(); 429cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (mDialog != null) { 430cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // Set removed here because this dismissal is just to hide 431cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // the dialog -- we don't want this to cause the fragment to 432cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn // actually be removed. 433ee8bdae679a94a9be65204b96d9352c4afb58a93Adam Powell mViewDestroyed = true; 434cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog.dismiss(); 435cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn mDialog = null; 436cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 437cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 438cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn} 439