some corrections to loading gifs
This commit is contained in:
parent
b421dc273f
commit
809d9b81a2
2 changed files with 12 additions and 3 deletions
|
@ -28,7 +28,6 @@ import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.fragment_holder.*
|
import kotlinx.android.synthetic.main.fragment_holder.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
||||||
private var mMedium: Medium? = null
|
private var mMedium: Medium? = null
|
||||||
private var mIsFullScreen = false
|
private var mIsFullScreen = false
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.davemorrissey.labs.subscaleview.ImageSource
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
|
import com.simplemobiletools.gallery.activities.PhotoActivity
|
||||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||||
import com.simplemobiletools.gallery.extensions.*
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
||||||
|
@ -48,10 +49,14 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
view = inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup
|
view = inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup
|
||||||
|
|
||||||
|
if (!isFragmentVisible && activity is PhotoActivity) {
|
||||||
|
isFragmentVisible = true
|
||||||
|
}
|
||||||
|
|
||||||
medium = arguments.getSerializable(MEDIUM) as Medium
|
medium = arguments.getSerializable(MEDIUM) as Medium
|
||||||
if (medium.path.startsWith("content://")) {
|
if (medium.path.startsWith("content://")) {
|
||||||
val originalPath = medium.path
|
val originalPath = medium.path
|
||||||
medium.path = context.getRealPathFromURI(Uri.parse(originalPath)) ?: ""
|
medium.path = context.getRealPathFromURI(Uri.parse(originalPath)) ?: medium.path
|
||||||
|
|
||||||
if (medium.path.isEmpty()) {
|
if (medium.path.isEmpty()) {
|
||||||
var out: FileOutputStream? = null
|
var out: FileOutputStream? = null
|
||||||
|
@ -155,7 +160,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun loadImage() {
|
private fun loadImage() {
|
||||||
if (medium.isGif()) {
|
if (medium.isGif()) {
|
||||||
gifDrawable = GifDrawable(medium.path)
|
gifDrawable = if (medium.path.startsWith("content://") || medium.path.startsWith("file://")) {
|
||||||
|
GifDrawable(context.contentResolver, Uri.parse(medium.path))
|
||||||
|
} else {
|
||||||
|
GifDrawable(medium.path)
|
||||||
|
}
|
||||||
|
|
||||||
if (!isFragmentVisible) {
|
if (!isFragmentVisible) {
|
||||||
gifDrawable!!.stop()
|
gifDrawable!!.stop()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue