mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
set a background to subsampled images to avoid glitches at too small images
This commit is contained in:
parent
edf60b77b3
commit
aae7c39058
2 changed files with 27 additions and 1 deletions
|
@ -3,7 +3,9 @@ package com.simplemobiletools.gallery.fragments
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
|
import android.graphics.Color
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -22,6 +24,7 @@ import com.simplemobiletools.commons.extensions.beVisible
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||||
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
||||||
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
||||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||||
|
@ -112,6 +115,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
} else {
|
} else {
|
||||||
view.subsampling_view.recycle()
|
view.subsampling_view.recycle()
|
||||||
view.subsampling_view.beGone()
|
view.subsampling_view.beGone()
|
||||||
|
view.subsampling_view.background = ColorDrawable(Color.TRANSPARENT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,12 +186,32 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addZoomableView() {
|
private fun addZoomableView() {
|
||||||
if (!medium.isPng() && isMenuVisible && view.subsampling_view.visibility == View.GONE) {
|
if (medium.isJpg() && isMenuVisible && view.subsampling_view.visibility == View.GONE) {
|
||||||
view.subsampling_view.apply {
|
view.subsampling_view.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
setDoubleTapZoomScale(1.4f)
|
setDoubleTapZoomScale(1.4f)
|
||||||
setImage(ImageSource.uri(medium.path))
|
setImage(ImageSource.uri(medium.path))
|
||||||
orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF
|
orientation = SubsamplingScaleImageView.ORIENTATION_USE_EXIF
|
||||||
|
setOnImageEventListener(object : SubsamplingScaleImageView.OnImageEventListener {
|
||||||
|
override fun onImageLoaded() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReady() {
|
||||||
|
background = ColorDrawable(context.config.backgroundColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTileLoadError(p0: java.lang.Exception?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPreviewReleased() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onImageLoadError(p0: java.lang.Exception?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPreviewLoadError(p0: java.lang.Exception?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ data class Medium(val name: String, var path: String, val isVideo: Boolean, val
|
||||||
|
|
||||||
fun isGif() = path.isGif()
|
fun isGif() = path.isGif()
|
||||||
|
|
||||||
|
fun isJpg() = !isPng() && !isGif()
|
||||||
|
|
||||||
fun isImage() = !isGif() && !isVideo
|
fun isImage() = !isGif() && !isVideo
|
||||||
|
|
||||||
fun getMimeType() = File(path).getMimeType()
|
fun getMimeType() = File(path).getMimeType()
|
||||||
|
|
Loading…
Reference in a new issue