use Picasso for loading fullscreen images

This commit is contained in:
tibbi 2017-03-17 19:46:44 +01:00
parent a6622ef9e3
commit 6a97a47d76
5 changed files with 14 additions and 28 deletions

View file

@ -38,6 +38,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.chrisbanes:PhotoView:1.3.1'
compile 'it.sephiroth.android.exif:library:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

View file

@ -1,19 +1,2 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in $ANDROID_HOME/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class com.simplemobiletools.** { *; }
-dontwarn com.simplemobiletools.**

View file

@ -160,6 +160,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
view_pager?.apply {
offscreenPageLimit = 2
adapter = pagerAdapter
currentItem = mPos
addOnPageChangeListener(this@ViewPagerActivity)

View file

@ -6,19 +6,20 @@ import android.graphics.BitmapFactory
import android.graphics.Matrix
import android.net.Uri
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.beVisible
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
import com.simplemobiletools.gallery.helpers.MEDIUM
import com.simplemobiletools.gallery.models.Medium
import com.squareup.picasso.Picasso
import it.sephiroth.android.library.exif2.ExifInterface
import kotlinx.android.synthetic.main.pager_photo_item.view.*
import uk.co.senab.photoview.PhotoViewAttacher
@ -118,6 +119,7 @@ class PhotoFragment : ViewPagerFragment() {
private fun loadImage() {
if (medium.isGif()) {
view.photo_view.beGone()
view.gif_holder.beVisible()
Glide.with(this)
.load(medium.path)
.asGif()
@ -130,13 +132,12 @@ class PhotoFragment : ViewPagerFragment() {
}
private fun loadBitmap(degrees: Float = 0f) {
Glide.with(this)
.load(medium.path)
.asBitmap()
.transform(GlideRotateTransformation(context, degrees))
.format(if (medium.isPng()) DecodeFormat.PREFER_ARGB_8888 else DecodeFormat.PREFER_RGB_565)
.thumbnail(0.2f)
.diskCacheStrategy(DiskCacheStrategy.NONE)
val metrics = DisplayMetrics()
activity.windowManager.defaultDisplay.getMetrics(metrics)
Picasso.with(activity)
.load("file:${medium.path}")
.resize(metrics.widthPixels * 2, metrics.heightPixels * 2)
.centerInside()
.into(view.photo_view)
}
@ -146,7 +147,6 @@ class PhotoFragment : ViewPagerFragment() {
override fun onDestroyView() {
super.onDestroyView()
Glide.clear(view.photo_view)
Glide.clear(view.gif_holder)
}

View file

@ -8,7 +8,8 @@
<ImageView
android:id="@+id/gif_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:visibility="gone"/>
<uk.co.senab.photoview.PhotoView
android:id="@+id/photo_view"