From a7d5d9a1d693e7794c8df03c4f0657f33040b6a9 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Sat, 19 Feb 2022 00:02:15 +0100 Subject: [PATCH] Fix rebase --- .../newpipe/info_list/InfoItemDialog.java | 2 +- .../util/StreamDialogDefaultEntry.java | 37 ++----------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java index 183b2d8d9..924c03cd8 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemDialog.java @@ -252,7 +252,7 @@ public final class InfoItemDialog { * @return the current {@link Builder} instance */ public Builder addEnqueueEntriesIfNeeded() { - if (PlayerHolder.getInstance().isPlayerOpen()) { + if (PlayerHolder.getInstance().isPlayQueueReady()) { addEntry(StreamDialogDefaultEntry.ENQUEUE); if (PlayerHolder.getInstance().getQueueSize() > 1) { diff --git a/app/src/main/java/org/schabi/newpipe/util/StreamDialogDefaultEntry.java b/app/src/main/java/org/schabi/newpipe/util/StreamDialogDefaultEntry.java index b9e1f17c5..a395d1ec1 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StreamDialogDefaultEntry.java +++ b/app/src/main/java/org/schabi/newpipe/util/StreamDialogDefaultEntry.java @@ -1,21 +1,15 @@ package org.schabi.newpipe.util; -import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; import static org.schabi.newpipe.util.StreamDialogEntry.fetchItemInfoIfSparse; import static org.schabi.newpipe.util.StreamDialogEntry.openChannelFragment; import android.net.Uri; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.StringRes; -import org.schabi.newpipe.NewPipeDatabase; import org.schabi.newpipe.R; import org.schabi.newpipe.database.stream.model.StreamEntity; -import org.schabi.newpipe.error.ErrorInfo; -import org.schabi.newpipe.error.ErrorUtil; -import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.local.dialog.PlaylistDialog; import org.schabi.newpipe.local.history.HistoryRecordManager; @@ -25,7 +19,6 @@ import org.schabi.newpipe.util.external_communication.ShareUtils; import java.util.Collections; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; -import io.reactivex.rxjava3.schedulers.Schedulers; /** *

@@ -44,32 +37,10 @@ import io.reactivex.rxjava3.schedulers.Schedulers; *

*/ public enum StreamDialogDefaultEntry { - SHOW_CHANNEL_DETAILS(R.string.show_channel_details, (fragment, item) -> { - if (isNullOrEmpty(item.getUploaderUrl())) { - final int serviceId = item.getServiceId(); - final String url = item.getUrl(); - Toast.makeText(fragment.getContext(), R.string.loading_channel_details, - Toast.LENGTH_SHORT).show(); - ExtractorHelper.getStreamInfo(serviceId, url, false) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(result -> { - NewPipeDatabase.getInstance(fragment.requireContext()).streamDAO() - .setUploaderUrl(serviceId, url, result.getUploaderUrl()) - .subscribeOn(Schedulers.io()).subscribe(); - openChannelFragment(fragment, item, result.getUploaderUrl()); - }, throwable -> ErrorUtil.openActivity( - fragment.requireContext(), - new ErrorInfo( - throwable, - UserAction.REQUESTED_CHANNEL, - url, - serviceId - ))); - } else { - openChannelFragment(fragment, item, item.getUploaderUrl()); - } - }), + SHOW_CHANNEL_DETAILS(R.string.show_channel_details, (fragment, item) -> + SaveUploaderUrlHelper.saveUploaderUrlIfNeeded(fragment, item, + uploaderUrl -> openChannelFragment(fragment, item, uploaderUrl)) + ), /** * Enqueues the stream automatically to the current PlayerType.