fix: Fix Playlist image loading
This commit is contained in:
parent
b9f3e7979b
commit
125681b938
5 changed files with 15 additions and 18 deletions
|
@ -107,9 +107,7 @@ class PlaylistAdapter(
|
||||||
holder.image?.setImageDrawable(getIconRes())
|
holder.image?.setImageDrawable(getIconRes())
|
||||||
} else {
|
} else {
|
||||||
Glide.with(activity)
|
Glide.with(activity)
|
||||||
.load(
|
.load(PlaylistPreview(playlist))
|
||||||
PlaylistPreview(playlist)
|
|
||||||
)
|
|
||||||
.playlistOptions()
|
.playlistOptions()
|
||||||
.into(holder.image!!)
|
.into(holder.image!!)
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
||||||
viewModel.getPlaylist().observe(viewLifecycleOwner) { playlistWithSongs ->
|
viewModel.getPlaylist().observe(viewLifecycleOwner) { playlistWithSongs ->
|
||||||
playlist = playlistWithSongs
|
playlist = playlistWithSongs
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(PlaylistPreview(playlist))
|
.load(PlaylistPreview(playlistWithSongs))
|
||||||
.playlistOptions()
|
.playlistOptions()
|
||||||
.into(binding.image)
|
.into(binding.image)
|
||||||
binding.title.text = playlist.playlistEntity.playlistName
|
binding.title.text = playlist.playlistEntity.playlistName
|
||||||
|
|
|
@ -148,9 +148,9 @@ object RetroGlideExtension {
|
||||||
.signature(createSignature(file))
|
.signature(createSignature(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> RequestBuilder<T>.playlistOptions(
|
fun <T> RequestBuilder<T>.playlistOptions(): RequestBuilder<T> {
|
||||||
): RequestBuilder<T> {
|
return diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
||||||
return diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
.placeholder(getDrawable(DEFAULT_ALBUM_IMAGE))
|
||||||
.error(getDrawable(DEFAULT_ALBUM_IMAGE))
|
.error(getDrawable(DEFAULT_ALBUM_IMAGE))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,21 +11,20 @@ class PlaylistPreview(val playlistWithSongs: PlaylistWithSongs) {
|
||||||
val songs: List<Song> get() = playlistWithSongs.songs.toSongs()
|
val songs: List<Song> get() = playlistWithSongs.songs.toSongs()
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (other is PlaylistPreview) {
|
println("Glide equals $this $other")
|
||||||
if (other.playlistEntity.playListId != playlistEntity.playListId) {
|
if (this === other) return true
|
||||||
return false
|
if (javaClass != other?.javaClass) return false
|
||||||
}
|
|
||||||
if (other.songs.size != songs.size) {
|
other as PlaylistPreview
|
||||||
return false
|
if (other.playlistEntity.playListId != playlistEntity.playListId) return false
|
||||||
}
|
if (other.songs.size != songs.size) return false
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
var result = playlistEntity.playListId.hashCode()
|
var result = playlistEntity.playListId.hashCode()
|
||||||
result = 31 * result + playlistWithSongs.songs.size
|
result = 31 * result + playlistWithSongs.songs.size
|
||||||
|
println("Glide $result")
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ class PlaylistPreviewFetcher(val context: Context, private val playlistPreview:
|
||||||
val bitmap =
|
val bitmap =
|
||||||
AutoGeneratedPlaylistBitmap.getBitmap(
|
AutoGeneratedPlaylistBitmap.getBitmap(
|
||||||
context,
|
context,
|
||||||
playlistPreview.songs.shuffled()
|
playlistPreview.songs
|
||||||
)
|
)
|
||||||
callback.onDataReady(bitmap)
|
callback.onDataReady(bitmap)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue