Use constants when building BrowseFragmentAdapter.

This commit is contained in:
casey langen 2019-02-10 12:17:28 -08:00
parent fff7d83338
commit 7967502607

View File

@ -5,11 +5,13 @@ import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.view.ViewGroup
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.ui.albums.fragment.AlbumBrowseFragment
import io.casey.musikcube.remote.ui.category.constant.NavigationType
import io.casey.musikcube.remote.ui.category.fragment.CategoryBrowseFragment
import io.casey.musikcube.remote.ui.shared.activity.Filterable
import io.casey.musikcube.remote.ui.tracks.fragment.TrackListFragment
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
class BrowseFragmentAdapter(private val context: Context, fm: FragmentManager): FragmentPagerAdapter(fm) {
private val fragments = mutableMapOf<Int, Fragment>()
@ -26,19 +28,19 @@ class BrowseFragmentAdapter(private val context: Context, fm: FragmentManager):
when (index) {
0 -> AlbumBrowseFragment.create()
1 -> CategoryBrowseFragment.create(
CategoryBrowseFragment.arguments(context, "artist"))
CategoryBrowseFragment.arguments(context, Metadata.Category.ALBUM_ARTIST))
2 -> TrackListFragment.create()
else -> CategoryBrowseFragment.create(
CategoryBrowseFragment.arguments("playlists", NavigationType.Tracks))
CategoryBrowseFragment.arguments(Metadata.Category.PLAYLISTS, NavigationType.Tracks))
}
override fun getPageTitle(position: Int): CharSequence? =
when (position) {
0 -> "albums"
1 -> "artists"
2 -> "songs"
else -> "playlists"
}
context.getString(when (position) {
0 -> R.string.button_albums
1 -> R.string.button_artists
2 -> R.string.button_tracks
else -> R.string.button_playlists
})
override fun getCount(): Int {
return 4