finally adding a fastscroller to tracks too

This commit is contained in:
tibbi 2020-10-18 21:11:15 +02:00
parent 15fd2e03e5
commit 15f003689f
3 changed files with 25 additions and 4 deletions

View file

@ -6,7 +6,6 @@ import android.os.Bundle
import android.view.Menu
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.helpers.AlphanumericComparator
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.adapters.SongsAdapter
@ -60,7 +59,7 @@ class TracksActivity : SimpleActivity() {
}
runOnUiThread {
SongsAdapter(this, listItems, tracks_list, album == null) {
val adapter = SongsAdapter(this, listItems, tracks_list, album == null, tracks_fastscroller) {
resetQueueItems(tracks) {
Intent(this, TrackActivity::class.java).apply {
putExtra(TRACK, Gson().toJson(it))
@ -71,6 +70,15 @@ class TracksActivity : SimpleActivity() {
}.apply {
tracks_list.adapter = this
}
tracks_fastscroller.setViews(tracks_list) {
val listItem = adapter.items.getOrNull(it)
if (listItem is Track) {
tracks_fastscroller.updateBubbleText(listItem.title)
} else if (listItem is AlbumHeader) {
tracks_fastscroller.updateBubbleText(listItem.title)
}
}
}
}

View file

@ -12,6 +12,7 @@ import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.getFormattedDuration
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 kotlinx.android.synthetic.main.item_album_header.view.*
import kotlinx.android.synthetic.main.item_song.view.*
import java.util.*
class SongsAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, val showAlbumCover: Boolean, itemClick: (Any) -> Unit) :
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
class SongsAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, val showAlbumCover: Boolean, fastScroller: FastScroller,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private val ITEM_HEADER = 0
private val ITEM_TRACK = 1

View file

@ -13,6 +13,18 @@
android:clipToPadding="false"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
<com.simplemobiletools.commons.views.FastScroller
android:id="@+id/tracks_fastscroller"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_above="@+id/current_track_bar"
android:layout_alignParentEnd="true"
android:paddingStart="@dimen/normal_margin">
<include layout="@layout/fastscroller_handle_vertical" />
</com.simplemobiletools.commons.views.FastScroller>
<include
layout="@layout/view_current_track_bar"
android:layout_width="match_parent"