Simple Stack 1.8.0
Simple Stack 1.8.0 (2017-10-25)
- BREAKING(?) CHANGE / FIX: when
goBack()returns false, then the backstack is not cleared automatically. Addedreset()to allow imitating the previous behavior.
Previous behavior would now be the same as:
if(!backstack.goBack() && !backstack.isStateChangePending()) {
backstack.reset();
}
Honestly, this might have been unexpected, as goBack() returning false had the side-effect of clearing the stack, and next state change using the initial key!
The test that checks for this has been changed to use the above construct. Another test of course has been added to validate new behavior.
Also, to eliminate the possibility of reset() misuse, it is only allowed when there are no pending state changes.
-
BREAKING CHANGE:
getInitialParameters()is renamed togetInitialKeys(). -
FIX:
getInitialParameters()returned the actual list instead of an unmodifiable copy, it returns the keys provided at initialization. -
ADDED:
replaceTop()backstack operator, which replaces current top with the provided key. -
ADDED:
goUp()backstack operator, which will go back to the provided key if exists, replace top with new key otherwise. -
ADDED:
goUpChain()backstack operator, which will:- If the chain of parents is found as previous elements, then it works as back navigation to that chain.
- If the whole chain is not found, but at least one element of it is found, then the history is kept up to that point, then the chain is added, any duplicate element in the chain is added to the end as part of the chain.
- If none of the chain is found, the current top is removed, and the provided parent chain is added.
I added a bunch of tests for this, hopefully I didn't forget anything!
-
ENHANCEMENT/FIX:
HistoryBuilder.get()is now@NonNull, becauseHistoryBuilder.from(List<?>)throws if List containsnull. -
ENHANCEMENT:
getHistory()andgetInitialParameters()also returns aList<T>in which each element is cast toT. -
FIX:
BackstackDelegate.setStateChanger()should have been allowed even without callingbackstackDelegate.onCreate()first. All the samples usenew BackstackDelegate(null)so it never came up. -
ENHANCEMENT: Some improvement to
persistViewToState()exception message if the view has no key (so that it referencesKeyContextWrapperandstateChange.createContext()).