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
19cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/**
20cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Static library support version of the framework's {@link android.app.FragmentTransaction}.
21cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Used to write apps that run on platforms prior to Android 3.0.  When running
22cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * on Android 3.0 or above, this implementation is still used; it does not try
23cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * to switch to the framework's implementation.  See the framework SDK
24cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * documentation for a class overview.
25cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */
26cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpublic abstract class FragmentTransaction {
27cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
28cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Calls {@link #add(int, Fragment, String)} with a 0 containerViewId.
29cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
30cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction add(Fragment fragment, String tag);
31cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
32cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
33cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Calls {@link #add(int, Fragment, String)} with a null tag.
34cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
35cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction add(int containerViewId, Fragment fragment);
36cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
37cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
38cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Add a fragment to the activity state.  This fragment may optionally
39cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * also have its view (if {@link Fragment#onCreateView Fragment.onCreateView}
40cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * returns non-null) into a container view of the activity.
41cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
42cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param containerViewId Optional identifier of the container this fragment is
43cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * to be placed in.  If 0, it will not be placed in a container.
44cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param fragment The fragment to be added.  This fragment must not already
45cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * be added to the activity.
46cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param tag Optional tag name for the fragment, to later retrieve the
47cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * fragment with {@link FragmentManager#findFragmentByTag(String)
48cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * FragmentManager.findFragmentByTag(String)}.
49cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
50cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
51cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
52cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag);
53cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
54cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
55cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Calls {@link #replace(int, Fragment, String)} with a null tag.
56cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
57cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction replace(int containerViewId, Fragment fragment);
58cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
59cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
60cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Replace an existing fragment that was added to a container.  This is
61cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * essentially the same as calling {@link #remove(Fragment)} for all
62cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * currently added fragments that were added with the same containerViewId
63cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * and then {@link #add(int, Fragment, String)} with the same arguments
64cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * given here.
65cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
66cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param containerViewId Identifier of the container whose fragment(s) are
67cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * to be replaced.
68cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param fragment The new fragment to place in the container.
69cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param tag Optional tag name for the fragment, to later retrieve the
70cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * fragment with {@link FragmentManager#findFragmentByTag(String)
71cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * FragmentManager.findFragmentByTag(String)}.
72cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
73cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
74cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
75cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction replace(int containerViewId, Fragment fragment, String tag);
76cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
77cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
78cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Remove an existing fragment.  If it was added to a container, its view
79cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * is also removed from that container.
80cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
81cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param fragment The fragment to be removed.
82cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
83cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
84cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
85cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction remove(Fragment fragment);
86cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
87cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
88cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Hides an existing fragment.  This is only relevant for fragments whose
89cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * views have been added to a container, as this will cause the view to
90cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * be hidden.
91cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
92cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param fragment The fragment to be hidden.
93cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
94cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
95cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
96cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction hide(Fragment fragment);
97cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
98cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
99cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Shows a previously hidden fragment.  This is only relevant for fragments whose
100cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * views have been added to a container, as this will cause the view to
101cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * be shown.
102cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
103cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param fragment The fragment to be shown.
104cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
105cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
106cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
107cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction show(Fragment fragment);
108cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
109cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
110eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * Detach the given fragment from the UI.  This is the same state as
111eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * when it is put on the back stack: the fragment is removed from
112eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * the UI, however its state is still being actively managed by the
113eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * fragment manager.  When going into this state its view hierarchy
114eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * is destroyed.
115eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     *
116eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * @param fragment The fragment to be detached.
117eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     *
118eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
119eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     */
120eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn    public abstract FragmentTransaction detach(Fragment fragment);
121eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn
122eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn    /**
123eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * Re-attach a fragment after it had previously been deatched from
124eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * the UI with {@link #detach(Fragment)}.  This
125eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * causes its view hierarchy to be re-created, attached to the UI,
126eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * and displayed.
127eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     *
128eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * @param fragment The fragment to be attached.
129eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     *
130eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
131eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn     */
132eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn    public abstract FragmentTransaction attach(Fragment fragment);
133eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn
134eedc67283a5a49dce86c625e54596dfdea9465a7Dianne Hackborn    /**
135cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return <code>true</code> if this transaction contains no operations,
136cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * <code>false</code> otherwise.
137cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
138cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract boolean isEmpty();
139cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
140cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
141cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Bit mask that is set for all enter transitions.
142cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
143cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_ENTER_MASK = 0x1000;
144cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
145cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
146cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Bit mask that is set for all exit transitions.
147cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
148cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_EXIT_MASK = 0x2000;
149cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
150cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /** Not set up for a transition. */
151cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_UNSET = -1;
152cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /** No animation for transition. */
153cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_NONE = 0;
154cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /** Fragment is being added onto the stack */
155cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_FRAGMENT_OPEN = 1 | TRANSIT_ENTER_MASK;
156cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /** Fragment is being removed from the stack */
157cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_FRAGMENT_CLOSE = 2 | TRANSIT_EXIT_MASK;
158cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /** Fragment should simply fade in or out; that is, no strong navigation associated
159cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * with it except that it is appearing or disappearing for some reason. */
160cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public static final int TRANSIT_FRAGMENT_FADE = 3 | TRANSIT_ENTER_MASK;
161cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
162cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
163cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Set specific animation resources to run for the fragments that are
164df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     * entering and exiting in this transaction. These animations will not be
165df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     * played when popping the back stack.
166cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
167cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setCustomAnimations(int enter, int exit);
168df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn
169df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn    /**
170df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     * Set specific animation resources to run for the fragments that are
171df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     * entering and exiting in this transaction. The <code>popEnter</code>
172df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     * and <code>popExit</code> animations will be played for enter/exit
173df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     * operations specifically when popping the back stack.
174df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn     */
175df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn    public abstract FragmentTransaction setCustomAnimations(int enter, int exit,
176df6f1393f73a488ba2661b28d3d88a5ac19c4ea2Dianne Hackborn            int popEnter, int popExit);
177cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
178cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
179cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Select a standard transition animation for this transaction.  May be
180cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN},
181cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * or {@link #TRANSIT_FRAGMENT_CLOSE}
182cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
183cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setTransition(int transit);
184cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
185cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
186cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Set a custom style resource that will be used for resolving transit
187cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * animations.
188cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
189cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setTransitionStyle(int styleRes);
190cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
191cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
192cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Add this transaction to the back stack.  This means that the transaction
193cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * will be remembered after it is committed, and will reverse its operation
194cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * when later popped off the stack.
195cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
196cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param name An optional name for this back stack state, or null.
197cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
198cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction addToBackStack(String name);
199cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
200cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
201cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Returns true if this FragmentTransaction is allowed to be added to the back
202cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * stack. If this method would return false, {@link #addToBackStack(String)}
203cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * will throw {@link IllegalStateException}.
204cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
205cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return True if {@link #addToBackStack(String)} is permitted on this transaction.
206cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
207cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract boolean isAddToBackStackAllowed();
208cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
209cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
210cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Disallow calls to {@link #addToBackStack(String)}. Any future calls to
211cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * addToBackStack will throw {@link IllegalStateException}. If addToBackStack
212cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * has already been called, this method will throw IllegalStateException.
213cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
214cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction disallowAddToBackStack();
215cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
216cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
217cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Set the full title to show as a bread crumb when this transaction
2180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is on the back stack.
219cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
220cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param res A string resource containing the title.
221cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
222cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbTitle(int res);
223cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
224cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
225cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Like {@link #setBreadCrumbTitle(int)} but taking a raw string; this
226cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * method is <em>not</em> recommended, as the string can not be changed
227cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * later if the locale changes.
228cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
229cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbTitle(CharSequence text);
230cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
231cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
232cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Set the short title to show as a bread crumb when this transaction
2330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is on the back stack.
234cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
235cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @param res A string resource containing the title.
236cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
237cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbShortTitle(int res);
238cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
239cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
240cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Like {@link #setBreadCrumbShortTitle(int)} but taking a raw string; this
241cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * method is <em>not</em> recommended, as the string can not be changed
242cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * later if the locale changes.
243cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
244cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbShortTitle(CharSequence text);
245cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
246cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
247cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Schedules a commit of this transaction.  The commit does
248cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * not happen immediately; it will be scheduled as work on the main thread
249cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * to be done the next time that thread is ready.
250cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
251cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * <p class="note">A transaction can only be committed with this method
252cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * prior to its containing activity saving its state.  If the commit is
253cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * attempted after that point, an exception will be thrown.  This is
254cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * because the state after the commit can be lost if the activity needs to
255cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * be restored from its state.  See {@link #commitAllowingStateLoss()} for
256cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * situations where it may be okay to lose the commit.</p>
257cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     *
258cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * @return Returns the identifier of this transaction's back stack entry,
259cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * if {@link #addToBackStack(String)} had been called.  Otherwise, returns
260cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * a negative number.
261cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
262cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract int commit();
263cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn
264cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    /**
265cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * Like {@link #commit} but allows the commit to be executed after an
266cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * activity's state is saved.  This is dangerous because the commit can
267cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * be lost if the activity needs to later be restored from its state, so
268cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * this should only be used for cases where it is okay for the UI state
269cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     * to change unexpectedly on the user.
270cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn     */
271cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn    public abstract int commitAllowingStateLoss();
272cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn}
273