Use the new schema for cover art URLs.
This commit is contained in:
parent
f062e62299
commit
d76f76a222
|
@ -229,6 +229,8 @@ class MainActivity : AppCompatActivity() {
|
||||||
is Event.LogOut -> {
|
is Event.LogOut -> {
|
||||||
PowerPreference.clearAllData()
|
PowerPreference.clearAllData()
|
||||||
|
|
||||||
|
cacheDir.deleteRecursively()
|
||||||
|
|
||||||
startActivity(Intent(this@MainActivity, LoginActivity::class.java).apply {
|
startActivity(Intent(this@MainActivity, LoginActivity::class.java).apply {
|
||||||
flags = Intent.FLAG_ACTIVITY_NO_HISTORY
|
flags = Intent.FLAG_ACTIVITY_NO_HISTORY
|
||||||
})
|
})
|
||||||
|
@ -370,14 +372,14 @@ class MainActivity : AppCompatActivity() {
|
||||||
now_playing_details_toggle.icon = getDrawable(R.drawable.pause)
|
now_playing_details_toggle.icon = getDrawable(R.drawable.pause)
|
||||||
|
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
|
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.urls?.original))
|
||||||
.fit()
|
.fit()
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(now_playing_cover)
|
.into(now_playing_cover)
|
||||||
|
|
||||||
now_playing_details_cover?.let { now_playing_details_cover ->
|
now_playing_details_cover?.let { now_playing_details_cover ->
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
|
.maybeLoad(maybeNormalizeUrl(track.album?.cover()))
|
||||||
.fit()
|
.fit()
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.transform(RoundedCornersTransformation(16, 0))
|
.transform(RoundedCornersTransformation(16, 0))
|
||||||
|
@ -391,7 +393,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}.widthPixels
|
}.widthPixels
|
||||||
|
|
||||||
val backgroundCover = Picasso.get()
|
val backgroundCover = Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
|
.maybeLoad(maybeNormalizeUrl(track.album?.cover()))
|
||||||
.get()
|
.get()
|
||||||
.run { Bitmap.createScaledBitmap(this, width, width, false).toDrawable(resources) }
|
.run { Bitmap.createScaledBitmap(this, width, width, false).toDrawable(resources) }
|
||||||
.apply {
|
.apply {
|
||||||
|
@ -422,7 +424,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
setOnMenuItemClickListener {
|
setOnMenuItemClickListener {
|
||||||
when (it.itemId) {
|
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_album -> AlbumsFragment.openTracks(this@MainActivity, track.album)
|
||||||
R.id.track_info_details -> TrackInfoDetailsFragment.new(track).show(supportFragmentManager, "dialog")
|
R.id.track_info_details -> TrackInfoDetailsFragment.new(track).show(supportFragmentManager, "dialog")
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class AlbumsAdapter(val context: Context?, private val listener: OnAlbumClickLis
|
||||||
val album = data[position]
|
val album = data[position]
|
||||||
|
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(album.cover.original))
|
.maybeLoad(maybeNormalizeUrl(album.cover()))
|
||||||
.fit()
|
.fit()
|
||||||
.transform(RoundedCornersTransformation(8, 0))
|
.transform(RoundedCornersTransformation(8, 0))
|
||||||
.into(holder.art)
|
.into(holder.art)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class AlbumsGridAdapter(val context: Context?, private val listener: OnAlbumClic
|
||||||
val album = data[position]
|
val album = data[position]
|
||||||
|
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(album.cover.original))
|
.maybeLoad(maybeNormalizeUrl(album.cover()))
|
||||||
.fit()
|
.fit()
|
||||||
.placeholder(R.drawable.cover)
|
.placeholder(R.drawable.cover)
|
||||||
.transform(RoundedCornersTransformation(16, 0))
|
.transform(RoundedCornersTransformation(16, 0))
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ArtistsAdapter(val context: Context?, private val listener: OnArtistClickL
|
||||||
artist.albums?.let { albums ->
|
artist.albums?.let { albums ->
|
||||||
if (albums.isNotEmpty()) {
|
if (albums.isNotEmpty()) {
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(albums[0].cover.original))
|
.maybeLoad(maybeNormalizeUrl(albums[0].cover?.urls?.original))
|
||||||
.fit()
|
.fit()
|
||||||
.transform(RoundedCornersTransformation(8, 0))
|
.transform(RoundedCornersTransformation(8, 0))
|
||||||
.into(holder.art)
|
.into(holder.art)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class FavoritesAdapter(private val context: Context?, private val favoriteListen
|
||||||
val favorite = data[position]
|
val favorite = data[position]
|
||||||
|
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(favorite.album?.cover?.original))
|
.maybeLoad(maybeNormalizeUrl(favorite.album?.cover()))
|
||||||
.fit()
|
.fit()
|
||||||
.placeholder(R.drawable.cover)
|
.placeholder(R.drawable.cover)
|
||||||
.transform(RoundedCornersTransformation(16, 0))
|
.transform(RoundedCornersTransformation(16, 0))
|
||||||
|
|
|
@ -56,7 +56,7 @@ class PlaylistTracksAdapter(private val context: Context?, private val favoriteL
|
||||||
val track = data[position]
|
val track = data[position]
|
||||||
|
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(track.track.album?.cover?.original))
|
.maybeLoad(maybeNormalizeUrl(track.track.album?.cover()))
|
||||||
.fit()
|
.fit()
|
||||||
.placeholder(R.drawable.cover)
|
.placeholder(R.drawable.cover)
|
||||||
.transform(RoundedCornersTransformation(16, 0))
|
.transform(RoundedCornersTransformation(16, 0))
|
||||||
|
|
|
@ -52,7 +52,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener:
|
||||||
val track = data[position]
|
val track = data[position]
|
||||||
|
|
||||||
Picasso.get()
|
Picasso.get()
|
||||||
.maybeLoad(maybeNormalizeUrl(track.album?.cover?.original))
|
.maybeLoad(maybeNormalizeUrl(track.album?.cover()))
|
||||||
.fit()
|
.fit()
|
||||||
.transform(RoundedCornersTransformation(8, 0))
|
.transform(RoundedCornersTransformation(8, 0))
|
||||||
.into(holder.cover)
|
.into(holder.cover)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class AlbumsFragment : OtterFragment<Album, AlbumsAdapter>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun new(artist: Artist, _art: String? = null): AlbumsFragment {
|
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 {
|
return AlbumsFragment().apply {
|
||||||
arguments = bundleOf(
|
arguments = bundleOf(
|
||||||
|
|
|
@ -126,7 +126,7 @@ class PlaylistTracksFragment : OtterFragment<PlaylistTrack, PlaylistTracksAdapte
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDataFetched(data: List<PlaylistTrack>) {
|
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) {
|
val imageView = when (index) {
|
||||||
0 -> cover_top_left
|
0 -> cover_top_left
|
||||||
1 -> cover_top_right
|
1 -> cover_top_right
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() {
|
||||||
"albumId" to album.id,
|
"albumId" to album.id,
|
||||||
"albumArtist" to album.artist.name,
|
"albumArtist" to album.artist.name,
|
||||||
"albumTitle" to album.title,
|
"albumTitle" to album.title,
|
||||||
"albumCover" to album.cover.original
|
"albumCover" to album.cover()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 openIntent = Intent(context, MainActivity::class.java).apply { action = NOTIFICATION_ACTION_OPEN_QUEUE.toString() }
|
||||||
val openPendingIntent = PendingIntent.getActivity(context, 0, openIntent, 0)
|
val openPendingIntent = PendingIntent.getActivity(context, 0, openIntent, 0)
|
||||||
|
|
||||||
val coverUrl = maybeNormalizeUrl(track.album?.cover?.original)
|
val coverUrl = maybeNormalizeUrl(track.album?.cover())
|
||||||
|
|
||||||
notification = NotificationCompat.Builder(
|
notification = NotificationCompat.Builder(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -323,7 +323,7 @@ class PlayerService : Service() {
|
||||||
|
|
||||||
private fun buildTrackMetadata(track: Track?): MediaMetadataCompat {
|
private fun buildTrackMetadata(track: Track?): MediaMetadataCompat {
|
||||||
track?.let {
|
track?.let {
|
||||||
val coverUrl = maybeNormalizeUrl(track.album?.cover?.original)
|
val coverUrl = maybeNormalizeUrl(track.album?.cover())
|
||||||
|
|
||||||
return mediaMetadataBuilder.apply {
|
return mediaMetadataBuilder.apply {
|
||||||
putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.title)
|
putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.title)
|
||||||
|
|
|
@ -56,7 +56,8 @@ data class RadiosResponse(override val count: Int, override val next: String?, v
|
||||||
override fun getData() = results
|
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>
|
typealias AlbumList = List<Album>
|
||||||
|
|
||||||
|
@ -70,12 +71,12 @@ data class Album(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val artist: Artist,
|
val artist: Artist,
|
||||||
val title: String,
|
val title: String,
|
||||||
val cover: Covers,
|
val cover: Covers?,
|
||||||
val release_date: String?
|
val release_date: String?
|
||||||
) : SearchResult {
|
) : SearchResult {
|
||||||
data class Artist(val name: String)
|
data class Artist(val name: String)
|
||||||
|
|
||||||
override fun cover() = cover.original
|
override fun cover() = cover?.urls?.original
|
||||||
override fun title() = title
|
override fun title() = title
|
||||||
override fun subtitle() = artist.name
|
override fun subtitle() = artist.name
|
||||||
}
|
}
|
||||||
|
@ -87,10 +88,10 @@ data class Artist(
|
||||||
) : SearchResult {
|
) : SearchResult {
|
||||||
data class Album(
|
data class Album(
|
||||||
val title: String,
|
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 title() = name
|
||||||
override fun subtitle() = "Artist"
|
override fun subtitle() = "Artist"
|
||||||
}
|
}
|
||||||
|
@ -115,7 +116,7 @@ data class Track(
|
||||||
id = download.id,
|
id = download.id,
|
||||||
title = download.title,
|
title = download.title,
|
||||||
artist = Artist(0, download.artist, listOf()),
|
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))
|
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 title() = title
|
||||||
override fun subtitle() = artist.name
|
override fun subtitle() = artist.name
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue