Use the new schema for cover art URLs.

This commit is contained in:
Antoine POPINEAU 2020-08-08 14:51:39 +02:00
parent f062e62299
commit d76f76a222
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
13 changed files with 25 additions and 22 deletions

View File

@ -229,6 +229,8 @@ class MainActivity : AppCompatActivity() {
is Event.LogOut -> {
PowerPreference.clearAllData()
cacheDir.deleteRecursively()
startActivity(Intent(this@MainActivity, LoginActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NO_HISTORY
})
@ -370,14 +372,14 @@ class MainActivity : AppCompatActivity() {
now_playing_details_toggle.icon = getDrawable(R.drawable.pause)
Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.urls?.original))
.fit()
.centerCrop()
.into(now_playing_cover)
now_playing_details_cover?.let { now_playing_details_cover ->
Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
.maybeLoad(maybeNormalizeUrl(track.album?.cover()))
.fit()
.centerCrop()
.transform(RoundedCornersTransformation(16, 0))
@ -391,7 +393,7 @@ class MainActivity : AppCompatActivity() {
}.widthPixels
val backgroundCover = Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
.maybeLoad(maybeNormalizeUrl(track.album?.cover()))
.get()
.run { Bitmap.createScaledBitmap(this, width, width, false).toDrawable(resources) }
.apply {
@ -422,7 +424,7 @@ class MainActivity : AppCompatActivity() {
setOnMenuItemClickListener {
when (it.itemId) {
R.id.track_info_artist -> ArtistsFragment.openAlbums(this@MainActivity, track.artist, art = track.album?.cover?.original)
R.id.track_info_artist -> ArtistsFragment.openAlbums(this@MainActivity, track.artist, art = track.album?.cover())
R.id.track_info_album -> AlbumsFragment.openTracks(this@MainActivity, track.album)
R.id.track_info_details -> TrackInfoDetailsFragment.new(track).show(supportFragmentManager, "dialog")
}

View File

@ -36,7 +36,7 @@ class AlbumsAdapter(val context: Context?, private val listener: OnAlbumClickLis
val album = data[position]
Picasso.get()
.maybeLoad(maybeNormalizeUrl(album.cover.original))
.maybeLoad(maybeNormalizeUrl(album.cover()))
.fit()
.transform(RoundedCornersTransformation(8, 0))
.into(holder.art)

View File

@ -35,7 +35,7 @@ class AlbumsGridAdapter(val context: Context?, private val listener: OnAlbumClic
val album = data[position]
Picasso.get()
.maybeLoad(maybeNormalizeUrl(album.cover.original))
.maybeLoad(maybeNormalizeUrl(album.cover()))
.fit()
.placeholder(R.drawable.cover)
.transform(RoundedCornersTransformation(16, 0))

View File

@ -55,7 +55,7 @@ class ArtistsAdapter(val context: Context?, private val listener: OnArtistClickL
artist.albums?.let { albums ->
if (albums.isNotEmpty()) {
Picasso.get()
.maybeLoad(maybeNormalizeUrl(albums[0].cover.original))
.maybeLoad(maybeNormalizeUrl(albums[0].cover?.urls?.original))
.fit()
.transform(RoundedCornersTransformation(8, 0))
.into(holder.art)

View File

@ -44,7 +44,7 @@ class FavoritesAdapter(private val context: Context?, private val favoriteListen
val favorite = data[position]
Picasso.get()
.maybeLoad(maybeNormalizeUrl(favorite.album?.cover?.original))
.maybeLoad(maybeNormalizeUrl(favorite.album?.cover()))
.fit()
.placeholder(R.drawable.cover)
.transform(RoundedCornersTransformation(16, 0))

View File

@ -56,7 +56,7 @@ class PlaylistTracksAdapter(private val context: Context?, private val favoriteL
val track = data[position]
Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.track.album?.cover?.original))
.maybeLoad(maybeNormalizeUrl(track.track.album?.cover()))
.fit()
.placeholder(R.drawable.cover)
.transform(RoundedCornersTransformation(16, 0))

View File

@ -52,7 +52,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener:
val track = data[position]
Picasso.get()
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
.maybeLoad(maybeNormalizeUrl(track.album?.cover()))
.fit()
.transform(RoundedCornersTransformation(8, 0))
.into(holder.cover)

View File

@ -43,7 +43,7 @@ class AlbumsFragment : OtterFragment<Album, AlbumsAdapter>() {
companion object {
fun new(artist: Artist, _art: String? = null): AlbumsFragment {
val art = _art ?: if (artist.albums?.isNotEmpty() == true) artist.albums[0].cover.original else ""
val art = _art ?: if (artist.albums?.isNotEmpty() == true) artist.cover() else ""
return AlbumsFragment().apply {
arguments = bundleOf(

View File

@ -126,7 +126,7 @@ class PlaylistTracksFragment : OtterFragment<PlaylistTrack, PlaylistTracksAdapte
}
override fun onDataFetched(data: List<PlaylistTrack>) {
data.map { it.track.album }.toSet().map { it?.cover?.original }.take(4).forEachIndexed { index, url ->
data.map { it.track.album }.toSet().map { it?.cover() }.take(4).forEachIndexed { index, url ->
val imageView = when (index) {
0 -> cover_top_left
1 -> cover_top_right

View File

@ -42,7 +42,7 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() {
"albumId" to album.id,
"albumArtist" to album.artist.name,
"albumTitle" to album.title,
"albumCover" to album.cover.original
"albumCover" to album.cover()
)
}
}

View File

@ -41,7 +41,7 @@ class MediaControlsManager(val context: Service, private val scope: CoroutineSco
val openIntent = Intent(context, MainActivity::class.java).apply { action = NOTIFICATION_ACTION_OPEN_QUEUE.toString() }
val openPendingIntent = PendingIntent.getActivity(context, 0, openIntent, 0)
val coverUrl = maybeNormalizeUrl(track.album?.cover?.original)
val coverUrl = maybeNormalizeUrl(track.album?.cover())
notification = NotificationCompat.Builder(
context,

View File

@ -323,7 +323,7 @@ class PlayerService : Service() {
private fun buildTrackMetadata(track: Track?): MediaMetadataCompat {
track?.let {
val coverUrl = maybeNormalizeUrl(track.album?.cover?.original)
val coverUrl = maybeNormalizeUrl(track.album?.cover())
return mediaMetadataBuilder.apply {
putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.title)

View File

@ -56,7 +56,8 @@ data class RadiosResponse(override val count: Int, override val next: String?, v
override fun getData() = results
}
data class Covers(val original: String)
data class Covers(val urls: CoverUrls)
data class CoverUrls(val original: String)
typealias AlbumList = List<Album>
@ -70,12 +71,12 @@ 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)
override fun cover() = cover.original
override fun cover() = cover?.urls?.original
override fun title() = title
override fun subtitle() = artist.name
}
@ -87,10 +88,10 @@ data class Artist(
) : SearchResult {
data class Album(
val title: String,
val cover: Covers
val cover: Covers?
)
override fun cover() = albums?.getOrNull(0)?.cover?.original
override fun cover(): String? = albums?.getOrNull(0)?.cover?.urls?.original
override fun title() = name
override fun subtitle() = "Artist"
}
@ -115,7 +116,7 @@ data class Track(
id = download.id,
title = download.title,
artist = Artist(0, download.artist, listOf()),
album = Album(0, Album.Artist(""), "", Covers(""), ""),
album = Album(0, Album.Artist(""), "", Covers(CoverUrls("")), ""),
uploads = listOf(Upload(download.contentId, 0, 0))
)
}
@ -143,7 +144,7 @@ data class Track(
}
}
override fun cover() = album?.cover?.original
override fun cover() = album?.cover?.urls?.original
override fun title() = title
override fun subtitle() = artist.name
}