mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
fix: can't open playlists
This commit is contained in:
parent
9c2abeeca1
commit
3661cd82f7
@ -26,11 +26,11 @@ import com.github.libretube.ui.views.SingleViewTouchableMotionLayout
|
||||
object NavigationHelper {
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
fun navigateChannel(context: Context, channelId: String?) {
|
||||
if (channelId == null) return
|
||||
fun navigateChannel(context: Context, channelUrlOrId: String?) {
|
||||
if (channelUrlOrId == null) return
|
||||
|
||||
val activity = ContextHelper.unwrapActivity(context)
|
||||
activity.navController.navigate(NavDirections.openChannel(channelId))
|
||||
activity.navController.navigate(NavDirections.openChannel(channelUrlOrId.toID()))
|
||||
try {
|
||||
if (activity.binding.mainMotionLayout.progress == 0.toFloat()) {
|
||||
activity.binding.mainMotionLayout.transitionToEnd()
|
||||
@ -48,20 +48,20 @@ object NavigationHelper {
|
||||
*/
|
||||
fun navigateVideo(
|
||||
context: Context,
|
||||
videoId: String?,
|
||||
videoUrlOrId: String?,
|
||||
playlistId: String? = null,
|
||||
channelId: String? = null,
|
||||
keepQueue: Boolean = false,
|
||||
timestamp: Long = 0,
|
||||
forceVideo: Boolean = false
|
||||
) {
|
||||
if (videoId == null) return
|
||||
if (videoUrlOrId == null) return
|
||||
BackgroundHelper.stopBackgroundPlay(context)
|
||||
|
||||
if (PreferenceHelper.getBoolean(PreferenceKeys.AUDIO_ONLY_MODE, false) && !forceVideo) {
|
||||
BackgroundHelper.playOnBackground(
|
||||
context,
|
||||
videoId.toID(),
|
||||
videoUrlOrId.toID(),
|
||||
timestamp,
|
||||
playlistId,
|
||||
channelId,
|
||||
@ -73,7 +73,7 @@ object NavigationHelper {
|
||||
return
|
||||
}
|
||||
|
||||
val playerData = PlayerData(videoId.toID(), playlistId, channelId, keepQueue, timestamp)
|
||||
val playerData = PlayerData(videoUrlOrId.toID(), playlistId, channelId, keepQueue, timestamp)
|
||||
val bundle = bundleOf(IntentData.playerData to playerData)
|
||||
|
||||
val activity = ContextHelper.unwrapActivity(context)
|
||||
@ -82,11 +82,11 @@ object NavigationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun navigatePlaylist(context: Context, playlistId: String?, playlistType: PlaylistType) {
|
||||
if (playlistId == null) return
|
||||
fun navigatePlaylist(context: Context, playlistUrlOrId: String?, playlistType: PlaylistType) {
|
||||
if (playlistUrlOrId == null) return
|
||||
|
||||
val activity = ContextHelper.unwrapActivity(context)
|
||||
activity.navController.navigate(NavDirections.openPlaylist(playlistId, playlistType))
|
||||
activity.navController.navigate(NavDirections.openPlaylist(playlistUrlOrId.toID(), playlistType))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,7 +415,7 @@ class MainActivity : BaseActivity() {
|
||||
intent?.getStringExtra(IntentData.videoId)?.let {
|
||||
NavigationHelper.navigateVideo(
|
||||
context = this,
|
||||
videoId = it,
|
||||
videoUrlOrId = it,
|
||||
timestamp = intent.getLongExtra(IntentData.timeStamp, 0L)
|
||||
)
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import com.github.libretube.api.obj.Comment
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.databinding.CommentsRowBinding
|
||||
import com.github.libretube.extensions.formatShort
|
||||
import com.github.libretube.extensions.toID
|
||||
import com.github.libretube.helpers.ClipboardHelper
|
||||
import com.github.libretube.helpers.ImageHelper
|
||||
import com.github.libretube.helpers.NavigationHelper
|
||||
|
@ -35,10 +35,7 @@ class LegacySubscriptionAdapter(
|
||||
channelAvatar
|
||||
)
|
||||
root.setOnClickListener {
|
||||
NavigationHelper.navigateChannel(
|
||||
root.context,
|
||||
subscription.url.toID()
|
||||
)
|
||||
NavigationHelper.navigateChannel(root.context, subscription.url)
|
||||
}
|
||||
|
||||
root.setOnLongClickListener {
|
||||
|
@ -105,7 +105,7 @@ class PlaylistAdapter(
|
||||
|
||||
if (!streamItem.uploaderUrl.isNullOrBlank()) {
|
||||
videoInfo.setOnClickListener {
|
||||
NavigationHelper.navigateChannel(root.context, streamItem.uploaderUrl.toID())
|
||||
NavigationHelper.navigateChannel(root.context, streamItem.uploaderUrl)
|
||||
}
|
||||
// add some extra padding to make it easier to click
|
||||
val extraPadding = 3f.dpToPx()
|
||||
|
@ -29,13 +29,14 @@ class SubscriptionGroupChannelsAdapter(
|
||||
|
||||
override fun onBindViewHolder(holder: SubscriptionGroupChannelRowViewHolder, position: Int) {
|
||||
val channel = channels[position]
|
||||
val channelId = channel.url.toID()
|
||||
holder.binding.apply {
|
||||
root.setOnClickListener {
|
||||
NavigationHelper.navigateChannel(root.context, channelId)
|
||||
NavigationHelper.navigateChannel(root.context, channel.url)
|
||||
}
|
||||
subscriptionChannelName.text = channel.name
|
||||
ImageHelper.loadImage(channel.avatar, subscriptionChannelImage)
|
||||
|
||||
val channelId = channel.url.toID()
|
||||
channelIncluded.setOnCheckedChangeListener(null)
|
||||
channelIncluded.isChecked = group.channels.contains(channelId)
|
||||
channelIncluded.setOnCheckedChangeListener { _, isChecked ->
|
||||
|
@ -163,7 +163,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
||||
killFragment()
|
||||
NavigationHelper.navigateVideo(
|
||||
context = requireContext(),
|
||||
videoId = PlayingQueue.getCurrent()?.url?.toID(),
|
||||
videoUrlOrId = PlayingQueue.getCurrent()?.url,
|
||||
timestamp = playerService?.player?.currentPosition?.div(1000) ?: 0,
|
||||
keepQueue = true,
|
||||
forceVideo = true
|
||||
|
@ -61,8 +61,10 @@ class ChannelFragment : DynamicLayoutManagerFragment() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
channelId = args.channelId?.toID()
|
||||
channelName = args.channelName?.replace("/c/", "")?.replace("/user/", "")
|
||||
channelName = args.channelName
|
||||
?.replace("/c/", "")
|
||||
?.replace("/user/", "")
|
||||
channelId = args.channelId
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
@ -200,7 +200,7 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
||||
NavigationHelper.navigateVideo(
|
||||
requireContext(),
|
||||
response.relatedStreams.first().url?.toID(),
|
||||
response.relatedStreams.first().url,
|
||||
playlistId
|
||||
)
|
||||
}
|
||||
@ -230,7 +230,7 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
||||
PlayingQueue.add(*queue.toTypedArray())
|
||||
NavigationHelper.navigateVideo(
|
||||
requireContext(),
|
||||
queue.first().url?.toID(),
|
||||
queue.first().url,
|
||||
playlistId = playlistId,
|
||||
keepQueue = true
|
||||
)
|
||||
|
@ -212,8 +212,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment() {
|
||||
PlayingQueue.clear()
|
||||
PlayingQueue.add(*streams.toTypedArray())
|
||||
|
||||
val videoId = streams.first().url.orEmpty().toID()
|
||||
NavigationHelper.navigateVideo(requireContext(), videoId = videoId, keepQueue = true)
|
||||
NavigationHelper.navigateVideo(requireContext(), videoUrlOrId = streams.first().url, keepQueue = true)
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
|
@ -34,7 +34,7 @@ class DownloadOptionsBottomSheet : BaseBottomSheet() {
|
||||
}
|
||||
|
||||
R.string.go_to_video -> {
|
||||
NavigationHelper.navigateVideo(requireContext(), videoId = videoId)
|
||||
NavigationHelper.navigateVideo(requireContext(), videoUrlOrId = videoId)
|
||||
}
|
||||
|
||||
R.string.share -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user