Promote Radios to stable!

This commit is contained in:
Antoine POPINEAU 2020-06-11 10:56:31 +02:00
parent 6dcd9afc31
commit eb97c3d4be
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
1 changed files with 16 additions and 40 deletions

View File

@ -5,23 +5,18 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter import androidx.fragment.app.FragmentPagerAdapter
import com.github.apognu.otter.R import com.github.apognu.otter.R
import com.github.apognu.otter.fragments.* import com.github.apognu.otter.fragments.*
import com.github.apognu.otter.utils.Settings
class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : FragmentPagerAdapter(manager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : FragmentPagerAdapter(manager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
var tabs = mutableListOf<Fragment>() var tabs = mutableListOf<Fragment>()
override fun getCount(): Int { override fun getCount() = 5
return if (Settings.areExperimentsEnabled()) 5 else 4
}
override fun getItem(position: Int): Fragment { override fun getItem(position: Int): Fragment {
tabs.getOrNull(position)?.let { tabs.getOrNull(position)?.let {
return it return it
} }
val fragment = val fragment = when (position) {
if (Settings.areExperimentsEnabled()) {
when (position) {
0 -> ArtistsFragment() 0 -> ArtistsFragment()
1 -> AlbumsGridFragment() 1 -> AlbumsGridFragment()
2 -> PlaylistsFragment() 2 -> PlaylistsFragment()
@ -29,15 +24,6 @@ class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : Fragm
4 -> FavoritesFragment() 4 -> FavoritesFragment()
else -> ArtistsFragment() else -> ArtistsFragment()
} }
} else {
when (position) {
0 -> ArtistsFragment()
1 -> AlbumsGridFragment()
2 -> PlaylistsFragment()
3 -> FavoritesFragment()
else -> ArtistsFragment()
}
}
tabs.add(position, fragment) tabs.add(position, fragment)
@ -45,8 +31,7 @@ class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : Fragm
} }
override fun getPageTitle(position: Int): String { override fun getPageTitle(position: Int): String {
return if (Settings.areExperimentsEnabled()) { return when (position) {
when (position) {
0 -> context.getString(R.string.artists) 0 -> context.getString(R.string.artists)
1 -> context.getString(R.string.albums) 1 -> context.getString(R.string.albums)
2 -> context.getString(R.string.playlists) 2 -> context.getString(R.string.playlists)
@ -54,14 +39,5 @@ class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : Fragm
4 -> context.getString(R.string.favorites) 4 -> context.getString(R.string.favorites)
else -> "" else -> ""
} }
} else {
when (position) {
0 -> context.getString(R.string.artists)
1 -> context.getString(R.string.albums)
2 -> context.getString(R.string.playlists)
3 -> context.getString(R.string.favorites)
else -> ""
}
}
} }
} }