mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
502cef4b04
commit
fd5c9e0ec4
@ -48,9 +48,9 @@ object BookCover {
|
||||
defaultDrawable = appCtx.resources.getDrawable(R.drawable.image_cover_default, null)
|
||||
return
|
||||
}
|
||||
defaultDrawable = BitmapUtils.decodeBitmap(path, 100, 150)?.let {
|
||||
BitmapDrawable(appCtx.resources, it)
|
||||
} ?: appCtx.resources.getDrawable(R.drawable.image_cover_default, null)
|
||||
defaultDrawable = kotlin.runCatching {
|
||||
BitmapDrawable(appCtx.resources, BitmapUtils.decodeBitmap(path, 100, 150))
|
||||
}.getOrDefault(appCtx.resources.getDrawable(R.drawable.image_cover_default, null))
|
||||
}
|
||||
|
||||
fun getBlurDefaultCover(context: Context): RequestBuilder<Drawable> {
|
||||
|
@ -28,7 +28,8 @@ object BitmapUtils {
|
||||
* @param height 想要显示的图片的高度
|
||||
* @return
|
||||
*/
|
||||
fun decodeBitmap(path: String, width: Int, height: Int): Bitmap? {
|
||||
@Throws(IOException::class)
|
||||
fun decodeBitmap(path: String, width: Int, height: Int): Bitmap {
|
||||
val op = BitmapFactory.Options()
|
||||
val ips = FileInputStream(path)
|
||||
// inJustDecodeBounds如果设置为true,仅仅返回图片实际的宽和高,宽和高是赋值给opts.outWidth,opts.outHeight;
|
||||
@ -53,7 +54,8 @@ object BitmapUtils {
|
||||
* @param path 图片路径
|
||||
* @return
|
||||
*/
|
||||
fun decodeBitmap(path: String): Bitmap? {
|
||||
@Throws(IOException::class)
|
||||
fun decodeBitmap(path: String): Bitmap {
|
||||
val opts = BitmapFactory.Options()
|
||||
val ips = FileInputStream(path)
|
||||
opts.inJustDecodeBounds = true
|
||||
|
Loading…
Reference in New Issue
Block a user