use the new fastscroller at the Tracks tab
This commit is contained in:
parent
2bb07bb398
commit
491fc214b4
5 changed files with 23 additions and 32 deletions
|
@ -62,13 +62,14 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:cbacb108df'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:92e67a1d01'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation 'androidx.media:media:1.4.2'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'com.airbnb.android:lottie:3.6.1'
|
||||
implementation 'com.github.tibbi:RecyclerView-FastScroller:ea19354180'
|
||||
|
||||
kapt "androidx.room:room-compiler:2.3.0"
|
||||
implementation "androidx.room:room-runtime:2.3.0"
|
||||
|
|
|
@ -80,7 +80,7 @@ class TracksActivity : SimpleActivity() {
|
|||
|
||||
runOnUiThread {
|
||||
val adapter = if (playlist != null) {
|
||||
TracksAdapter(this, tracks, true, tracks_list, tracks_fastscroller) {
|
||||
TracksAdapter(this, tracks, true, tracks_list) {
|
||||
itemClicked(it as Track)
|
||||
}
|
||||
} 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.dialogs.PropertiesDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
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,9 @@ import kotlinx.android.synthetic.main.item_track.view.*
|
|||
import org.greenrobot.eventbus.EventBus
|
||||
import java.util.*
|
||||
|
||||
class TracksAdapter(activity: SimpleActivity, var tracks: ArrayList<Track>, val isPlaylistContent: Boolean, recyclerView: MyRecyclerView,
|
||||
fastScroller: FastScroller, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
class TracksAdapter(
|
||||
activity: SimpleActivity, var tracks: ArrayList<Track>, val isPlaylistContent: Boolean, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
|
||||
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||
|
||||
private var textToHighlight = ""
|
||||
private val placeholder = resources.getColoredDrawableWithColor(R.drawable.ic_headset, textColor)
|
||||
|
@ -206,4 +207,6 @@ class TracksAdapter(activity: SimpleActivity, var tracks: ArrayList<Track>, val
|
|||
track_id.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChange(position: Int) = tracks.getOrNull(position)?.getBubbleText() ?: ""
|
||||
}
|
||||
|
|
|
@ -5,9 +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.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SimpleActivity
|
||||
|
@ -47,7 +45,7 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
tracks_placeholder.beVisibleIf(tracks.isEmpty())
|
||||
val adapter = tracks_list.adapter
|
||||
if (adapter == null) {
|
||||
TracksAdapter(activity, tracks, false, tracks_list, tracks_fastscroller) {
|
||||
TracksAdapter(activity, tracks, false, tracks_list) {
|
||||
activity.resetQueueItems(tracks) {
|
||||
Intent(activity, TrackActivity::class.java).apply {
|
||||
putExtra(TRACK, Gson().toJson(it))
|
||||
|
@ -62,11 +60,6 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
if (context.areSystemAnimationsEnabled) {
|
||||
tracks_list.scheduleLayoutAnimation()
|
||||
}
|
||||
|
||||
tracks_fastscroller.setViews(tracks_list) {
|
||||
val track = (tracks_list.adapter as TracksAdapter).tracks.getOrNull(it)
|
||||
tracks_fastscroller.updateBubbleText(track?.getBubbleText() ?: "")
|
||||
}
|
||||
} else {
|
||||
(adapter as TracksAdapter).updateItems(tracks)
|
||||
}
|
||||
|
@ -105,7 +98,6 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
tracks_placeholder.setTextColor(textColor)
|
||||
tracks_fastscroller.updatePrimaryColor()
|
||||
tracks_fastscroller.updateBubbleColors()
|
||||
tracks_fastscroller.updateColors(adjustedPrimaryColor, adjustedPrimaryColor.getContrastColor())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,23 +19,18 @@
|
|||
android:textSize="@dimen/bigger_text_size"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/tracks_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/tracks_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/tracks_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.TracksFragment>
|
||||
|
|
Loading…
Reference in a new issue