diff --git a/app/build.gradle b/app/build.gradle index b76d28272..6d576b873 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -178,7 +178,8 @@ dependencies { implementation 'com.github.gedoor:rhino-android:1.5' //网络 - implementation 'com.squareup.okhttp3:okhttp:4.9.0' + //noinspection GradleDependency + implementation 'com.squareup.okhttp3:okhttp:4.9.1' implementation 'com.ljx.rxhttp:rxhttp:2.5.7' kapt 'com.ljx.rxhttp:rxhttp-compiler:2.5.7' diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index bae066fe6..77b43f4de 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -28,11 +28,11 @@ object BitmapUtils { */ fun decodeBitmap(path: String, width: Int, height: Int): Bitmap? { val op = BitmapFactory.Options() - op.inPreferredConfig=Config.RGB_565 - var ips=FileInputStream(path) + op.inPreferredConfig = Config.RGB_565 + val ips = FileInputStream(path) // inJustDecodeBounds如果设置为true,仅仅返回图片实际的宽和高,宽和高是赋值给opts.outWidth,opts.outHeight; op.inJustDecodeBounds = true - BitmapFactory.decodeStream(ips,null,op)//获取尺寸信息 + BitmapFactory.decodeFileDescriptor(ips.fd, null, op) //获取比例大小 val wRatio = ceil((op.outWidth / width).toDouble()).toInt() val hRatio = ceil((op.outHeight / height).toDouble()).toInt() @@ -44,9 +44,8 @@ object BitmapUtils { op.inSampleSize = hRatio } } - ips=FileInputStream(path) op.inJustDecodeBounds = false - return BitmapFactory.decodeStream(ips,null,op) + return BitmapFactory.decodeFileDescriptor(ips.fd, null, op) } /** 从path中获取Bitmap图片 @@ -54,15 +53,16 @@ object BitmapUtils { * @return */ fun decodeBitmap(path: String): Bitmap? { + val opts = BitmapFactory.Options() - opts.inPreferredConfig=Config.RGB_565 - var ips=FileInputStream(path) + opts.inPreferredConfig = Config.RGB_565 + val ips = FileInputStream(path) opts.inJustDecodeBounds = true - BitmapFactory.decodeStream(ips,null,opts) + BitmapFactory.decodeFileDescriptor(ips.fd, null, opts) opts.inSampleSize = computeSampleSize(opts, -1, 128 * 128) opts.inJustDecodeBounds = false - ips=FileInputStream(path) - return BitmapFactory.decodeStream(ips,null,opts) + + return BitmapFactory.decodeFileDescriptor(ips.fd, null, opts) } /**