address pull request feedback

This commit is contained in:
khimaros 2020-12-30 14:40:21 -08:00
parent 83faf119a9
commit 48a5107296
6 changed files with 17 additions and 24 deletions

View File

@ -360,11 +360,8 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
StreamDialogEntry.share
));
}
final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(item.getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
if (enableKodiEntry) {
entries.add(StreamDialogEntry.play_on_kodi);
if (KoreUtil.shouldShowPlayWithKodi(context, item)) {
entries.add(StreamDialogEntry.play_with_kodi);
}
StreamDialogEntry.setEnabledEntries(entries);

View File

@ -17,7 +17,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.preference.PreferenceManager;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
@ -176,11 +175,8 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
StreamDialogEntry.share
));
}
final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(item.getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
if (enableKodiEntry) {
entries.add(StreamDialogEntry.play_on_kodi);
if (KoreUtil.shouldShowPlayWithKodi(context, item)) {
entries.add(StreamDialogEntry.play_with_kodi);
}
StreamDialogEntry.setEnabledEntries(entries);

View File

@ -17,7 +17,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
import com.google.android.material.snackbar.Snackbar;
@ -415,11 +414,8 @@ public class StatisticsPlaylistFragment
StreamDialogEntry.share
));
}
final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(infoItem.getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
if (enableKodiEntry) {
entries.add(StreamDialogEntry.play_on_kodi);
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) {
entries.add(StreamDialogEntry.play_with_kodi);
}
StreamDialogEntry.setEnabledEntries(entries);

View File

@ -20,7 +20,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
@ -783,11 +782,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
StreamDialogEntry.share
));
}
final boolean enableKodiEntry = KoreUtil.isServiceSupportedByKore(infoItem.getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
if (enableKodiEntry) {
entries.add(StreamDialogEntry.play_on_kodi);
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) {
entries.add(StreamDialogEntry.play_with_kodi);
}
StreamDialogEntry.setEnabledEntries(entries);

View File

@ -4,9 +4,11 @@ package org.schabi.newpipe.util;
import android.content.Context;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
public final class KoreUtil {
private KoreUtil() { }
@ -16,6 +18,12 @@ public final class KoreUtil {
|| serviceId == ServiceList.SoundCloud.getServiceId());
}
public static boolean shouldShowPlayWithKodi(final Context context, final StreamInfoItem item) {
return isServiceSupportedByKore(item.getServiceId())
&& PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
}
public static void showInstallKoreDialog(final Context context) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.kore_not_found)

View File

@ -71,7 +71,7 @@ public enum StreamDialogEntry {
}
}),
play_on_kodi(R.string.play_with_kodi_title, (fragment, item) -> {
play_with_kodi(R.string.play_with_kodi_title, (fragment, item) -> {
final Uri videoUrl = Uri.parse(item.getUrl());
try {
NavigationHelper.playWithKore(fragment.getContext(), videoUrl);