mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-26 17:06:56 +00:00
pass serviceId instead of item, reduce duplication
This commit is contained in:
parent
48a5107296
commit
ac59382b84
@ -333,7 +333,6 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void showStreamDialog(final StreamInfoItem item) {
|
protected void showStreamDialog(final StreamInfoItem item) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
@ -360,7 +359,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (KoreUtil.shouldShowPlayWithKodi(context, item)) {
|
if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
@ -175,7 +175,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (KoreUtil.shouldShowPlayWithKodi(context, item)) {
|
if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
@ -414,7 +414,7 @@ public class StatisticsPlaylistFragment
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) {
|
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
@ -782,7 +782,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||||||
StreamDialogEntry.share
|
StreamDialogEntry.share
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) {
|
if (KoreUtil.shouldShowPlayWithKodi(context, infoItem.getServiceId())) {
|
||||||
entries.add(StreamDialogEntry.play_with_kodi);
|
entries.add(StreamDialogEntry.play_with_kodi);
|
||||||
}
|
}
|
||||||
StreamDialogEntry.setEnabledEntries(entries);
|
StreamDialogEntry.setEnabledEntries(entries);
|
||||||
|
@ -932,9 +932,7 @@ public class VideoPlayerImpl extends VideoPlayer
|
|||||||
service.getString(R.string.show_play_with_kodi_key), false);
|
service.getString(R.string.show_play_with_kodi_key), false);
|
||||||
// show kodi button if it supports the current service and it is enabled in settings
|
// show kodi button if it supports the current service and it is enabled in settings
|
||||||
final boolean showKodiButton = playQueue != null && playQueue.getItem() != null
|
final boolean showKodiButton = playQueue != null && playQueue.getItem() != null
|
||||||
&& KoreUtil.isServiceSupportedByKore(playQueue.getItem().getServiceId())
|
&& KoreUtil.shouldShowPlayWithKodi(context, playQueue.getItem().getServiceId());
|
||||||
&& PreferenceManager.getDefaultSharedPreferences(context)
|
|
||||||
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
|
||||||
playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton
|
playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton
|
||||||
? View.VISIBLE : View.GONE);
|
? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.schabi.newpipe.util;
|
package org.schabi.newpipe.util;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
@ -8,7 +7,6 @@ import androidx.preference.PreferenceManager;
|
|||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
|
||||||
|
|
||||||
public final class KoreUtil {
|
public final class KoreUtil {
|
||||||
private KoreUtil() { }
|
private KoreUtil() { }
|
||||||
@ -18,8 +16,8 @@ public final class KoreUtil {
|
|||||||
|| serviceId == ServiceList.SoundCloud.getServiceId());
|
|| serviceId == ServiceList.SoundCloud.getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldShowPlayWithKodi(final Context context, final StreamInfoItem item) {
|
public static boolean shouldShowPlayWithKodi(final Context context, final int serviceId) {
|
||||||
return isServiceSupportedByKore(item.getServiceId())
|
return isServiceSupportedByKore(serviceId)
|
||||||
&& PreferenceManager.getDefaultSharedPreferences(context)
|
&& PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
.getBoolean(context.getString(R.string.show_play_with_kodi_key), false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user