use the new fastscroller everywhere
This commit is contained in:
parent
491fc214b4
commit
e615abcac5
18 changed files with 145 additions and 175 deletions
|
@ -6,6 +6,8 @@ import android.view.Menu
|
|||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.extensions.getFormattedDuration
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.adapters.AlbumsTracksAdapter
|
||||
|
@ -24,7 +26,7 @@ import org.greenrobot.eventbus.EventBus
|
|||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
// Artists -> Albums -> Tracks
|
||||
// Artists -> Albums -> Tracks
|
||||
class AlbumsActivity : SimpleActivity() {
|
||||
private var bus: EventBus? = null
|
||||
|
||||
|
@ -35,6 +37,8 @@ class AlbumsActivity : SimpleActivity() {
|
|||
bus = EventBus.getDefault()
|
||||
bus!!.register(this)
|
||||
|
||||
albums_fastscroller.updateColors(getAdjustedPrimaryColor(), getAdjustedPrimaryColor().getContrastColor())
|
||||
|
||||
val artistType = object : TypeToken<Artist>() {}.type
|
||||
val artist = Gson().fromJson<Artist>(intent.getStringExtra(ARTIST), artistType)
|
||||
title = artist.title
|
||||
|
@ -60,7 +64,7 @@ class AlbumsActivity : SimpleActivity() {
|
|||
listItems.addAll(tracksToAdd)
|
||||
|
||||
runOnUiThread {
|
||||
val adapter = AlbumsTracksAdapter(this, listItems, albums_list, albums_fastscroller) {
|
||||
val adapter = AlbumsTracksAdapter(this, listItems, albums_list) {
|
||||
if (it is Album) {
|
||||
Intent(this, TracksActivity::class.java).apply {
|
||||
putExtra(ALBUM, Gson().toJson(it))
|
||||
|
@ -82,15 +86,6 @@ class AlbumsActivity : SimpleActivity() {
|
|||
if (areSystemAnimationsEnabled) {
|
||||
albums_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.os.Bundle
|
|||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.adapters.QueueAdapter
|
||||
|
@ -12,6 +14,7 @@ import com.simplemobiletools.musicplayer.dialogs.NewPlaylistDialog
|
|||
import com.simplemobiletools.musicplayer.helpers.PLAY_TRACK
|
||||
import com.simplemobiletools.musicplayer.helpers.RoomHelper
|
||||
import com.simplemobiletools.musicplayer.helpers.TRACK_ID
|
||||
import com.simplemobiletools.musicplayer.inlines.indexOfFirstOrNull
|
||||
import com.simplemobiletools.musicplayer.models.Events
|
||||
import com.simplemobiletools.musicplayer.models.Track
|
||||
import com.simplemobiletools.musicplayer.services.MusicService
|
||||
|
@ -30,6 +33,7 @@ class QueueActivity : SimpleActivity() {
|
|||
bus = EventBus.getDefault()
|
||||
bus!!.register(this)
|
||||
setupAdapter()
|
||||
queue_fastscroller.updateColors(getAdjustedPrimaryColor(), getAdjustedPrimaryColor().getContrastColor())
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -54,7 +58,7 @@ class QueueActivity : SimpleActivity() {
|
|||
private fun setupAdapter() {
|
||||
val adapter = queue_list.adapter
|
||||
if (adapter == null) {
|
||||
val queueAdapter = QueueAdapter(this, MusicService.mTracks, queue_list, queue_fastscroller) {
|
||||
QueueAdapter(this, MusicService.mTracks, queue_list) {
|
||||
Intent(this, MusicService::class.java).apply {
|
||||
action = PLAY_TRACK
|
||||
putExtra(TRACK_ID, (it as Track).mediaStoreId)
|
||||
|
@ -68,10 +72,11 @@ class QueueActivity : SimpleActivity() {
|
|||
queue_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
queue_fastscroller.setViews(queue_list) {
|
||||
val track = queueAdapter.items.getOrNull(it)
|
||||
queue_fastscroller.updateBubbleText(track?.title ?: "")
|
||||
val currentTrackPosition = MusicService.mTracks.indexOfFirstOrNull { it == MusicService.mCurrTrack } ?: -1
|
||||
if (currentTrackPosition > 0) {
|
||||
queue_list.smoothScrollToPosition(currentTrackPosition)
|
||||
}
|
||||
|
||||
} else {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@ import com.simplemobiletools.musicplayer.extensions.*
|
|||
import com.simplemobiletools.musicplayer.helpers.*
|
||||
import com.simplemobiletools.musicplayer.models.*
|
||||
import com.simplemobiletools.musicplayer.services.MusicService
|
||||
import kotlinx.android.synthetic.main.activity_queue.*
|
||||
import kotlinx.android.synthetic.main.activity_tracks.*
|
||||
import kotlinx.android.synthetic.main.view_current_track_bar.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
// Artists -> Albums -> Tracks
|
||||
// Artists -> Albums -> Tracks
|
||||
class TracksActivity : SimpleActivity() {
|
||||
private var bus: EventBus? = null
|
||||
private var playlist: Playlist? = null
|
||||
|
@ -48,8 +49,10 @@ class TracksActivity : SimpleActivity() {
|
|||
|
||||
title = playlist?.title ?: album.title
|
||||
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
tracks_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
|
||||
tracks_placeholder.setTextColor(config.textColor)
|
||||
tracks_placeholder_2.setTextColor(getAdjustedPrimaryColor())
|
||||
tracks_placeholder_2.setTextColor(adjustedPrimaryColor)
|
||||
tracks_placeholder_2.underlineText()
|
||||
tracks_placeholder_2.setOnClickListener {
|
||||
addFolderToPlaylist()
|
||||
|
@ -84,7 +87,7 @@ class TracksActivity : SimpleActivity() {
|
|||
itemClicked(it as Track)
|
||||
}
|
||||
} else {
|
||||
TracksHeaderAdapter(this, listItems, tracks_list, tracks_fastscroller) {
|
||||
TracksHeaderAdapter(this, listItems, tracks_list) {
|
||||
itemClicked(it as Track)
|
||||
}
|
||||
}
|
||||
|
@ -94,20 +97,6 @@ class TracksActivity : SimpleActivity() {
|
|||
if (areSystemAnimationsEnabled) {
|
||||
tracks_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
tracks_fastscroller.setViews(tracks_list) {
|
||||
val listItem = when (adapter) {
|
||||
is TracksAdapter -> adapter.tracks.getOrNull(it)
|
||||
is TracksHeaderAdapter -> adapter.items.getOrNull(it)
|
||||
else -> return@setViews
|
||||
}
|
||||
|
||||
if (listItem is Track) {
|
||||
tracks_fastscroller.updateBubbleText(listItem.title)
|
||||
} else if (listItem is AlbumHeader) {
|
||||
tracks_fastscroller.updateBubbleText(listItem.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
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
|
||||
|
@ -22,8 +22,8 @@ import com.simplemobiletools.musicplayer.models.Track
|
|||
import kotlinx.android.synthetic.main.item_album.view.*
|
||||
import java.util.*
|
||||
|
||||
class AlbumsAdapter(activity: SimpleActivity, var albums: ArrayList<Album>, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class AlbumsAdapter(activity: SimpleActivity, var albums: ArrayList<Album>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private var textToHighlight = ""
|
||||
private val placeholderBig = resources.getColoredDrawableWithColor(R.drawable.ic_headset, textColor)
|
||||
|
@ -165,4 +165,6 @@ class AlbumsAdapter(activity: SimpleActivity, var albums: ArrayList<Album>, recy
|
|||
.into(findViewById(R.id.album_image))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = albums.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
|
@ -14,7 +15,6 @@ 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
|
||||
|
@ -32,8 +32,10 @@ import kotlinx.android.synthetic.main.item_track.view.*
|
|||
import java.util.*
|
||||
|
||||
// we show both albums and individual tracks here
|
||||
class AlbumsTracksAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, fastScroller: FastScroller,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class AlbumsTracksAdapter(
|
||||
activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView,
|
||||
itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private val ITEM_SECTION = 0
|
||||
private val ITEM_ALBUM = 1
|
||||
|
@ -223,4 +225,13 @@ class AlbumsTracksAdapter(activity: SimpleActivity, val items: ArrayList<ListIte
|
|||
item_section.setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int): CharSequence {
|
||||
val listItem = items.getOrNull(position)
|
||||
return when (listItem) {
|
||||
is Track -> listItem.getBubbleText()
|
||||
is Album -> listItem.title
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
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
|
||||
|
@ -24,8 +24,8 @@ import com.simplemobiletools.musicplayer.models.Track
|
|||
import kotlinx.android.synthetic.main.item_artist.view.*
|
||||
import java.util.*
|
||||
|
||||
class ArtistsAdapter(activity: SimpleActivity, var artists: ArrayList<Artist>, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class ArtistsAdapter(activity: SimpleActivity, var artists: ArrayList<Artist>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private var textToHighlight = ""
|
||||
private val placeholder = resources.getColoredDrawableWithColor(R.drawable.ic_headset_padded, textColor)
|
||||
|
@ -181,4 +181,6 @@ class ArtistsAdapter(activity: SimpleActivity, var artists: ArrayList<Artist>, r
|
|||
.into(findViewById(R.id.artist_image))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = artists.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ package com.simplemobiletools.musicplayer.adapters
|
|||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.deleteFiles
|
||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
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 +23,9 @@ import kotlinx.android.synthetic.main.item_playlist.view.*
|
|||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
|
||||
class PlaylistsAdapter(activity: SimpleActivity, var playlists: ArrayList<Playlist>, recyclerView: MyRecyclerView, fastScroller: FastScroller,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class PlaylistsAdapter(
|
||||
activity: SimpleActivity, var playlists: ArrayList<Playlist>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private var textToHighlight = ""
|
||||
|
||||
|
@ -160,4 +161,6 @@ class PlaylistsAdapter(activity: SimpleActivity, var playlists: ArrayList<Playli
|
|||
playlist_tracks.setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = playlists.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
|
@ -19,7 +20,6 @@ import com.simplemobiletools.commons.extensions.getFormattedDuration
|
|||
import com.simplemobiletools.commons.interfaces.ItemMoveCallback
|
||||
import com.simplemobiletools.commons.interfaces.ItemTouchHelperContract
|
||||
import com.simplemobiletools.commons.interfaces.StartReorderDragListener
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SimpleActivity
|
||||
|
@ -35,8 +35,8 @@ import com.simplemobiletools.musicplayer.services.MusicService
|
|||
import kotlinx.android.synthetic.main.item_track_queue.view.*
|
||||
import java.util.*
|
||||
|
||||
class QueueAdapter(activity: SimpleActivity, val items: ArrayList<Track>, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick), ItemTouchHelperContract {
|
||||
class QueueAdapter(activity: SimpleActivity, val items: ArrayList<Track>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), ItemTouchHelperContract, RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private val placeholder = resources.getColoredDrawableWithColor(R.drawable.ic_headset, textColor)
|
||||
private var startReorderDragListener: StartReorderDragListener
|
||||
|
@ -187,4 +187,6 @@ class QueueAdapter(activity: SimpleActivity, val items: ArrayList<Track>, recycl
|
|||
override fun onRowClear(myViewHolder: ViewHolder?) {}
|
||||
|
||||
override fun onRowSelected(myViewHolder: ViewHolder?) {}
|
||||
|
||||
override fun onChange(position: Int) = items.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
|
@ -14,7 +15,6 @@ 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 +28,8 @@ import kotlinx.android.synthetic.main.item_album_header.view.*
|
|||
import kotlinx.android.synthetic.main.item_track.view.*
|
||||
import java.util.*
|
||||
|
||||
class TracksHeaderAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, fastScroller: FastScroller,
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class TracksHeaderAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private val ITEM_HEADER = 0
|
||||
private val ITEM_TRACK = 1
|
||||
|
@ -183,4 +183,13 @@ class TracksHeaderAdapter(activity: SimpleActivity, val items: ArrayList<ListIte
|
|||
.into(findViewById(R.id.album_image))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int): CharSequence {
|
||||
val listItem = items.getOrNull(position)
|
||||
return when (listItem) {
|
||||
is Track -> listItem.getBubbleText()
|
||||
is AlbumHeader -> listItem.title
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
|
||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SimpleActivity
|
||||
|
@ -54,7 +55,7 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
val adapter = albums_list.adapter
|
||||
if (adapter == null) {
|
||||
AlbumsAdapter(activity, albums, albums_list, albums_fastscroller) {
|
||||
AlbumsAdapter(activity, albums, albums_list) {
|
||||
Intent(activity, TracksActivity::class.java).apply {
|
||||
putExtra(ALBUM, Gson().toJson(it))
|
||||
activity.startActivity(this)
|
||||
|
@ -66,11 +67,6 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
if (context.areSystemAnimationsEnabled) {
|
||||
albums_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
albums_fastscroller.setViews(albums_list) {
|
||||
val album = (albums_list.adapter as AlbumsAdapter).albums.getOrNull(it)
|
||||
albums_fastscroller.updateBubbleText(album?.getBubbleText() ?: "")
|
||||
}
|
||||
} else {
|
||||
val oldItems = (adapter as AlbumsAdapter).albums
|
||||
if (oldItems.sortedBy { it.id }.hashCode() != albums.sortedBy { it.id }.hashCode()) {
|
||||
|
@ -132,7 +128,6 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
albums_placeholder.setTextColor(textColor)
|
||||
albums_fastscroller.updatePrimaryColor()
|
||||
albums_fastscroller.updateBubbleColors()
|
||||
albums_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
|||
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
|
||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.AlbumsActivity
|
||||
|
@ -51,7 +52,7 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
|
||||
val adapter = artists_list.adapter
|
||||
if (adapter == null) {
|
||||
ArtistsAdapter(activity, artists, artists_list, artists_fastscroller) {
|
||||
ArtistsAdapter(activity, artists, artists_list) {
|
||||
Intent(activity, AlbumsActivity::class.java).apply {
|
||||
putExtra(ARTIST, Gson().toJson(it as Artist))
|
||||
activity.startActivity(this)
|
||||
|
@ -63,11 +64,6 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
if (context.areSystemAnimationsEnabled) {
|
||||
artists_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
artists_fastscroller.setViews(artists_list) {
|
||||
val artist = (artists_list.adapter as ArtistsAdapter).artists.getOrNull(it)
|
||||
artists_fastscroller.updateBubbleText(artist?.getBubbleText() ?: "")
|
||||
}
|
||||
} else {
|
||||
val oldItems = (adapter as ArtistsAdapter).artists
|
||||
if (oldItems.sortedBy { it.id }.hashCode() != artists.sortedBy { it.id }.hashCode()) {
|
||||
|
@ -129,7 +125,6 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
artists_placeholder.setTextColor(textColor)
|
||||
artists_fastscroller.updatePrimaryColor()
|
||||
artists_fastscroller.updateBubbleColors()
|
||||
artists_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,7 @@ import android.content.Intent
|
|||
import android.util.AttributeSet
|
||||
import com.google.gson.Gson
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
|
||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.underlineText
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SimpleActivity
|
||||
|
@ -52,7 +49,7 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
playlists_placeholder_2.beVisibleIf(playlists.isEmpty())
|
||||
val adapter = playlists_list.adapter
|
||||
if (adapter == null) {
|
||||
PlaylistsAdapter(activity, playlists, playlists_list, playlists_fastscroller) {
|
||||
PlaylistsAdapter(activity, playlists, playlists_list) {
|
||||
Intent(activity, TracksActivity::class.java).apply {
|
||||
putExtra(PLAYLIST, Gson().toJson(it))
|
||||
activity.startActivity(this)
|
||||
|
@ -64,11 +61,6 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
if (context.areSystemAnimationsEnabled) {
|
||||
playlists_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
playlists_fastscroller.setViews(playlists_list) {
|
||||
val playlist = (playlists_list.adapter as PlaylistsAdapter).playlists.getOrNull(it)
|
||||
playlists_fastscroller.updateBubbleText(playlist?.getBubbleText() ?: "")
|
||||
}
|
||||
} else {
|
||||
(adapter as PlaylistsAdapter).updateItems(playlists)
|
||||
}
|
||||
|
@ -111,7 +103,6 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
playlists_placeholder.setTextColor(textColor)
|
||||
playlists_placeholder_2.setTextColor(adjustedPrimaryColor)
|
||||
|
||||
playlists_fastscroller.updatePrimaryColor()
|
||||
playlists_fastscroller.updateBubbleColors()
|
||||
playlists_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,26 +5,21 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/albums_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/current_track_bar"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
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">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/albums_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/current_track_bar"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
|
||||
<include
|
||||
layout="@layout/view_current_track_bar"
|
||||
|
|
|
@ -5,24 +5,19 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/queue_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/queue_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/queue_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -5,26 +5,21 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/tracks_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/current_track_bar"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
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">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/tracks_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/current_track_bar"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/tracks_placeholder"
|
||||
|
|
|
@ -19,23 +19,18 @@
|
|||
android:textSize="@dimen/bigger_text_size"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/albums_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/albums_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/albums_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</com.simplemobiletools.musicplayer.fragments.AlbumsFragment>
|
||||
|
|
|
@ -19,23 +19,18 @@
|
|||
android:textSize="@dimen/bigger_text_size"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/artists_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/artists_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/artists_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
</com.simplemobiletools.musicplayer.fragments.ArtistsFragment>
|
||||
|
|
|
@ -5,24 +5,20 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/playlists_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
<com.simplemobiletools.commons.views.FastScroller
|
||||
<com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||
android:id="@+id/playlists_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/fastscroller_handle_vertical" />
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/playlists_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
|
||||
</com.simplemobiletools.commons.views.FastScroller>
|
||||
</com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/playlists_placeholder"
|
||||
|
|
Loading…
Reference in a new issue