Fixed invisible bottom navbar sometimes and a crash

This commit is contained in:
Prathamesh More 2021-10-13 16:53:53 +05:30
parent c2647b9160
commit 9b376a2f4f
4 changed files with 13 additions and 8 deletions

View file

@ -26,6 +26,7 @@ import androidx.navigation.ui.setupWithNavController
import code.name.monkey.retromusic.* import code.name.monkey.retromusic.*
import code.name.monkey.retromusic.activities.base.AbsCastActivity import code.name.monkey.retromusic.activities.base.AbsCastActivity
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding 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.extra
import code.name.monkey.retromusic.extensions.findNavController import code.name.monkey.retromusic.extensions.findNavController
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
@ -91,9 +92,7 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
getBottomNavigationView().setupWithNavController(navController) getBottomNavigationView().setupWithNavController(navController)
// Scroll Fragment to top // Scroll Fragment to top
getBottomNavigationView().setOnItemReselectedListener { getBottomNavigationView().setOnItemReselectedListener {
supportFragmentManager.findFragmentById(R.id.fragment_container)?.childFragmentManager?.fragments?.get( currentFragment(R.id.fragment_container)
0
)
.also { .also {
if (it is AbsRecyclerViewFragment<*, *>) { if (it is AbsRecyclerViewFragment<*, *>) {
it.scrollToTop() it.scrollToTop()

View file

@ -14,6 +14,7 @@
*/ */
package code.name.monkey.retromusic.activities.base package code.name.monkey.retromusic.activities.base
import android.animation.Animator
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -65,6 +66,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
} }
private var windowInsets: WindowInsetsCompat? = null private var windowInsets: WindowInsetsCompat? = null
private var bottomNavAnimator: Animator? = null
protected val libraryViewModel by viewModel<LibraryViewModel>() protected val libraryViewModel by viewModel<LibraryViewModel>()
private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<FrameLayout> private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<FrameLayout>
private var playerFragment: AbsPlayerFragment? = null private var playerFragment: AbsPlayerFragment? = null
@ -274,8 +276,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
} }
fun setBottomBarVisibility(visible: Boolean) { fun setBottomBarVisibility(visible: Boolean) {
bottomNavAnimator?.end()
if (!(visible && binding.bottomNavigationView.isVisible)) { if (!(visible && binding.bottomNavigationView.isVisible)) {
if (visible) { bottomNavAnimator = if (visible) {
binding.bottomNavigationView.translateYAnimate(0F) binding.bottomNavigationView.translateYAnimate(0F)
} else { } else {
binding.bottomNavigationView.translateYAnimate(dip(R.dimen.bottom_nav_height).toFloat()) binding.bottomNavigationView.translateYAnimate(dip(R.dimen.bottom_nav_height).toFloat())

View file

@ -14,6 +14,7 @@
*/ */
package code.name.monkey.retromusic.extensions package code.name.monkey.retromusic.extensions
import android.animation.Animator
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
@ -63,8 +64,8 @@ fun EditText.appHandleColor(): EditText {
return this return this
} }
fun View.translateYAnimate(value: Float) { fun View.translateYAnimate(value: Float): Animator {
ObjectAnimator.ofFloat(this, "translationY", value) return ObjectAnimator.ofFloat(this, "translationY", value)
.apply { .apply {
duration = 300 duration = 300
doOnStart { doOnStart {

View file

@ -327,8 +327,10 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
} }
private fun setColors(color: Int) { private fun setColors(color: Int) {
binding.fragmentAlbumContent.shuffleAction.applyColor(color) _binding?.fragmentAlbumContent?.apply {
binding.fragmentAlbumContent.playAction.applyOutlineColor(color) shuffleAction.applyColor(color)
playAction.applyOutlineColor(color)
}
} }
override fun onAlbumClick(albumId: Long, view: View) { override fun onAlbumClick(albumId: Long, view: View) {