Fixing crash on restore caused by bonsai upgrade
This commit is contained in:
parent
826ca9118e
commit
1f1d1e7f32
@ -17,11 +17,14 @@ import android.webkit.WebView;
|
||||
import com.anthonycr.bonsai.Completable;
|
||||
import com.anthonycr.bonsai.CompletableAction;
|
||||
import com.anthonycr.bonsai.CompletableSubscriber;
|
||||
import com.anthonycr.bonsai.ObservableSubscriber;
|
||||
import com.anthonycr.bonsai.Single;
|
||||
import com.anthonycr.bonsai.SingleAction;
|
||||
import com.anthonycr.bonsai.SingleOnSubscribe;
|
||||
import com.anthonycr.bonsai.SingleSubscriber;
|
||||
import com.anthonycr.bonsai.Stream;
|
||||
import com.anthonycr.bonsai.StreamAction;
|
||||
import com.anthonycr.bonsai.StreamOnSubscribe;
|
||||
import com.anthonycr.bonsai.StreamSubscriber;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -156,9 +159,9 @@ public class TabsManager {
|
||||
@NonNull final CompletableSubscriber subscriber) {
|
||||
|
||||
restoreState().subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.main()).subscribe(new SingleOnSubscribe<Bundle>() {
|
||||
.observeOn(Schedulers.main()).subscribe(new StreamOnSubscribe<Bundle>() {
|
||||
@Override
|
||||
public void onItem(@Nullable Bundle item) {
|
||||
public void onNext(@Nullable Bundle item) {
|
||||
LightningView tab = newTab(activity, "", false);
|
||||
String url = item.getString(URL_KEY);
|
||||
if (url != null && tab.getWebView() != null) {
|
||||
@ -480,16 +483,16 @@ public class TabsManager {
|
||||
* and will delete the saved instance file when
|
||||
* restoration is complete.
|
||||
*/
|
||||
private Single<Bundle> restoreState() {
|
||||
return Single.create(new SingleAction<Bundle>() {
|
||||
private Stream<Bundle> restoreState() {
|
||||
return Stream.create(new StreamAction<Bundle>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull SingleSubscriber<Bundle> subscriber) {
|
||||
public void onSubscribe(@NonNull StreamSubscriber<Bundle> subscriber) {
|
||||
Bundle savedState = FileUtils.readBundleFromStorage(mApp, BUNDLE_STORAGE);
|
||||
if (savedState != null) {
|
||||
Log.d(Constants.TAG, "Restoring previous WebView state now");
|
||||
for (String key : savedState.keySet()) {
|
||||
if (key.startsWith(BUNDLE_KEY)) {
|
||||
subscriber.onItem(savedState.getBundle(key));
|
||||
subscriber.onNext(savedState.getBundle(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user