increase the image load priority of initially opened images

This commit is contained in:
tibbi 2017-03-17 20:17:48 +01:00
parent 19d4ff53cb
commit aa55dfbb15

View file

@ -10,6 +10,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.Priority
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.simplemobiletools.commons.extensions.beGone import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.beVisible import com.simplemobiletools.commons.extensions.beVisible
@ -124,6 +125,7 @@ class PhotoFragment : ViewPagerFragment() {
.load(medium.path) .load(medium.path)
.asGif() .asGif()
.crossFade() .crossFade()
.priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.LOW)
.diskCacheStrategy(DiskCacheStrategy.SOURCE) .diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into(view.gif_holder) .into(view.gif_holder)
} else { } else {
@ -135,6 +137,7 @@ class PhotoFragment : ViewPagerFragment() {
Picasso.with(activity) Picasso.with(activity)
.load("file:${medium.path}") .load("file:${medium.path}")
.resize(ViewPagerActivity.screenWidth * 2, ViewPagerActivity.screenHeight * 2) .resize(ViewPagerActivity.screenWidth * 2, ViewPagerActivity.screenHeight * 2)
.priority(if (isFragmentVisible) Picasso.Priority.HIGH else Picasso.Priority.LOW)
.rotate(degrees) .rotate(degrees)
.centerInside() .centerInside()
.into(view.photo_view) .into(view.photo_view)