mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
fix the abnormal channel behavior
This commit is contained in:
parent
977acaefbf
commit
a3a87780ad
@ -12,35 +12,36 @@ import com.github.libretube.constants.IntentData
|
|||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.ui.activities.MainActivity
|
import com.github.libretube.ui.activities.MainActivity
|
||||||
import com.github.libretube.ui.fragments.PlayerFragment
|
import com.github.libretube.ui.fragments.PlayerFragment
|
||||||
|
import com.github.libretube.ui.views.SingleViewTouchableMotionLayout
|
||||||
|
|
||||||
object NavigationHelper {
|
object NavigationHelper {
|
||||||
fun navigateChannel(
|
fun navigateChannel(
|
||||||
context: Context,
|
context: Context,
|
||||||
channelId: String?
|
channelId: String?
|
||||||
) {
|
) {
|
||||||
if (channelId != null) {
|
if (channelId == null) return
|
||||||
|
|
||||||
val activity = context as MainActivity
|
val activity = context as MainActivity
|
||||||
val bundle = bundleOf(IntentData.channelId to channelId)
|
val bundle = bundleOf(IntentData.channelId to channelId)
|
||||||
activity.navController.navigate(R.id.channelFragment, bundle)
|
activity.navController.navigate(R.id.channelFragment, bundle)
|
||||||
try {
|
try {
|
||||||
if (activity.binding.mainMotionLayout.progress == 0.toFloat()) {
|
if (activity.binding.mainMotionLayout.progress == 0.toFloat()) {
|
||||||
activity.binding.mainMotionLayout.transitionToEnd()
|
activity.binding.mainMotionLayout.transitionToEnd()
|
||||||
activity.supportFragmentManager.fragments.forEach {
|
activity.findViewById<SingleViewTouchableMotionLayout>(R.id.playerMotionLayout)
|
||||||
(it as PlayerFragment?)?.binding?.playerMotionLayout?.transitionToEnd()
|
.transitionToEnd()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun navigateVideo(
|
fun navigateVideo(
|
||||||
context: Context,
|
context: Context,
|
||||||
videoId: String?,
|
videoId: String?,
|
||||||
playlistId: String? = null
|
playlistId: String? = null
|
||||||
) {
|
) {
|
||||||
if (videoId != null) {
|
if (videoId == null) return
|
||||||
|
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(IntentData.videoId, videoId.toID())
|
bundle.putString(IntentData.videoId, videoId.toID())
|
||||||
if (playlistId != null) bundle.putString(IntentData.playlistId, playlistId)
|
if (playlistId != null) bundle.putString(IntentData.playlistId, playlistId)
|
||||||
@ -54,21 +55,20 @@ object NavigationHelper {
|
|||||||
.replace(R.id.container, frag)
|
.replace(R.id.container, frag)
|
||||||
.commitNow()
|
.commitNow()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun navigatePlaylist(
|
fun navigatePlaylist(
|
||||||
context: Context,
|
context: Context,
|
||||||
playlistId: String?,
|
playlistId: String?,
|
||||||
isOwner: Boolean
|
isOwner: Boolean
|
||||||
) {
|
) {
|
||||||
if (playlistId != null) {
|
if (playlistId == null) return
|
||||||
|
|
||||||
val activity = context as MainActivity
|
val activity = context as MainActivity
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString(IntentData.playlistId, playlistId)
|
bundle.putString(IntentData.playlistId, playlistId)
|
||||||
bundle.putBoolean("isOwner", isOwner)
|
bundle.putBoolean("isOwner", isOwner)
|
||||||
activity.navController.navigate(R.id.playlistFragment, bundle)
|
activity.navController.navigate(R.id.playlistFragment, bundle)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Needed due to different MainActivity Aliases because of the app icons
|
* Needed due to different MainActivity Aliases because of the app icons
|
||||||
|
Loading…
Reference in New Issue
Block a user