Fixed invisible bottom navbar sometimes and a crash
This commit is contained in:
parent
c2647b9160
commit
9b376a2f4f
4 changed files with 13 additions and 8 deletions
|
@ -26,6 +26,7 @@ import androidx.navigation.ui.setupWithNavController
|
|||
import code.name.monkey.retromusic.*
|
||||
import code.name.monkey.retromusic.activities.base.AbsCastActivity
|
||||
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
|
||||
import code.name.monkey.retromusic.extensions.currentFragment
|
||||
import code.name.monkey.retromusic.extensions.extra
|
||||
import code.name.monkey.retromusic.extensions.findNavController
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
||||
|
@ -91,9 +92,7 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
getBottomNavigationView().setupWithNavController(navController)
|
||||
// Scroll Fragment to top
|
||||
getBottomNavigationView().setOnItemReselectedListener {
|
||||
supportFragmentManager.findFragmentById(R.id.fragment_container)?.childFragmentManager?.fragments?.get(
|
||||
0
|
||||
)
|
||||
currentFragment(R.id.fragment_container)
|
||||
.also {
|
||||
if (it is AbsRecyclerViewFragment<*, *>) {
|
||||
it.scrollToTop()
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.activities.base
|
||||
|
||||
import android.animation.Animator
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -65,6 +66,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
|
||||
private var windowInsets: WindowInsetsCompat? = null
|
||||
private var bottomNavAnimator: Animator? = null
|
||||
protected val libraryViewModel by viewModel<LibraryViewModel>()
|
||||
private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<FrameLayout>
|
||||
private var playerFragment: AbsPlayerFragment? = null
|
||||
|
@ -274,8 +276,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
|
||||
fun setBottomBarVisibility(visible: Boolean) {
|
||||
bottomNavAnimator?.end()
|
||||
if (!(visible && binding.bottomNavigationView.isVisible)) {
|
||||
if (visible) {
|
||||
bottomNavAnimator = if (visible) {
|
||||
binding.bottomNavigationView.translateYAnimate(0F)
|
||||
} else {
|
||||
binding.bottomNavigationView.translateYAnimate(dip(R.dimen.bottom_nav_height).toFloat())
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
|
@ -63,8 +64,8 @@ fun EditText.appHandleColor(): EditText {
|
|||
return this
|
||||
}
|
||||
|
||||
fun View.translateYAnimate(value: Float) {
|
||||
ObjectAnimator.ofFloat(this, "translationY", value)
|
||||
fun View.translateYAnimate(value: Float): Animator {
|
||||
return ObjectAnimator.ofFloat(this, "translationY", value)
|
||||
.apply {
|
||||
duration = 300
|
||||
doOnStart {
|
||||
|
|
|
@ -327,8 +327,10 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
}
|
||||
|
||||
private fun setColors(color: Int) {
|
||||
binding.fragmentAlbumContent.shuffleAction.applyColor(color)
|
||||
binding.fragmentAlbumContent.playAction.applyOutlineColor(color)
|
||||
_binding?.fragmentAlbumContent?.apply {
|
||||
shuffleAction.applyColor(color)
|
||||
playAction.applyOutlineColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAlbumClick(albumId: Long, view: View) {
|
||||
|
|
Loading…
Reference in a new issue