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