Fix recycled bitmap crash
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
package org.koitharu.kotatsu.domain
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.media.ThumbnailUtils
|
||||
import android.util.Size
|
||||
import androidx.annotation.Px
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import coil.Coil
|
||||
import coil.api.get
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import org.koin.core.KoinComponent
|
||||
import org.koin.core.get
|
||||
import org.koitharu.kotatsu.BuildConfig
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import org.koitharu.kotatsu.core.model.MangaPage
|
||||
import org.koitharu.kotatsu.core.prefs.ReaderMode
|
||||
import org.koitharu.kotatsu.utils.ext.await
|
||||
@@ -61,23 +54,4 @@ object MangaUtils : KoinComponent {
|
||||
check(imageHeight > 0 && imageWidth > 0)
|
||||
return Size(imageWidth, imageHeight)
|
||||
}
|
||||
|
||||
suspend fun getMangaIcon(manga: Manga, @Px width: Int, @Px height: Int): Bitmap? {
|
||||
try {
|
||||
val bmp = Coil.loader().get(manga.coverUrl) {
|
||||
size(width, height)
|
||||
}.toBitmap()
|
||||
return ThumbnailUtils.extractThumbnail(
|
||||
bmp,
|
||||
width,
|
||||
height,
|
||||
ThumbnailUtils.OPTIONS_RECYCLE_INPUT
|
||||
)
|
||||
} catch (e: Throwable) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ object ShortcutUtils {
|
||||
bmp,
|
||||
size.width,
|
||||
size.height,
|
||||
ThumbnailUtils.OPTIONS_RECYCLE_INPUT
|
||||
0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user