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