adding a fastscroller to the artists screen
This commit is contained in:
parent
118f9fa72d
commit
dee5850878
3 changed files with 24 additions and 3 deletions
|
@ -12,6 +12,7 @@ import com.bumptech.glide.request.RequestOptions
|
|||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SimpleActivity
|
||||
|
@ -23,8 +24,8 @@ import com.simplemobiletools.musicplayer.models.Track
|
|||
import kotlinx.android.synthetic.main.item_artist.view.*
|
||||
import java.util.*
|
||||
|
||||
class ArtistsAdapter(activity: SimpleActivity, val artists: ArrayList<Artist>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||
class ArtistsAdapter(activity: SimpleActivity, val artists: ArrayList<Artist>, recyclerView: MyRecyclerView, fastScroller: FastScroller?, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
private val placeholder = resources.getColoredDrawableWithColor(R.drawable.ic_headset_padded, textColor)
|
||||
|
||||
init {
|
||||
|
|
|
@ -18,7 +18,7 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
override fun setupFragment(activity: SimpleActivity) {
|
||||
activity.getArtists { artists ->
|
||||
activity.runOnUiThread {
|
||||
ArtistsAdapter(activity, artists, artists_list) {
|
||||
val adapter = ArtistsAdapter(activity, artists, artists_list, artists_fastscroller) {
|
||||
Intent(activity, AlbumsActivity::class.java).apply {
|
||||
putExtra(ARTIST, Gson().toJson(it as Artist))
|
||||
activity.startActivity(this)
|
||||
|
@ -26,8 +26,16 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
}.apply {
|
||||
artists_list.adapter = this
|
||||
}
|
||||
|
||||
artists_fastscroller.setViews(artists_list) {
|
||||
val artist = adapter.artists.getOrNull(it)
|
||||
artists_fastscroller.updateBubbleText(artist?.title ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artists_fastscroller.updatePrimaryColor()
|
||||
artists_fastscroller.updateBubbleColors()
|
||||
}
|
||||
|
||||
override fun finishActMode() {
|
||||
|
|
|
@ -12,4 +12,16 @@
|
|||
android:clipToPadding="false"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
android:id="@+id/artists_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/breadcrumbs"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
|
||||
</com.simplemobiletools.musicplayer.fragments.ArtistsFragment>
|
||||
|
|
Loading…
Reference in a new issue