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())
|
||||
} else {
|
||||
Glide.with(activity)
|
||||
.load(
|
||||
PlaylistPreview(playlist)
|
||||
)
|
||||
.load(PlaylistPreview(playlist))
|
||||
.playlistOptions()
|
||||
.into(holder.image!!)
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
viewModel.getPlaylist().observe(viewLifecycleOwner) { playlistWithSongs ->
|
||||
playlist = playlistWithSongs
|
||||
Glide.with(this)
|
||||
.load(PlaylistPreview(playlist))
|
||||
.load(PlaylistPreview(playlistWithSongs))
|
||||
.playlistOptions()
|
||||
.into(binding.image)
|
||||
binding.title.text = playlist.playlistEntity.playlistName
|
||||
|
|
|
@ -148,9 +148,9 @@ object RetroGlideExtension {
|
|||
.signature(createSignature(file))
|
||||
}
|
||||
|
||||
fun <T> RequestBuilder<T>.playlistOptions(
|
||||
): RequestBuilder<T> {
|
||||
return diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
|
||||
fun <T> RequestBuilder<T>.playlistOptions(): RequestBuilder<T> {
|
||||
return diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
|
||||
.placeholder(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()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other is PlaylistPreview) {
|
||||
if (other.playlistEntity.playListId != playlistEntity.playListId) {
|
||||
return false
|
||||
}
|
||||
if (other.songs.size != songs.size) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
println("Glide equals $this $other")
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as PlaylistPreview
|
||||
if (other.playlistEntity.playListId != playlistEntity.playListId) return false
|
||||
if (other.songs.size != songs.size) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = playlistEntity.playListId.hashCode()
|
||||
result = 31 * result + playlistWithSongs.songs.size
|
||||
println("Glide $result")
|
||||
return result
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ class PlaylistPreviewFetcher(val context: Context, private val playlistPreview:
|
|||
val bitmap =
|
||||
AutoGeneratedPlaylistBitmap.getBitmap(
|
||||
context,
|
||||
playlistPreview.songs.shuffled()
|
||||
playlistPreview.songs
|
||||
)
|
||||
callback.onDataReady(bitmap)
|
||||
} catch (e: Exception) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue