Fixed crash (fromCallable rethrows instead of calling onError)

This commit is contained in:
ByteHamster 2020-09-20 08:52:25 +02:00
parent 689bdb69db
commit 3671188b0f
1 changed files with 5 additions and 11 deletions

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.core.util.playback.PlaybackController;
import de.danoeh.antennapod.core.util.playback.Timeline; import de.danoeh.antennapod.core.util.playback.Timeline;
import de.danoeh.antennapod.view.ShownotesWebView; import de.danoeh.antennapod.view.ShownotesWebView;
@ -82,8 +83,10 @@ public class ItemDescriptionFragment extends Fragment {
if (webViewLoader != null) { if (webViewLoader != null) {
webViewLoader.dispose(); webViewLoader.dispose();
} }
webViewLoader = Maybe.fromCallable(this::loadData) webViewLoader = Maybe.<String>create(emitter -> {
.subscribeOn(Schedulers.io()) Timeline timeline = new Timeline(getActivity(), controller.getMedia());
emitter.onSuccess(timeline.processShownotes());
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(data -> { .subscribe(data -> {
webvDescription.loadDataWithBaseURL("https://127.0.0.1", data, "text/html", webvDescription.loadDataWithBaseURL("https://127.0.0.1", data, "text/html",
@ -92,15 +95,6 @@ public class ItemDescriptionFragment extends Fragment {
}, error -> Log.e(TAG, Log.getStackTraceString(error))); }, error -> Log.e(TAG, Log.getStackTraceString(error)));
} }
@Nullable
private String loadData() {
if (controller == null || controller.getMedia() == null) {
return null;
}
Timeline timeline = new Timeline(getActivity(), controller.getMedia());
return timeline.processShownotes();
}
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();