mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix(manga/details): Fix "Theme buttons based on cover"
Palette doesn't like copy's bitmap, could be because of mutability is disabled or perhaps because it's set to HARDWARE configured, not entirely sure, because Google didn't document it. Classic Google behaviour :^)
This commit is contained in:
parent
e9b4292295
commit
889b20797e
3 changed files with 10 additions and 9 deletions
|
@ -11,6 +11,7 @@
|
|||
-->
|
||||
## Fixes
|
||||
- Fixed crashes caused by certain extension implementation
|
||||
- Fixed "Theme buttons based on cover" doesn't work properly
|
||||
|
||||
## Other
|
||||
- More StorIO to SQLDelight migration effort
|
||||
|
|
|
@ -586,15 +586,16 @@ class MangaDetailsController :
|
|||
)
|
||||
} ?: drawable
|
||||
|
||||
val bitmap = (copy as? BitmapDrawable)?.bitmap
|
||||
// Don't use 'copy', Palette doesn't like its bitmap, could be caused by mutability is disabled,
|
||||
// or perhaps because it's HARDWARE configured, not entirely sure why, the behaviour is not
|
||||
// documented by Google.
|
||||
val bitmap = (drawable as? BitmapDrawable)?.bitmap
|
||||
// Generate the Palette on a background thread.
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap).generate {
|
||||
if (it == null) return@generate
|
||||
Palette.from(bitmap).generate { palette ->
|
||||
if (presenter.preferences.themeMangaDetails().get()) {
|
||||
launchUI {
|
||||
view.context.getResourceColor(R.attr.colorSecondary)
|
||||
val vibrantColor = it.getBestColor() ?: return@launchUI
|
||||
val vibrantColor = palette?.getBestColor() ?: return@launchUI
|
||||
manga?.vibrantCoverColor = vibrantColor
|
||||
setAccentColorValue(vibrantColor)
|
||||
setHeaderColorValue(vibrantColor)
|
||||
|
|
|
@ -68,14 +68,13 @@ object MangaCoverMetadata {
|
|||
}
|
||||
val bitmap = BitmapFactory.decodeFile(file.filePath, options)
|
||||
if (bitmap != null) {
|
||||
Palette.from(bitmap).generate {
|
||||
if (it == null) return@generate
|
||||
Palette.from(bitmap).generate { palette ->
|
||||
if (isInLibrary) {
|
||||
it.dominantSwatch?.let { swatch ->
|
||||
palette?.dominantSwatch?.let { swatch ->
|
||||
addCoverColor(mangaId, swatch.rgb, swatch.titleTextColor)
|
||||
}
|
||||
}
|
||||
val color = it.getBestColor() ?: return@generate
|
||||
val color = palette?.getBestColor() ?: return@generate
|
||||
setVibrantColor(mangaId, color)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue