fix: Implement onBackPressedDispatcher in AbsSlidingMusicPanelActivity
This commit is contained in:
parent
9f334c09b2
commit
c6dd54d200
1 changed files with 10 additions and 4 deletions
|
@ -26,6 +26,7 @@ import android.view.ViewGroup
|
|||
import android.view.ViewTreeObserver
|
||||
import android.view.animation.PathInterpolator
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isGone
|
||||
|
@ -217,6 +218,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
bottomSheetBehavior = from(binding.slidingPanel)
|
||||
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||
bottomSheetBehavior.isHideable = PreferenceUtil.swipeDownToDismiss
|
||||
bottomSheetBehavior.significantVelocityThreshold = 300
|
||||
setMiniPlayerAlphaProgress(0F)
|
||||
}
|
||||
|
||||
|
@ -229,6 +231,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
if (bottomSheetBehavior.state == STATE_EXPANDED) {
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (!handleBackPress()) {
|
||||
remove()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -392,10 +402,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (!handleBackPress()) super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun handleBackPress(): Boolean {
|
||||
if (bottomSheetBehavior.peekHeight != 0 && playerFragment.onBackPressed()) return true
|
||||
if (panelState == STATE_EXPANDED) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue