12dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackbornpackage android.app; 22dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn 3d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mountimport android.util.Pair; 4d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mountimport android.view.View; 5d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount 62dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn/** 72dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn * API for performing a set of Fragment operations. 8b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * 9b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <div class="special reference"> 10b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <h3>Developer Guides</h3> 11b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <p>For more information about using fragments, read the 12b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * <a href="{@docRoot}guide/topics/fundamentals/fragments.html">Fragments</a> developer guide.</p> 13b54e7a3d9f60ac605f404f9eb3c5e92ca51bbd23Joe Fernandez * </div> 142dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn */ 15ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackbornpublic abstract class FragmentTransaction { 165ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 175ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Calls {@link #add(int, Fragment, String)} with a 0 containerViewId. 185ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 19ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction add(Fragment fragment, String tag); 205ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 215ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 225ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Calls {@link #add(int, Fragment, String)} with a null tag. 235ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 24ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction add(int containerViewId, Fragment fragment); 255ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 265ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 275ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Add a fragment to the activity state. This fragment may optionally 285ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * also have its view (if {@link Fragment#onCreateView Fragment.onCreateView} 295ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * returns non-null) into a container view of the activity. 305ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 315ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param containerViewId Optional identifier of the container this fragment is 325ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * to be placed in. If 0, it will not be placed in a container. 335ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be added. This fragment must not already 345ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * be added to the activity. 355ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param tag Optional tag name for the fragment, to later retrieve the 36247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * fragment with {@link FragmentManager#findFragmentByTag(String) 37247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * FragmentManager.findFragmentByTag(String)}. 385ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 395ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 405ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 41ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag); 425ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 435ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 445ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Calls {@link #replace(int, Fragment, String)} with a null tag. 455ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 46ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction replace(int containerViewId, Fragment fragment); 475ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 485ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 495ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Replace an existing fragment that was added to a container. This is 505ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * essentially the same as calling {@link #remove(Fragment)} for all 515ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * currently added fragments that were added with the same containerViewId 525ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * and then {@link #add(int, Fragment, String)} with the same arguments 535ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * given here. 545ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 555ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param containerViewId Identifier of the container whose fragment(s) are 565ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * to be replaced. 575ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The new fragment to place in the container. 585ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param tag Optional tag name for the fragment, to later retrieve the 59247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * fragment with {@link FragmentManager#findFragmentByTag(String) 60247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn * FragmentManager.findFragmentByTag(String)}. 615ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 625ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 635ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 64ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction replace(int containerViewId, Fragment fragment, String tag); 655ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 665ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 675ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Remove an existing fragment. If it was added to a container, its view 685ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * is also removed from that container. 695ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 705ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be removed. 715ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 725ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 735ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 74ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction remove(Fragment fragment); 75f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 76f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** 775ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Hides an existing fragment. This is only relevant for fragments whose 785ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * views have been added to a container, as this will cause the view to 795ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * be hidden. 805ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 815ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be hidden. 825ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 835ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 845ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 85ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction hide(Fragment fragment); 865ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 875ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 88baa1553c8d125a55956d1a8b2966ccd100673179Jim Shuma * Shows a previously hidden fragment. This is only relevant for fragments whose 895ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * views have been added to a container, as this will cause the view to 905ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * be shown. 915ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 925ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @param fragment The fragment to be shown. 935ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * 945ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * @return Returns the same FragmentTransaction instance. 955ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn */ 96ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction show(Fragment fragment); 972b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell 982b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell /** 9947c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * Detach the given fragment from the UI. This is the same state as 10047c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * when it is put on the back stack: the fragment is removed from 10147c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * the UI, however its state is still being actively managed by the 10247c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * fragment manager. When going into this state its view hierarchy 10347c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * is destroyed. 10447c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 10547c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @param fragment The fragment to be detached. 10647c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 10747c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @return Returns the same FragmentTransaction instance. 10847c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn */ 10947c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn public abstract FragmentTransaction detach(Fragment fragment); 11047c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn 11147c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn /** 112355297c6df91b2e0fd55f8f400f378b3af19fb4cPaul Quei * Re-attach a fragment after it had previously been detached from 11347c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * the UI with {@link #detach(Fragment)}. This 11447c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * causes its view hierarchy to be re-created, attached to the UI, 11547c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * and displayed. 11647c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 11747c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @param fragment The fragment to be attached. 11847c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * 11947c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn * @return Returns the same FragmentTransaction instance. 12047c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn */ 12147c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn public abstract FragmentTransaction attach(Fragment fragment); 12247c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn 12347c4156567ce5abf8a6fca7fefe6ae9a20fb5117Dianne Hackborn /** 1242b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell * @return <code>true</code> if this transaction contains no operations, 125c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * <code>false</code> otherwise. 1262b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell */ 127ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract boolean isEmpty(); 1285ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn 1295ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn /** 1305ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn * Bit mask that is set for all enter transitions. 131f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn */ 132ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_ENTER_MASK = 0x1000; 133f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 134f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** 135f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn * Bit mask that is set for all exit transitions. 136f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn */ 137ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_EXIT_MASK = 0x2000; 138f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 139f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** Not set up for a transition. */ 140ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_UNSET = -1; 141f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn /** No animation for transition. */ 142ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_NONE = 0; 1439ff82bf2b33513052500473d0d6d025a80dcecbfChet Haase /** Fragment is being added onto the stack */ 144ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_FRAGMENT_OPEN = 1 | TRANSIT_ENTER_MASK; 1459ff82bf2b33513052500473d0d6d025a80dcecbfChet Haase /** Fragment is being removed from the stack */ 146ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public static final int TRANSIT_FRAGMENT_CLOSE = 2 | TRANSIT_EXIT_MASK; 147327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn /** Fragment should simply fade in or out; that is, no strong navigation associated 148327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn * with it except that it is appearing or disappearing for some reason. */ 149327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn public static final int TRANSIT_FRAGMENT_FADE = 3 | TRANSIT_ENTER_MASK; 150811ed1065f39469cf2cf6adba22cab397ed88d5eChet Haase 151c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 152c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set specific animation resources to run for the fragments that are 153bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * entering and exiting in this transaction. These animations will not be 154bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * played when popping the back stack. 155c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 156ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setCustomAnimations(int enter, int exit); 157bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase 158bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase /** 159bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * Set specific animation resources to run for the fragments that are 160bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * entering and exiting in this transaction. The <code>popEnter</code> 161bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * and <code>popExit</code> animations will be played for enter/exit 162bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase * operations specifically when popping the back stack. 163bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase */ 164bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase public abstract FragmentTransaction setCustomAnimations(int enter, int exit, 165bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase int popEnter, int popExit); 166bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase 167c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 168c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Select a standard transition animation for this transaction. May be 169c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN}, 170c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * or {@link #TRANSIT_FRAGMENT_CLOSE} 171c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 172ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setTransition(int transit); 173c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 174c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 175c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount * TODO: remove from API 176c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount * @hide 177c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount */ 178c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount public FragmentTransaction setCustomTransition(int sceneRootId, int transitionId) { 179c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount return this; 180c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount } 181d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount 182d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount /** 183c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount * Used with to map a View from a removed or hidden Fragment to a View from a shown 184c03da0e7a9ef721709d51cf8a2d539a5bd8a320eGeorge Mount * or added Fragment. 185d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount * @param sharedElement A View in a disappearing Fragment to match with a View in an 186d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount * appearing Fragment. 1870a2ae002e60f7ea9b6bea282086b5eb0ae3c6e51George Mount * @param name The transitionName for a View in an appearing Fragment to match to the shared 188d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount * element. 189d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount */ 190448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount public abstract FragmentTransaction addSharedElement(View sharedElement, String name); 191448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount 192448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount /** 193448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount * TODO: remove from API 194448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount * @hide 195448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount */ 196d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount public abstract FragmentTransaction setSharedElement(View sharedElement, String name); 197d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount 198d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount /** 199448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount * TODO: remove from API 200448bace8612b0f9a41844339ca5db1b8eac1ac5cGeorge Mount * @hide 201d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount */ 202d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount public abstract FragmentTransaction setSharedElements(Pair<View, String>... sharedElements); 203d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount 204d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount /** 205c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set a custom style resource that will be used for resolving transit 206c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * animations. 207c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 208ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setTransitionStyle(int styleRes); 209f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn 210c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 211c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Add this transaction to the back stack. This means that the transaction 212c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * will be remembered after it is committed, and will reverse its operation 213c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * when later popped off the stack. 214c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * 215c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * @param name An optional name for this back stack state, or null. 216c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 217ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction addToBackStack(String name); 218dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn 219dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn /** 2200c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Returns true if this FragmentTransaction is allowed to be added to the back 2210c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * stack. If this method would return false, {@link #addToBackStack(String)} 2220c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * will throw {@link IllegalStateException}. 2230c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * 2240c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * @return True if {@link #addToBackStack(String)} is permitted on this transaction. 2250c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 226ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract boolean isAddToBackStackAllowed(); 2270c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 2280c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 2290c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * Disallow calls to {@link #addToBackStack(String)}. Any future calls to 2300c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * addToBackStack will throw {@link IllegalStateException}. If addToBackStack 2310c24a5514c1ff143a223720a090b19a86a75945fAdam Powell * has already been called, this method will throw IllegalStateException. 2320c24a5514c1ff143a223720a090b19a86a75945fAdam Powell */ 233ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction disallowAddToBackStack(); 2340c24a5514c1ff143a223720a090b19a86a75945fAdam Powell 2350c24a5514c1ff143a223720a090b19a86a75945fAdam Powell /** 236c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set the full title to show as a bread crumb when this transaction 237c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * is on the back stack, as used by {@link FragmentBreadCrumbs}. 238c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * 239c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * @param res A string resource containing the title. 240c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 241ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbTitle(int res); 242c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 243c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 244c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Like {@link #setBreadCrumbTitle(int)} but taking a raw string; this 245c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * method is <em>not</em> recommended, as the string can not be changed 246c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * later if the locale changes. 247c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 248ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbTitle(CharSequence text); 249c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 250c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 251c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Set the short title to show as a bread crumb when this transaction 252c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * is on the back stack, as used by {@link FragmentBreadCrumbs}. 253c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * 254c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * @param res A string resource containing the title. 255c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 256ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbShortTitle(int res); 257c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 258c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 259c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * Like {@link #setBreadCrumbShortTitle(int)} but taking a raw string; this 260c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * method is <em>not</em> recommended, as the string can not be changed 261c6669ca63299219d815464129dac051ab2404286Dianne Hackborn * later if the locale changes. 262c6669ca63299219d815464129dac051ab2404286Dianne Hackborn */ 263ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract FragmentTransaction setBreadCrumbShortTitle(CharSequence text); 264c6669ca63299219d815464129dac051ab2404286Dianne Hackborn 265c6669ca63299219d815464129dac051ab2404286Dianne Hackborn /** 266ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * Schedules a commit of this transaction. The commit does 267dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * not happen immediately; it will be scheduled as work on the main thread 268dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * to be done the next time that thread is ready. 269dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * 270ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * <p class="note">A transaction can only be committed with this method 271ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * prior to its containing activity saving its state. If the commit is 272ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * attempted after that point, an exception will be thrown. This is 273ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * because the state after the commit can be lost if the activity needs to 274ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * be restored from its state. See {@link #commitAllowingStateLoss()} for 275ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * situations where it may be okay to lose the commit.</p> 276ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * 277dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * @return Returns the identifier of this transaction's back stack entry, 278dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * if {@link #addToBackStack(String)} had been called. Otherwise, returns 279dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn * a negative number. 280dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn */ 281ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract int commit(); 282ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn 283ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn /** 284ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * Like {@link #commit} but allows the commit to be executed after an 285ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * activity's state is saved. This is dangerous because the commit can 286ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * be lost if the activity needs to later be restored from its state, so 287ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * this should only be used for cases where it is okay for the UI state 288ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn * to change unexpectedly on the user. 289ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn */ 290ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn public abstract int commitAllowingStateLoss(); 2912dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn} 292