mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 23:32:59 +00:00 
			
		
		
		
	pass serviceId instead of item, reduce duplication
This commit is contained in:
		| @@ -333,7 +333,6 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     protected void showStreamDialog(final StreamInfoItem item) { | ||||
|         final Context context = getContext(); | ||||
|         final Activity activity = getActivity(); | ||||
| @@ -360,7 +359,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> | ||||
|                     StreamDialogEntry.share | ||||
|             )); | ||||
|         } | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, item)) { | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) { | ||||
|             entries.add(StreamDialogEntry.play_with_kodi); | ||||
|         } | ||||
|         StreamDialogEntry.setEnabledEntries(entries); | ||||
|   | ||||
| @@ -175,7 +175,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> { | ||||
|                     StreamDialogEntry.share | ||||
|             )); | ||||
|         } | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, item)) { | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, item.getServiceId())) { | ||||
|             entries.add(StreamDialogEntry.play_with_kodi); | ||||
|         } | ||||
|         StreamDialogEntry.setEnabledEntries(entries); | ||||
|   | ||||
| @@ -414,7 +414,7 @@ public class StatisticsPlaylistFragment | ||||
|                     StreamDialogEntry.share | ||||
|             )); | ||||
|         } | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) { | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, infoItem.getServiceId())) { | ||||
|             entries.add(StreamDialogEntry.play_with_kodi); | ||||
|         } | ||||
|         StreamDialogEntry.setEnabledEntries(entries); | ||||
|   | ||||
| @@ -782,7 +782,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|                     StreamDialogEntry.share | ||||
|             )); | ||||
|         } | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, infoItem)) { | ||||
|         if (KoreUtil.shouldShowPlayWithKodi(context, infoItem.getServiceId())) { | ||||
|             entries.add(StreamDialogEntry.play_with_kodi); | ||||
|         } | ||||
|         StreamDialogEntry.setEnabledEntries(entries); | ||||
|   | ||||
| @@ -932,9 +932,7 @@ public class VideoPlayerImpl extends VideoPlayer | ||||
|                 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 | ||||
|         final boolean showKodiButton = playQueue != null && playQueue.getItem() != null | ||||
|                 && KoreUtil.isServiceSupportedByKore(playQueue.getItem().getServiceId()) | ||||
|                 && PreferenceManager.getDefaultSharedPreferences(context) | ||||
|                 .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); | ||||
|                 && KoreUtil.shouldShowPlayWithKodi(context, playQueue.getItem().getServiceId()); | ||||
|         playWithKodi.setVisibility(videoPlayerSelected() && kodiEnabled && showKodiButton | ||||
|                 ? View.VISIBLE : View.GONE); | ||||
|     } | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| package org.schabi.newpipe.util; | ||||
|  | ||||
|  | ||||
| import android.content.Context; | ||||
|  | ||||
| import androidx.appcompat.app.AlertDialog; | ||||
| @@ -8,7 +7,6 @@ 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() { } | ||||
| @@ -18,8 +16,8 @@ public final class KoreUtil { | ||||
|                 || serviceId == ServiceList.SoundCloud.getServiceId()); | ||||
|     } | ||||
|  | ||||
|     public static boolean shouldShowPlayWithKodi(final Context context, final StreamInfoItem item) { | ||||
|         return isServiceSupportedByKore(item.getServiceId()) | ||||
|     public static boolean shouldShowPlayWithKodi(final Context context, final int serviceId) { | ||||
|         return isServiceSupportedByKore(serviceId) | ||||
|                 && PreferenceManager.getDefaultSharedPreferences(context) | ||||
|                 .getBoolean(context.getString(R.string.show_play_with_kodi_key), false); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 khimaros
					khimaros