Fixed fab bottom margin
This commit is contained in:
parent
a83879dffb
commit
541a6fffe5
8 changed files with 36 additions and 13 deletions
|
@ -23,6 +23,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -40,6 +41,7 @@ class LibraryViewModel(
|
|||
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
|
||||
private val genres = MutableLiveData<List<Genre>>()
|
||||
private val searchResults = MutableLiveData<List<Any>>()
|
||||
private val fabMargin = MutableLiveData(0)
|
||||
val paletteColor: LiveData<Int> = _paletteColor
|
||||
|
||||
init {
|
||||
|
@ -85,6 +87,10 @@ class LibraryViewModel(
|
|||
return home
|
||||
}
|
||||
|
||||
fun getFabMargin(): LiveData<Int> {
|
||||
return fabMargin
|
||||
}
|
||||
|
||||
private fun fetchSongs() {
|
||||
viewModelScope.launch(IO) {
|
||||
songs.postValue(repository.allSongs())
|
||||
|
@ -328,6 +334,14 @@ class LibraryViewModel(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setFabMargin(bottomMargin: Int) {
|
||||
fabMargin.postValue(
|
||||
// Normal Margin
|
||||
DensityUtil.dip2px(App.getContext(), 16F) +
|
||||
bottomMargin
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
enum class ReloadType {
|
||||
|
|
|
@ -22,6 +22,7 @@ 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
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -85,6 +86,11 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
} else {
|
||||
binding.shuffleButton.isVisible = false
|
||||
}
|
||||
libraryViewModel.getFabMargin().observe(viewLifecycleOwner, {
|
||||
binding.shuffleButton.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = it
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
open fun onShuffleClicked() {
|
||||
|
|
|
@ -52,7 +52,7 @@ class PlayingQueueFragment : AbsRecyclerViewFragment<PlayingQueueAdapter, Linear
|
|||
|
||||
private fun setupToolbar() {
|
||||
toolbar().apply {
|
||||
setOnClickListener {
|
||||
setNavigationOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
setNavigationIcon(R.drawable.ic_keyboard_backspace_black)
|
||||
|
|
|
@ -23,12 +23,10 @@ import android.speech.RecognizerIntent
|
|||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.CompoundButton
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.*
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.transition.TransitionManager
|
||||
|
@ -89,6 +87,11 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
view.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
}
|
||||
libraryViewModel.getFabMargin().observe(viewLifecycleOwner, {
|
||||
binding.keyboardPopup.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = it
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setupChips() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue