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 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()) { 0 -> ArtistsFragment()
when (position) { 1 -> AlbumsGridFragment()
0 -> ArtistsFragment() 2 -> PlaylistsFragment()
1 -> AlbumsGridFragment() 3 -> RadiosFragment()
2 -> PlaylistsFragment() 4 -> FavoritesFragment()
3 -> RadiosFragment() else -> ArtistsFragment()
4 -> FavoritesFragment() }
else -> ArtistsFragment()
}
} else {
when (position) {
0 -> ArtistsFragment()
1 -> AlbumsGridFragment()
2 -> PlaylistsFragment()
3 -> FavoritesFragment()
else -> ArtistsFragment()
}
}
tabs.add(position, fragment) tabs.add(position, fragment)
@ -45,23 +31,13 @@ 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) 3 -> context.getString(R.string.radios)
3 -> context.getString(R.string.radios) 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 -> ""
}
} }
} }
} }