mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
fix: back navigation from comment replies (#6954)
This commit is contained in:
parent
fc4055289e
commit
aef23e26e5
@ -4,6 +4,8 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.ComponentDialog
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.commit
|
||||
@ -20,6 +22,14 @@ class CommentsSheet : ExpandablePlayerSheet() {
|
||||
|
||||
private val commonPlayerViewModel: CommonPlayerViewModel by activityViewModels()
|
||||
|
||||
private val backPressedCallback by lazy(LazyThreadSafetyMode.NONE) {
|
||||
(dialog as ComponentDialog?)?.onBackPressedDispatcher?.addCallback(owner = viewLifecycleOwner, enabled = false) {
|
||||
if (childFragmentManager.backStackEntryCount > 0) {
|
||||
childFragmentManager.popBackStack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@ -70,6 +80,7 @@ class CommentsSheet : ExpandablePlayerSheet() {
|
||||
fun updateFragmentInfo(showBackButton: Boolean, title: String) {
|
||||
binding.btnBack.isVisible = showBackButton
|
||||
binding.commentsTitle.text = title
|
||||
backPressedCallback?.isEnabled = showBackButton
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
Loading…
x
Reference in New Issue
Block a user