You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Get a copy of the current stack that is being displayed
194
-
*
195
-
* @return Current stack
196
-
*/
197
-
@SuppressWarnings("unchecked")
198
-
@CheckResult
199
-
@Nullable
200
-
publicStack<Fragment> getCurrentStack() {
201
-
return getStack(selectedTabIndex);
202
-
}
203
-
204
-
/**
205
-
* Get the index of the current stack that is being displayed
206
-
*
207
-
* @return Current stack index
208
-
*/
209
-
@CheckResult
210
-
@TabIndex
211
-
publicint getCurrentStackIndex() {
212
-
return selectedTabIndex;
213
-
}
214
-
215
-
/**
216
-
* @return If true, you are at the bottom of the stack
217
-
* (Consider using replaceFragment if you need to change the root fragment for some reason)
218
-
* else you can popFragment as needed as your are not at the root
219
-
*/
220
-
@CheckResult
221
-
publicboolean isRootFragment() {
222
-
Stack<Fragment> stack = getCurrentStack();
223
-
224
-
return stack ==null|| stack.size() ==1;
225
-
}
226
-
227
-
/**
228
-
* Helper function to get wether the fragmentManger has gone through a stateSave, if this is true, you probably want to commit allowing stateloss
229
-
*
230
-
* @return if fragmentManger isStateSaved
231
-
*/
232
-
publicboolean isStateSaved() {
233
-
return fragmentManger.isStateSaved();
234
-
}
163
+
Can be set using the transactionOptions
235
164
236
-
/**
237
-
* Use this if you need to make sure that pending transactions occur immediately. This call is safe to
238
-
* call as often as you want as there's a check to prevent multiple executePendingTransactions at once
239
-
*
240
-
*/
241
-
publicvoid executePendingTransactions() {
242
-
if (!executingTransaction) {
243
-
executingTransaction =true;
244
-
fragmentManger.executePendingTransactions();
245
-
executingTransaction =false;
246
-
}
247
-
}
248
165
249
-
250
-
```
251
166
252
167
## Restoring Fragment State
253
168
Fragments transitions in this library use attach()/detch() (http://daniel-codes.blogspot.com/2012/06/fragment-transactions-reference.html). This is a delibrate choice in order to maintain the fragment's lifecycle, as well as being optimal for memory. This means that fragments will go through their proper lifecycle https://developer.android.com/guide/components/fragments.html#Lifecycle . This lifecycle includes going through `OnCreateView` which means that if you want to maintain view states, that is outside the scope of this library, and is up to the indiviudal fragment. There are plenty of resources out there that will help you design your fragments in such a way that their view state can be restored https://inthecheesefactory.com/blog/fragment-state-saving-best-practices/en and there are libraries that can help restore other states https://github.com/frankiesardo/icepick
0 commit comments