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,39 +5,25 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.github.apognu.otter.R
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) {
var tabs = mutableListOf<Fragment>()
override fun getCount(): Int {
return if (Settings.areExperimentsEnabled()) 5 else 4
}
override fun getCount() = 5
override fun getItem(position: Int): Fragment {
tabs.getOrNull(position)?.let {
return it
}
val fragment =
if (Settings.areExperimentsEnabled()) {
when (position) {
0 -> ArtistsFragment()
1 -> AlbumsGridFragment()
2 -> PlaylistsFragment()
3 -> RadiosFragment()
4 -> FavoritesFragment()
else -> ArtistsFragment()
}
} else {
when (position) {
0 -> ArtistsFragment()
1 -> AlbumsGridFragment()
2 -> PlaylistsFragment()
3 -> FavoritesFragment()
else -> ArtistsFragment()
}
}
val fragment = when (position) {
0 -> ArtistsFragment()
1 -> AlbumsGridFragment()
2 -> PlaylistsFragment()
3 -> RadiosFragment()
4 -> FavoritesFragment()
else -> ArtistsFragment()
}
tabs.add(position, fragment)
@ -45,23 +31,13 @@ class BrowseTabsAdapter(val context: Fragment, manager: FragmentManager) : Fragm
}
override fun getPageTitle(position: Int): String {
return if (Settings.areExperimentsEnabled()) {
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.radios)
4 -> context.getString(R.string.favorites)
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 -> ""
}
return 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.radios)
4 -> context.getString(R.string.favorites)
else -> ""
}
}
}