Catch error from ExtractorHelper.getStreamInfo, remove blockingGet
This commit is contained in:
parent
76803bfcb1
commit
d8888e3495
1 changed files with 17 additions and 10 deletions
|
@ -2,6 +2,7 @@ package org.schabi.newpipe.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
@ -37,17 +38,23 @@ public enum StreamDialogEntry {
|
||||||
final int serviceId = item.getServiceId();
|
final int serviceId = item.getServiceId();
|
||||||
final String url = item.getUrl();
|
final String url = item.getUrl();
|
||||||
// TODO: Some visual loading indicator
|
// TODO: Some visual loading indicator
|
||||||
final String uploaderUrl = ExtractorHelper.getStreamInfo(serviceId, url, false)
|
ExtractorHelper.getStreamInfo(serviceId, url, false)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.blockingGet()
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.getUploaderUrl();
|
.subscribe(result -> {
|
||||||
NewPipeDatabase.getInstance(fragment.getContext()).streamDAO()
|
NewPipeDatabase.getInstance(fragment.getContext()).streamDAO()
|
||||||
.setUploaderUrl(serviceId, url, uploaderUrl)
|
.setUploaderUrl(serviceId, url, result.getUploaderUrl())
|
||||||
.subscribeOn(Schedulers.io()).subscribe();
|
.subscribeOn(Schedulers.io()).subscribe();
|
||||||
// For some reason `getParentFragmentManager()` doesn't work, but this does.
|
// For some reason `getParentFragmentManager()` doesn't work, but this does.
|
||||||
NavigationHelper.openChannelFragment(
|
NavigationHelper.openChannelFragment(
|
||||||
fragment.requireActivity().getSupportFragmentManager(),
|
fragment.requireActivity().getSupportFragmentManager(),
|
||||||
item.getServiceId(), uploaderUrl, item.getUploaderName());
|
item.getServiceId(), result.getUploaderUrl(),
|
||||||
|
item.getUploaderName());
|
||||||
|
}, throwable -> Toast.makeText(
|
||||||
|
fragment.getContext(),
|
||||||
|
"Error at Show Channel Details",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show());
|
||||||
} else {
|
} else {
|
||||||
// For some reason `getParentFragmentManager()` doesn't work, but this does.
|
// For some reason `getParentFragmentManager()` doesn't work, but this does.
|
||||||
NavigationHelper.openChannelFragment(
|
NavigationHelper.openChannelFragment(
|
||||||
|
|
Loading…
Reference in a new issue