Browse Source

Promote Radios to stable!

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
eb97c3d4be
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 56
      app/src/main/java/com/github/apognu/otter/adapters/BrowseTabsAdapter.kt

56
app/src/main/java/com/github/apognu/otter/adapters/BrowseTabsAdapter.kt

@ -5,39 +5,25 @@ import androidx.fragment.app.FragmentManager @@ -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 @@ -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 -> ""
}
}
}
Loading…
Cancel
Save