Update PagerPageHolder.kt

This commit is contained in:
Jay 2019-04-13 09:44:25 -07:00
parent 1e49b4543f
commit 220cdd3c05

View File

@ -4,8 +4,10 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.BitmapFactory
import android.graphics.PointF
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.support.v4.graphics.ColorUtils
import android.view.GestureDetector
import android.view.Gravity
import android.view.MotionEvent
@ -255,10 +257,24 @@ class PagerPageHolder(
launchUI {
val image = async { BitmapFactory.decodeByteArray(bytesArray, 0, bytesArray.size) }
imageView.background = ImageUtil.autoSetBackground(image.await())
if (!viewer.config.imageCropBorders)
val bg = ImageUtil.autoSetBackground(image.await())
imageView.background = bg
if (!viewer.config.imageCropBorders) {
if (bg is ColorDrawable) {
val array = FloatArray(3)
ColorUtils.colorToHSL(bg.color, array)
if (array[1] < 0.2) {
val bytesStream = bytesArray.inputStream()
imageView.setImage(ImageSource.inputStream(bytesStream))
bytesStream.close()
}
else
imageView.setImage(ImageSource.bitmap(image.await()))
}
else
imageView.setImage(ImageSource.bitmap(image.await()))
}
}
}
else {
initSubsamplingImageView().setImage(ImageSource.inputStream(openStream!!))