Skip to content

Commit

Permalink
Merge pull request #44 from livefront/prepare-for-v1.2.0-release
Browse files Browse the repository at this point in the history
Prepare for v1.2.0 release
  • Loading branch information
brian-livefront committed May 30, 2019
2 parents 4aff8cb + c109ab3 commit 85c00a3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
Change Log
==========

Version 1.2.0 *(2019-05-30)*
----------------------------

* `Bridge` can now save the state of `View` objects. You may now optionally provide a `ViewSavedStateHandler` to `Bridge.initialize` in order to unlock this functionality.
* Improved performance during configuration changes and when navigating while apps are in the foreground.

Version 1.1.3 *(2018-10-08)*
----------------------------

* `Bridge.clear` is now safe to call in `Activity.onDestroy` when "Don't Keep Activities" is enabled.
* All data is now correctly cleared on fresh launches for apps that do not use `Bridge` in every `Activity`.
* Min SDK is now 14.
Expand Down
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ A library for avoiding TransactionTooLargeException during state saving and rest
* [Motivation](#motivation)
* [Setup](#setup)
* [Clearing Data](#clear)
* [Bridge for Views](#views)
* [Install](#install)
* [How Does It Work](#how)
* [Limitations](#limitations)
Expand Down Expand Up @@ -84,6 +85,50 @@ This method is typically safe to call without any additional logic, as it will o

In the event that you might like to migrate away from the use of `Bridge` but ensure that all associated data is cleared, `Bridge.clearAll` may be called at any time.

<a name="views"></a>
## Bridge for Views

In addition to `Activity`, `Fragment`, presenter, etc. classes, `Bridge` can also be used to assist in saving the state of `View` classes using `View`-specific save and restore methods :

```java
@Override
protected Parcelable onSaveInstanceState() {
return Bridge.saveInstanceState(this, super.onSaveInstanceState());
}

@Override
protected void onRestoreInstanceState(Parcelable state) {
super.onRestoreInstanceState(Bridge.restoreInstanceState(this, state));
}
```

In order to enable this ability, a `ViewSavedStateHandler` must be passed to the `Bridge.initialize` method. For example:

```java
Bridge.initialize(
getApplicationContext(),
new SavedStateHandler() {
...
},
new ViewSavedStateHandler() {
@NonNull
@Override
public <T extends View> Parcelable saveInstanceState(
@NonNull T target,
@Nullable Parcelable parentState) {
return Icepick.saveInstanceState(target, parentState);
}

@Nullable
@Override
public <T extends View> Parcelable restoreInstanceState(
@NonNull T target,
@Nullable Parcelable state) {
return Icepick.restoreInstanceState(target, state);
}
});
```

<a name="install"></a>
## Install

Expand All @@ -95,7 +140,7 @@ repositories {
}
dependencies {
implementation 'com.github.livefront:bridge:v1.1.3'
implementation 'com.github.livefront:bridge:v1.2.0'
}
```

Expand Down

0 comments on commit 85c00a3

Please sign in to comment.