|
1 | 1 | package org.schabi.newpipe.util; |
2 | 2 |
|
3 | | -import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; |
4 | 3 | import static org.schabi.newpipe.util.StreamDialogEntry.fetchItemInfoIfSparse; |
5 | 4 | import static org.schabi.newpipe.util.StreamDialogEntry.openChannelFragment; |
6 | 5 |
|
7 | 6 | import android.net.Uri; |
8 | | -import android.widget.Toast; |
9 | 7 |
|
10 | 8 | import androidx.annotation.NonNull; |
11 | 9 | import androidx.annotation.StringRes; |
12 | 10 |
|
13 | | -import org.schabi.newpipe.NewPipeDatabase; |
14 | 11 | import org.schabi.newpipe.R; |
15 | 12 | import org.schabi.newpipe.database.stream.model.StreamEntity; |
16 | | -import org.schabi.newpipe.error.ErrorInfo; |
17 | | -import org.schabi.newpipe.error.ErrorUtil; |
18 | | -import org.schabi.newpipe.error.UserAction; |
19 | 13 | import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; |
20 | 14 | import org.schabi.newpipe.local.dialog.PlaylistDialog; |
21 | 15 | import org.schabi.newpipe.local.history.HistoryRecordManager; |
|
25 | 19 | import java.util.Collections; |
26 | 20 |
|
27 | 21 | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |
28 | | -import io.reactivex.rxjava3.schedulers.Schedulers; |
29 | 22 |
|
30 | 23 | /** |
31 | 24 | * <p> |
|
44 | 37 | * </p> |
45 | 38 | */ |
46 | 39 | public enum StreamDialogDefaultEntry { |
47 | | - SHOW_CHANNEL_DETAILS(R.string.show_channel_details, (fragment, item) -> { |
48 | | - if (isNullOrEmpty(item.getUploaderUrl())) { |
49 | | - final int serviceId = item.getServiceId(); |
50 | | - final String url = item.getUrl(); |
51 | | - Toast.makeText(fragment.getContext(), R.string.loading_channel_details, |
52 | | - Toast.LENGTH_SHORT).show(); |
53 | | - ExtractorHelper.getStreamInfo(serviceId, url, false) |
54 | | - .subscribeOn(Schedulers.io()) |
55 | | - .observeOn(AndroidSchedulers.mainThread()) |
56 | | - .subscribe(result -> { |
57 | | - NewPipeDatabase.getInstance(fragment.requireContext()).streamDAO() |
58 | | - .setUploaderUrl(serviceId, url, result.getUploaderUrl()) |
59 | | - .subscribeOn(Schedulers.io()).subscribe(); |
60 | | - openChannelFragment(fragment, item, result.getUploaderUrl()); |
61 | | - }, throwable -> ErrorUtil.openActivity( |
62 | | - fragment.requireContext(), |
63 | | - new ErrorInfo( |
64 | | - throwable, |
65 | | - UserAction.REQUESTED_CHANNEL, |
66 | | - url, |
67 | | - serviceId |
68 | | - ))); |
69 | | - } else { |
70 | | - openChannelFragment(fragment, item, item.getUploaderUrl()); |
71 | | - } |
72 | | - }), |
| 40 | + SHOW_CHANNEL_DETAILS(R.string.show_channel_details, (fragment, item) -> |
| 41 | + SaveUploaderUrlHelper.saveUploaderUrlIfNeeded(fragment, item, |
| 42 | + uploaderUrl -> openChannelFragment(fragment, item, uploaderUrl)) |
| 43 | + ), |
73 | 44 |
|
74 | 45 | /** |
75 | 46 | * Enqueues the stream automatically to the current PlayerType. |
|
0 commit comments