From 1f1d1e7f3252f0b95de4efdf0952b65799b9679c Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Sun, 26 Mar 2017 20:08:36 -0400 Subject: [PATCH] Fixing crash on restore caused by bonsai upgrade --- .../browser/lightning/activity/TabsManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java index 7e5eefa..6167edd 100644 --- a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java +++ b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java @@ -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() { + .observeOn(Schedulers.main()).subscribe(new StreamOnSubscribe() { @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 restoreState() { - return Single.create(new SingleAction() { + private Stream restoreState() { + return Stream.create(new StreamAction() { @Override - public void onSubscribe(@NonNull SingleSubscriber subscriber) { + public void onSubscribe(@NonNull StreamSubscriber 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)); } } }