Code cleanup
This commit is contained in:
parent
5ee9c04924
commit
9d93d700be
6 changed files with 21 additions and 31 deletions
|
@ -89,9 +89,9 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
)
|
||||
}
|
||||
navController.graph = navGraph
|
||||
getBottomNavigationView().setupWithNavController(navController)
|
||||
bottomNavigationView.setupWithNavController(navController)
|
||||
// Scroll Fragment to top
|
||||
getBottomNavigationView().setOnItemReselectedListener {
|
||||
bottomNavigationView.setOnItemReselectedListener {
|
||||
currentFragment(R.id.fragment_container)
|
||||
.also {
|
||||
if (it is AbsRecyclerViewFragment<*, *>) {
|
||||
|
@ -118,7 +118,6 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
}
|
||||
else -> setBottomNavVisibility(visible = false, animate = true) // Hide Bottom Navigation Bar
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.model.CategoryInfo
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
|
@ -103,7 +102,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
STATE_SETTLING, STATE_DRAGGING -> {
|
||||
if (fromNotification) {
|
||||
getBottomNavigationView().isVisible = true
|
||||
bottomNavigationView.isVisible = true
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
@ -125,7 +124,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
windowInsets = insets
|
||||
insets
|
||||
}
|
||||
binding.bottomNavigationView.drawAboveSystemBarsWithPadding()
|
||||
bottomNavigationView.drawAboveSystemBarsWithPadding()
|
||||
if (RetroUtil.isLandscape()) {
|
||||
binding.slidingPanel.drawAboveSystemBarsWithPadding(true)
|
||||
}
|
||||
|
@ -214,9 +213,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
})
|
||||
}
|
||||
|
||||
fun getBottomNavigationView(): BottomNavigationView {
|
||||
return binding.bottomNavigationView
|
||||
}
|
||||
val bottomNavigationView get() = binding.bottomNavigationView
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
|
@ -357,7 +354,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomSheetBehavior.peekHeightAnimate(heightOfBar)
|
||||
bottomNavAnimator?.end()
|
||||
bottomNavAnimator =
|
||||
getBottomNavigationView().translateYAnimate(dip(R.dimen.bottom_nav_height).toFloat())
|
||||
bottomNavigationView.translateYAnimate(dip(R.dimen.bottom_nav_height).toFloat())
|
||||
bottomNavAnimator?.doOnEnd {
|
||||
binding.slidingPanel.bringToFront()
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ abstract class AbsRecyclerViewCustomGridSizeFragment<A : RecyclerView.Adapter<*>
|
|||
} else {
|
||||
saveGridSize(gridSize)
|
||||
}
|
||||
recyclerView().isVisible = false
|
||||
recyclerView.isVisible = false
|
||||
invalidateLayoutManager()
|
||||
// only recreate the adapter and layout manager if the layout currentLayoutRes has changed
|
||||
if (oldLayoutRes != itemLayoutRes()) {
|
||||
|
@ -95,10 +95,10 @@ abstract class AbsRecyclerViewCustomGridSizeFragment<A : RecyclerView.Adapter<*>
|
|||
setGridSize(gridSize)
|
||||
}
|
||||
val transition = MaterialFade().apply {
|
||||
addTarget(recyclerView())
|
||||
addTarget(recyclerView)
|
||||
}
|
||||
TransitionManager.beginDelayedTransition(getContainer(), transition)
|
||||
recyclerView().isVisible = true
|
||||
TransitionManager.beginDelayedTransition(container, transition)
|
||||
recyclerView.isVisible = true
|
||||
}
|
||||
|
||||
protected abstract fun setGridSize(gridSize: Int)
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.view.*
|
|||
import androidx.annotation.NonNull
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
|
@ -57,7 +56,6 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
_binding = FragmentMainRecyclerBinding.bind(view)
|
||||
postponeEnterTransition()
|
||||
view.doOnPreDraw { startPostponedEnterTransition() }
|
||||
|
||||
mainActivity.setSupportActionBar(binding.toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
initLayoutManager()
|
||||
|
@ -198,16 +196,12 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
binding.recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
fun recyclerView(): RecyclerView {
|
||||
return binding.recyclerView
|
||||
}
|
||||
val recyclerView get() = binding.recyclerView
|
||||
|
||||
fun getContainer(): CoordinatorLayout {
|
||||
return binding.root
|
||||
}
|
||||
val container get() = binding.root
|
||||
|
||||
fun scrollToTop() {
|
||||
recyclerView().scrollToPosition(0)
|
||||
recyclerView.scrollToPosition(0)
|
||||
binding.appBarLayout.setExpanded(true, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
|
|||
navGraph.setStartDestination(categoryInfo.category.id)
|
||||
}
|
||||
navController.graph = navGraph
|
||||
NavigationUI.setupWithNavController(mainActivity.getBottomNavigationView(), navController)
|
||||
NavigationUI.setupWithNavController(mainActivity.bottomNavigationView, navController)
|
||||
navController.addOnDestinationChangedListener { _, _, _ ->
|
||||
binding.appBarLayout.setExpanded(true, true)
|
||||
}
|
||||
|
|
|
@ -70,12 +70,12 @@ class PlayingQueueRVFragment : AbsRecyclerViewFragment<PlayingQueueAdapter, Line
|
|||
recyclerViewDragDropManager?.createWrappedAdapter(adapter!!) as RecyclerView.Adapter<*>
|
||||
wrappedAdapter =
|
||||
recyclerViewSwipeManager?.createWrappedAdapter(wrappedAdapter) as RecyclerView.Adapter<*>
|
||||
recyclerView().layoutManager = layoutManager
|
||||
recyclerView().adapter = wrappedAdapter
|
||||
recyclerView().itemAnimator = animator
|
||||
recyclerViewTouchActionGuardManager?.attachRecyclerView(recyclerView())
|
||||
recyclerViewDragDropManager?.attachRecyclerView(recyclerView())
|
||||
recyclerViewSwipeManager?.attachRecyclerView(recyclerView())
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = wrappedAdapter
|
||||
recyclerView.itemAnimator = animator
|
||||
recyclerViewTouchActionGuardManager?.attachRecyclerView(recyclerView)
|
||||
recyclerViewDragDropManager?.attachRecyclerView(recyclerView)
|
||||
recyclerViewSwipeManager?.attachRecyclerView(recyclerView)
|
||||
|
||||
layoutManager?.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class PlayingQueueRVFragment : AbsRecyclerViewFragment<PlayingQueueAdapter, Line
|
|||
}
|
||||
|
||||
private fun resetToCurrentPosition() {
|
||||
recyclerView().stopScroll()
|
||||
recyclerView.stopScroll()
|
||||
layoutManager?.scrollToPositionWithOffset(MusicPlayerRemote.position + 1, 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue