diff --git a/app/build.gradle b/app/build.gradle index bc540c805..40817a42c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index c4840d61f..a9c0f371b 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -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.** diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index c966cdfe7..183a929c7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index e41713d3c..675fd7135 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -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) } diff --git a/app/src/main/res/layout/pager_photo_item.xml b/app/src/main/res/layout/pager_photo_item.xml index 814b0a3ed..a3b004a57 100644 --- a/app/src/main/res/layout/pager_photo_item.xml +++ b/app/src/main/res/layout/pager_photo_item.xml @@ -8,7 +8,8 @@ + android:layout_height="match_parent" + android:visibility="gone"/>