Browse Source

Sort artists and global albums by name/title. Sort an artist's albums by release date. Display the release year in the albums view (#54).

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
37f4b1da9e
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 9
      app/src/main/java/com/github/apognu/otter/adapters/AlbumsAdapter.kt
  2. 2
      app/src/main/java/com/github/apognu/otter/adapters/DownloadsAdapter.kt
  3. 4
      app/src/main/java/com/github/apognu/otter/repositories/AlbumsRepository.kt
  4. 2
      app/src/main/java/com/github/apognu/otter/repositories/ArtistsRepository.kt
  5. 3
      app/src/main/java/com/github/apognu/otter/utils/Models.kt
  6. 9
      app/src/main/res/drawable/pill.xml
  7. 8
      app/src/main/res/layout/row_album.xml

9
app/src/main/java/com/github/apognu/otter/adapters/AlbumsAdapter.kt

@ -41,12 +41,21 @@ class AlbumsAdapter(val context: Context?, private val listener: OnAlbumClickLis @@ -41,12 +41,21 @@ class AlbumsAdapter(val context: Context?, private val listener: OnAlbumClickLis
holder.title.text = album.title
holder.artist.text = album.artist.name
holder.release_date.visibility = View.GONE
album.release_date.split('-').getOrNull(0)?.let { year ->
if (year.isNotEmpty()) {
holder.release_date.visibility = View.VISIBLE
holder.release_date.text = year
}
}
}
inner class ViewHolder(view: View, private val listener: OnAlbumClickListener) : RecyclerView.ViewHolder(view), View.OnClickListener {
val art = view.art
val title = view.title
val artist = view.artist
val release_date = view.release_date
override fun onClick(view: View?) {
listener.onClick(view, data[layoutPosition])

2
app/src/main/java/com/github/apognu/otter/adapters/DownloadsAdapter.kt

@ -79,7 +79,7 @@ class DownloadsAdapter(private val context: Context, private val listener: OnDow @@ -79,7 +79,7 @@ class DownloadsAdapter(private val context: Context, private val listener: OnDow
Download.STATE_QUEUED, Download.STATE_DOWNLOADING -> DownloadService.sendSetStopReason(context, PinService::class.java, download.contentId, 1, false)
Download.STATE_FAILED -> {
Track(download.id, download.title, Artist(0, download.artist, listOf()), Album(0, Album.Artist(""), "", Covers("")), 0, listOf(Track.Upload(download.contentId, 0, 0))).also {
Track(download.id, download.title, Artist(0, download.artist, listOf()), Album(0, Album.Artist(""), "", Covers(""), ""), 0, listOf(Track.Upload(download.contentId, 0, 0))).also {
PinService.download(context, it)
}
}

4
app/src/main/java/com/github/apognu/otter/repositories/AlbumsRepository.kt

@ -17,8 +17,8 @@ class AlbumsRepository(override val context: Context?, artistId: Int? = null) : @@ -17,8 +17,8 @@ class AlbumsRepository(override val context: Context?, artistId: Int? = null) :
override val upstream: Upstream<Album> by lazy {
val url =
if (artistId == null) "/api/v1/albums/?playable=true"
else "/api/v1/albums/?playable=true&artist=$artistId"
if (artistId == null) "/api/v1/albums/?playable=true&ordering=title"
else "/api/v1/albums/?playable=true&artist=$artistId&ordering=release_date"
HttpUpstream<Album, FunkwhaleResponse<Album>>(
HttpUpstream.Behavior.Progressive,

2
app/src/main/java/com/github/apognu/otter/repositories/ArtistsRepository.kt

@ -11,7 +11,7 @@ import java.io.BufferedReader @@ -11,7 +11,7 @@ import java.io.BufferedReader
class ArtistsRepository(override val context: Context?) : Repository<Artist, ArtistsCache>() {
override val cacheId = "artists"
override val upstream = HttpUpstream<Artist, FunkwhaleResponse<Artist>>(HttpUpstream.Behavior.Progressive, "/api/v1/artists/?playable=true", object : TypeToken<ArtistsResponse>() {}.type)
override val upstream = HttpUpstream<Artist, FunkwhaleResponse<Artist>>(HttpUpstream.Behavior.Progressive, "/api/v1/artists/?playable=true&ordering=name", object : TypeToken<ArtistsResponse>() {}.type)
override fun cache(data: List<Artist>) = ArtistsCache(data)
override fun uncache(reader: BufferedReader) = gsonDeserializerOf(ArtistsCache::class.java).deserialize(reader)

3
app/src/main/java/com/github/apognu/otter/utils/Models.kt

@ -70,7 +70,8 @@ data class Album( @@ -70,7 +70,8 @@ data class Album(
val id: Int,
val artist: Artist,
val title: String,
val cover: Covers
val cover: Covers,
val release_date: String
) : SearchResult {
data class Artist(val name: String)

9
app/src/main/res/drawable/pill.xml

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="3dp" />
<solid android:color="@color/ripple" />
<padding android:top="4dp" android:left="8dp" android:right="8dp" android:bottom="4dp" />
</shape>

8
app/src/main/res/layout/row_album.xml

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
@ -44,4 +45,11 @@ @@ -44,4 +45,11 @@
</LinearLayout>
<TextView
android:id="@+id/release_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@drawable/pill" />
</LinearLayout>
Loading…
Cancel
Save