Browse Source

Use the new schema for cover art URLs.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
d76f76a222
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 10
      app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt
  2. 2
      app/src/main/java/com/github/apognu/otter/adapters/AlbumsAdapter.kt
  3. 2
      app/src/main/java/com/github/apognu/otter/adapters/AlbumsGridAdapter.kt
  4. 2
      app/src/main/java/com/github/apognu/otter/adapters/ArtistsAdapter.kt
  5. 2
      app/src/main/java/com/github/apognu/otter/adapters/FavoritesAdapter.kt
  6. 2
      app/src/main/java/com/github/apognu/otter/adapters/PlaylistTracksAdapter.kt
  7. 2
      app/src/main/java/com/github/apognu/otter/adapters/TracksAdapter.kt
  8. 2
      app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt
  9. 2
      app/src/main/java/com/github/apognu/otter/fragments/PlaylistTracksFragment.kt
  10. 2
      app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt
  11. 2
      app/src/main/java/com/github/apognu/otter/playback/MediaControlsManager.kt
  12. 2
      app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt
  13. 15
      app/src/main/java/com/github/apognu/otter/utils/Models.kt

10
app/src/main/java/com/github/apognu/otter/activities/MainActivity.kt

@ -229,6 +229,8 @@ class MainActivity : AppCompatActivity() { @@ -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() { @@ -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() { @@ -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() { @@ -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")
}

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

@ -36,7 +36,7 @@ class AlbumsAdapter(val context: Context?, private val listener: OnAlbumClickLis @@ -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)

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

@ -35,7 +35,7 @@ class AlbumsGridAdapter(val context: Context?, private val listener: OnAlbumClic @@ -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))

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

@ -55,7 +55,7 @@ class ArtistsAdapter(val context: Context?, private val listener: OnArtistClickL @@ -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)

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

@ -44,7 +44,7 @@ class FavoritesAdapter(private val context: Context?, private val favoriteListen @@ -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))

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

@ -56,7 +56,7 @@ class PlaylistTracksAdapter(private val context: Context?, private val favoriteL @@ -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))

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

@ -52,7 +52,7 @@ class TracksAdapter(private val context: Context?, private val favoriteListener: @@ -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)

2
app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt

@ -43,7 +43,7 @@ class AlbumsFragment : OtterFragment<Album, AlbumsAdapter>() { @@ -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(

2
app/src/main/java/com/github/apognu/otter/fragments/PlaylistTracksFragment.kt

@ -126,7 +126,7 @@ class PlaylistTracksFragment : OtterFragment<PlaylistTrack, PlaylistTracksAdapte @@ -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

2
app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt

@ -42,7 +42,7 @@ class TracksFragment : OtterFragment<Track, TracksAdapter>() { @@ -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()
)
}
}

2
app/src/main/java/com/github/apognu/otter/playback/MediaControlsManager.kt

@ -41,7 +41,7 @@ class MediaControlsManager(val context: Service, private val scope: CoroutineSco @@ -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,

2
app/src/main/java/com/github/apognu/otter/playback/PlayerService.kt

@ -323,7 +323,7 @@ class PlayerService : Service() { @@ -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)

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

@ -56,7 +56,8 @@ data class RadiosResponse(override val count: Int, override val next: String?, v @@ -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( @@ -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( @@ -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( @@ -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( @@ -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
}

Loading…
Cancel
Save