adding a fastscroller to albums

This commit is contained in:
tibbi 2020-10-18 21:05:09 +02:00
parent d27dc984c3
commit 15fd2e03e5
4 changed files with 27 additions and 4 deletions

View file

@ -59,7 +59,7 @@ class AlbumsActivity : SimpleActivity() {
listItems.addAll(tracksToAdd)
runOnUiThread {
AlbumsAdapter(this, listItems, albums_list) {
val adapter = AlbumsAdapter(this, listItems, albums_list, albums_fastscroller) {
if (it is Album) {
Intent(this, TracksActivity::class.java).apply {
putExtra(ALBUM, Gson().toJson(it))
@ -77,6 +77,15 @@ class AlbumsActivity : SimpleActivity() {
}.apply {
albums_list.adapter = this
}
albums_fastscroller.setViews(albums_list) {
val item = adapter.items.getOrNull(it)
if (item is Track) {
albums_fastscroller.updateBubbleText(item.title)
} else if (item is Album) {
albums_fastscroller.updateBubbleText(item.title)
}
}
}
}

View file

@ -13,6 +13,7 @@ import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.getFormattedDuration
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
@ -28,8 +29,8 @@ import kotlinx.android.synthetic.main.item_song.view.*
import java.util.*
// we show both albums and individual tracks here
class AlbumsAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
class AlbumsAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, fastScroller: FastScroller,
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private val ITEM_SECTION = 0
private val ITEM_ALBUM = 1

View file

@ -26,6 +26,7 @@ import java.util.*
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 {

View file

@ -9,10 +9,22 @@
android:id="@+id/albums_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:layout_above="@+id/current_track_bar"
android:clipToPadding="false"
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
<com.simplemobiletools.commons.views.FastScroller
android:id="@+id/albums_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"