home: hide tabs when there is only one
Hide the tab selector when there is only one tab. This is mostly to remove a redundant UI element that has no purpose when only one list is shown.
This commit is contained in:
parent
28feebcec3
commit
61839405ce
2 changed files with 11 additions and 5 deletions
|
@ -21,6 +21,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.iterator
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
|
@ -56,8 +57,6 @@ import org.oxycblt.auxio.util.unlikelyToBeNull
|
|||
* The main "Launching Point" fragment of Auxio, allowing navigation to the detail views for each
|
||||
* respective item.
|
||||
* @author OxygenCobalt
|
||||
*
|
||||
* TODO: Make tabs invisible when there is only one
|
||||
*/
|
||||
class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuItemClickListener {
|
||||
private val playbackModel: PlaybackViewModel by activityViewModels()
|
||||
|
@ -75,6 +74,8 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
|
|||
setOnMenuItemClickListener(this@HomeFragment)
|
||||
}
|
||||
|
||||
updateTabConfiguration()
|
||||
|
||||
binding.homePager.apply {
|
||||
adapter = HomePagerAdapter()
|
||||
|
||||
|
@ -224,10 +225,17 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
|
|||
private fun handleRecreateTabs(recreate: Boolean) {
|
||||
if (recreate) {
|
||||
requireBinding().homePager.recreate()
|
||||
updateTabConfiguration()
|
||||
homeModel.finishRecreateTabs()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTabConfiguration() {
|
||||
if (homeModel.tabs.size == 1) {
|
||||
requireBinding().homeTabs.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleLoaderResponse(response: MusicStore.Response?) {
|
||||
val binding = requireBinding()
|
||||
when (response) {
|
||||
|
|
|
@ -91,9 +91,7 @@ class HomeViewModel : ViewModel(), SettingsManager.Callback, MusicStore.Callback
|
|||
_shouldRecreateTabs.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specific sort for the given [DisplayMode].
|
||||
*/
|
||||
/** Get the specific sort for the given [DisplayMode]. */
|
||||
fun getSortForDisplay(displayMode: DisplayMode): Sort {
|
||||
return when (displayMode) {
|
||||
DisplayMode.SHOW_SONGS -> settingsManager.libSongSort
|
||||
|
|
Loading…
Reference in a new issue