mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-16 09:20:37 +03:00
Added Fastscroll Library with section popup support
Fixed collation for the sorting of tha Artist list
This commit is contained in:
parent
47e5675d1e
commit
7dcaf5b1a6
@ -38,6 +38,7 @@ ext.versions = [
|
||||
robolectric : "4.4",
|
||||
dexter : "6.1.2",
|
||||
timber : "4.7.1",
|
||||
fastScroll : "2.0.1",
|
||||
]
|
||||
|
||||
ext.gradlePlugins = [
|
||||
@ -77,6 +78,7 @@ ext.other = [
|
||||
picasso : "com.squareup.picasso:picasso:$versions.picasso",
|
||||
dexter : "com.karumi:dexter:$versions.dexter",
|
||||
timber : "com.jakewharton.timber:timber:$versions.timber",
|
||||
fastScroll : "com.simplecityapps:recyclerview-fastscroll:$versions.fastScroll",
|
||||
]
|
||||
|
||||
ext.testing = [
|
||||
|
@ -77,6 +77,7 @@ dependencies {
|
||||
implementation other.koinAndroid
|
||||
implementation other.koinViewModel
|
||||
implementation other.okhttpLogging
|
||||
implementation other.fastScroll
|
||||
|
||||
kapt androidSupport.room
|
||||
|
||||
|
@ -29,11 +29,13 @@ import android.widget.PopupMenu
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.SectionedAdapter
|
||||
import org.moire.ultrasonic.R
|
||||
import org.moire.ultrasonic.data.ActiveServerProvider.Companion.isOffline
|
||||
import org.moire.ultrasonic.domain.Artist
|
||||
import org.moire.ultrasonic.domain.MusicDirectory
|
||||
import org.moire.ultrasonic.util.ImageLoader
|
||||
import java.text.Collator
|
||||
|
||||
/**
|
||||
* Creates a Row in a RecyclerView which contains the details of an Artist
|
||||
@ -45,14 +47,14 @@ class ArtistRowAdapter(
|
||||
val onArtistClick: (Artist) -> Unit,
|
||||
val onContextMenuClick: (MenuItem, Artist) -> Boolean,
|
||||
val onFolderClick: (view: View) -> Unit,
|
||||
val imageLoader: ImageLoader
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
private val imageLoader: ImageLoader
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>(), SectionedAdapter {
|
||||
|
||||
/**
|
||||
* Sets the data to be displayed in the RecyclerView
|
||||
*/
|
||||
fun setData(data: List<Artist>) {
|
||||
artistList = data.sortedBy { t -> t.name }
|
||||
artistList = data.sortedWith(compareBy(Collator.getInstance()){ t -> t.name })
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
@ -133,6 +135,11 @@ class ArtistRowAdapter(
|
||||
return if (position == 0 && shouldShowHeader) TYPE_HEADER else TYPE_ITEM
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
val listPosition = if (shouldShowHeader) position - 1 else position
|
||||
return getSectionFromName(artistList[listPosition].name ?: " ")
|
||||
}
|
||||
|
||||
private fun getSectionForArtist(artistPosition: Int): String {
|
||||
if (artistPosition == 0)
|
||||
return getSectionFromName(artistList[artistPosition].name ?: " ")
|
||||
|
@ -13,18 +13,22 @@
|
||||
a:layout_height="0dip"
|
||||
a:layout_weight="1.0">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
a:id="@+id/select_artist_list"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:paddingTop="8dp"
|
||||
a:paddingBottom="8dp"
|
||||
a:clipToPadding="false"
|
||||
app:fastScrollEnabled="true"
|
||||
app:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
||||
app:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
||||
app:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
|
||||
app:fastScrollVerticalTrackDrawable="@drawable/line_drawable" />
|
||||
app:fastScrollAutoHide="true"
|
||||
app:fastScrollAutoHideDelay="2000"
|
||||
app:fastScrollPopupTextSize="28sp"
|
||||
app:fastScrollPopupBackgroundSize="42dp"
|
||||
app:fastScrollPopupBgColor="@color/cyan"
|
||||
app:fastScrollPopupTextColor="@android:color/primary_text_dark"
|
||||
app:fastScrollPopupPosition="adjacent"
|
||||
app:fastScrollTrackColor="@color/dividerColor"
|
||||
app:fastScrollThumbColor="@color/cyan" />
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user