- Added
GetPreviousViewStrategy
toDefaultStateChanger
as per request (#36).
- Added
KeyFilter
to allow clearing out keys on process death that should not be restored. - Added
stateChange.backstack()
which returns the backstack this state change was executed by. - Added
DefaultStateChanger.ViewChangeStartListener
for before the view change, but after the state restore - Added
DefaultStateChanger.LayoutInflationStrategy
to support asynchronous layout inflation (if you need it) or hopefully Anko
- Bump
state-bundle
version to1.1.4
- Bump
state-bundle
version to1.1.0
- Added a method to
DefaultStateChanger
to allow perform view change with an externally specified direction.
-
Merged
zhuinden/navigator
intozhuinden/simple-stack
. -
ADDED:
Navigator
class as an optional replacement forBackstackDelegate
(API 11+).
BackstackDelegate
had a lot of callbacks to remember (onPause()
, onResume()
, onRetainCustomNonConfigurationInstance()
, onDestroy()
),
but more importantly you had to manage saving out the current view's state in onSaveInstanceState()
manually.
With Navigator, this is all hidden in the BackstackHost
installed by Navigator.install()
(or Navigator.configure()...install()
, so this problem is solved for you.
- ADDED:
DefaultStateChanger
that by default usesNavigator
-based installation.
To use DefaultStateChanger
with BackstackDelegate
, you must provide DefaultStateChanger.configure().setStatePersistenceStrategy()
and delegate persistence calls to your delegate.
-
ADDED:
StateKey
interface used byDefaultStateChanger
. -
ADDED: default view change handlers for
DefaultStateChanger
. -
All examples (except the
fragment
andmultistack
samples) were updated to useNavigator
. -
simple-stack-example-mvp
no longer usessquare/coordinator
, it uses custom viewgroups instead.
This is because Coordinator
gets created only after container.addView()
, which makes it hard to work with.
- ADDED:
backstack.top()
method that returns the last element in the backstack ornull
- FIX: Fixed a bug that if a restored backstack is cleared and an initialize state change is triggered, then the restored keys were used instead of the initial key (this only surfaced if you attempt to use multiple backstacks, and a cleared backstack is re-used)
- CHANGE: Decreased minSDK to 1.
- MINOR FIX: Adjusted exception message in
BackstackManager
to saysetup()
.
-
BREAKING CHANGE:
StateBundle
is moved fromcom.zhuinden.simplestack.StateBundle
tocom.zhuinden.statebundle.StateBundle
-
CHANGE:
StateBundle
is moved to https://github.com/Zhuinden/state-bundle and is a compile dependency ofsimple-stack
-
REFACTOR:
BackstackDelegate
is separated intoBackstackManager
. -
ADDED:
BackstackManager
class to help with creating backstacks inside views. -
ENHANCEMENT:
BackstackManager
is nowBundleable
, therefore its state can be automatically restored along with other managed services (see examples). -
CHANGE:
clearStatesNotIn()
is no longer a method ofBackstackDelegate
orBackstackManager
, it can be specified as custom using aBackstackManager.StateClearStrategy
. -
ADDED:
simple-stack-example-services
that shows how to useservice-tree
withsimple-stack
to store scoped services that can have their states restored and survive configuration change. -
ADDED:
simple-stack-example-nestedstack
that shows how to use view-levelBackstackManager
stored inservice-tree
to have nested backstacks inside views.
- FIX:
HistoryBuilder
should receiveList<?>
as parameters, notList<Object>
on all methods.
-
BREAKING CHANGE:
Bundleable
andSavedState
now useStateBundle
class. -
ENHANCEMENT: Added
StateBundle
class to replaceandroid.os.Bundle
.
-
FIX: A bug that allowed the possibility that an uninitialized backstack could restore its history to be an empty list after process death.
-
ADDED:
simple-stack-example-multistack
for handling multiple backstacks in the same Activity using a BottomNavigationView.
-
BREAKING CHANGE:
Backstack
's APIs returnObject
instead ofParcelable
(that includesStateChange
, initial keys,HistoryBuilder
, etc.) -
ENHANCEMENT: Added
KeyParceler
interface to allow defining custom strategy in order to turn keys intoParcelable
(for example, usingParceler
library instead)
-
RELEASE: 1.0.0!
-
ENHANCEMENT: Javadoc for all public classes and methods.
- INTERNAL CHANGE: Hidden
stateChangeComplete()
from public API ofBackstackDelegate
, it shouldn't have been public.
-
INTERNAL CHANGE:
clearStatesNotIn()
now receives bothkeyStateMap
andStateChange
, instead of just the new state. -
ENHANCEMENT: Added
HistoryBuilder.from(Backstack)
andHistoryBuilder.from(BackstackDelegate)
convenience methods. -
ENHANCEMENT: Added
HistoryBuilder.isEmpty()
method, and implementsIterable<Parcelable>
. -
ADDED:
flow-masterdetail-fragments
example. -
FIX: A bug in
flow-masterdetail
sample that prevented Master's state from being persisted if detail directly opens a detail.
-
ENHANCEMENT: Added ability to force execute pending state changes with
Backstack.executePendingStateChange()
. -
INTERNAL CHANGE:
BackstackDelegate.onDestroy()
callsbackstack.executePendingStateChange()
to prevent hanging state changes. -
ADDED:
ObjectAnimator
-based segue animation to MVP example.
-
BREAKING CHANGE(?):
CompletionListener
no longer receivesisPending
parameter. -
ADDED:
Backstack.isStateChangePending()
to replaceisPending
. -
ENHANCEMENT: Added some missing
@NonNull
and@Nullable
annotations. -
ADDED: Apache license notes, and improved the README.
-
BREAKING CHANGE(!):
BackstackDelegate
has a new method which must be called:backstackDelegate.onDestroy()
Not callingbackstackDelegate.onDestroy()
will most likely result in memory leak, so please make sure you call it paired withonCreate()
. -
BREAKING CHANGE:
BackstackDelegate.clearStatesNotIn()
is no longer public, because it is automatically managed on state change completion. -
ENHANCEMENT: Added
Backstack.CompletionListener
which listens to when backstack has completed a state change. AddedBackstack.addCompletionListener()
andBackstack.removeCompletionListener()
methods. The backstack keeps a strong reference to your completion listener, so make sure you remove your change listener when no longer needed. -
ENHANCEMENT: It is no longer the responsibility of the
StateChanger
to callbackstackDelegate.clearStatesNotIn()
. TheBackstackDelegate
registers itself as aCompletionListener
, and therefore it can callclearStatesNotIn()
automatically. -
ENHANCEMENT: Added
flow-sample
changed to use Simple-Stack, as namesimple-stack-flow-masterdetail
.
- ENHANCEMENT: Added
BackstackDelegate.setPersistenceTag(String)
for support of multiple backstacks. It must be called beforeBackstackDelegate.onCreate()
.
- CHANGE:
KeyContextWrapper
is public again - ENHANCEMENT: Created
fragments
example based onmvp
example.
- BREAKING(?) CHANGE: Renamed
HistoryBuilder.peek()
toHistoryBuilder.getLast()
- ENHANCEMENT: Added the following new methods to
HistoryBuilder
:HistoryBuilder.get(index)
,HistoryBuilder.contains(key)
,HistoryBuilder.containsAll(keys)
,HistoryBuilder.add(key, index)
,HistoryBuilder.size()
,HistoryBuilder.removeAt(index)
,HistoryBuilder.remove(key)
,HistoryBuilder.clear()
,HistoryBuilder.retainAll(keys)
,HistoryBuilder.indexOf(key)
,
- BREAKING CHANGE: Removed
StateChange.Direction
, it is now anint
annotated with@IntDef
. This means thatStateChange.Direction.FORWARD
is nowStateChange.FORWARD
, same forBACKWARD
andREPLACE
. - Fix:
@StateChangerRegisterMode
shouldn't have been public
- BREAKING CHANGE: Removed
Backstack.get(Context)
,BackstackDelegate.isSystemService(String)
andBackstackDelegate.getSystemService(Context)
.
These can be easily done manually with the following setup:
public static Backstack get(Context context) {
// noinspection ResourceType
return (Backstack)context.getSystemService(BACKSTACK);
}
and
@Override
public Object getSystemService(String name) {
if(name.equals(BACKSTACK)) {
return backstackDelegate.getBackstack();
}
return super.getSystemService(name);
}
Therefore the preferred solution is to provide the Backstack
instance via @Inject
instead of Backstack.get(Context)
.
Example for Backstack.get(Context)
was moved to simple-stack-example
as BackstackService
.
Example for @Inject Backstack backstack;
is seen in simple-stack-example-mvp
.
- It is now allowed to initialize
BackstackDelegate
without aStateChanger
, in which casesetStateChanger()
must be called beforeonPostResume()
.This way it is possible to postpone the initialization state change of the
Backstack`.
- Simple Stack is now a library!
- Added
BackstackDelegate.getBackstack()
for convenience overBackstack.get(this)
in Activity
- Added
Bundleable
interface to allow saving view's state to Bundle - Added
BackstackDelegate.restoreViewFromState()
method to mirrorpersistViewToState()
getSavedState()
now returns a newSavedState
instead of throwing error if the key has no state bound to it- Added
SavedState.viewHierarchyState
default valuenew SparseArray<>()
, null is prohibited
- Added
BackstackDelegate
class to hide activity lifecycle integration - Moved
SavedState
into library - Added
Backstack.get(Context)
method to obtain Backstack of instance shared by the delegate - Moved
KeyContextWrapper
into library, and it is now package-private - Added
StateChange.createContext(base, key)
method to createKeyContextWrapper
KeyContextWrapper.getKey(Context)
is nowBackstack.getKey(Context)
- Rename packages from
demostack
tosimplestack
- Rename
State
toSavedState
- Add check for if
key
isnull
inState
'sBuilder.build()
- Added missing
equals()
/hashCode()
toState
class in example
- Added view persistence to example code (
MainActivity
)
- Added
HistoryBuilder
for convenience
- Minor bug fixes and simplifications
- Added
ReentranceTest
and ported tosimple-stack-demo
codebase - Fixed some bugs based on
ReentranceTest
- all tests pass now
- State changes are now enqueued while
StateChanger
is not available (afteronPause()
) or a state change is already in progress - Added
FlowTest
and ported tosimple-stack-demo
codebase
- Key and backstack are now provided to custom viewgroup via
getSystemService()
- Added initial
Backstack
,StateChange
andStateChanger
classes. - Backstack allows manipulation of state via
goTo()
,goBack()
andsetHistory()
. - Demo persists backstack history through config change and process death.
Limitations:
- ViewState is not persisted
- scheduling state changes (starting a state change while another is in progress) is not allowed
- there is a possibility that state change can occur even after
onPause()
- key and backstack are manually set to the custom viewgroup, which means these are not directly accessible in their child views (and the interfaces are ugly anyways)