mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
replace Picasso with Glide everywhere once again
This commit is contained in:
parent
d277dee1b9
commit
a150e5da04
10 changed files with 39 additions and 84 deletions
|
@ -32,13 +32,12 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.simplemobiletools:commons:2.13.3'
|
compile 'com.simplemobiletools:commons:2.13.4'
|
||||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
|
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
|
||||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||||
compile 'com.google.code.gson:gson:2.8.0'
|
compile 'com.google.code.gson:gson:2.8.0'
|
||||||
compile 'com.github.chrisbanes:PhotoView:1.3.1'
|
compile 'com.github.chrisbanes:PhotoView:1.3.1'
|
||||||
compile 'it.sephiroth.android.exif:library:1.0.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"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,11 @@ import android.Manifest
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.support.v4.app.ActivityCompat
|
import android.support.v4.app.ActivityCompat
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
@ -52,14 +50,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
|
|
||||||
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
||||||
|
|
||||||
companion object {
|
|
||||||
var thumbnailSize = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
updateThumbnailSize()
|
|
||||||
|
|
||||||
mIsPickImageIntent = isPickImageIntent(intent)
|
mIsPickImageIntent = isPickImageIntent(intent)
|
||||||
mIsPickVideoIntent = isPickVideoIntent(intent)
|
mIsPickVideoIntent = isPickVideoIntent(intent)
|
||||||
|
@ -124,17 +117,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
config.isFirstRun = false
|
config.isFirstRun = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
|
||||||
super.onConfigurationChanged(newConfig)
|
|
||||||
updateThumbnailSize()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateThumbnailSize() {
|
|
||||||
val metrics = DisplayMetrics()
|
|
||||||
windowManager.defaultDisplay.getMetrics(metrics)
|
|
||||||
thumbnailSize = metrics.widthPixels / config.dirColumnCnt
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun tryloadGallery() {
|
private fun tryloadGallery() {
|
||||||
if (hasWriteStoragePermission()) {
|
if (hasWriteStoragePermission()) {
|
||||||
if (config.showAll)
|
if (config.showAll)
|
||||||
|
@ -235,13 +217,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun increaseColumnCount() {
|
private fun increaseColumnCount() {
|
||||||
config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount
|
config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
updateThumbnailSize()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reduceColumnCount() {
|
private fun reduceColumnCount() {
|
||||||
config.dirColumnCnt = --(directories_grid.layoutManager as GridLayoutManager).spanCount
|
config.dirColumnCnt = --(directories_grid.layoutManager as GridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
updateThumbnailSize()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isPickImageIntent(intent: Intent) = isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent))
|
private fun isPickImageIntent(intent: Intent) = isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent))
|
||||||
|
|
|
@ -3,12 +3,10 @@ package com.simplemobiletools.gallery.activities
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.WallpaperManager
|
import android.app.WallpaperManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
@ -48,10 +46,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
private var mLoadedInitialPhotos = false
|
private var mLoadedInitialPhotos = false
|
||||||
private var mStoredAnimateGifs = true
|
private var mStoredAnimateGifs = true
|
||||||
|
|
||||||
companion object {
|
|
||||||
var thumbnailSize = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_media)
|
setContentView(R.layout.activity_media)
|
||||||
|
@ -61,7 +55,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false)
|
mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateThumbnailSize()
|
|
||||||
media_refresh_layout.setOnRefreshListener({ getMedia() })
|
media_refresh_layout.setOnRefreshListener({ getMedia() })
|
||||||
mPath = intent.getStringExtra(DIRECTORY)
|
mPath = intent.getStringExtra(DIRECTORY)
|
||||||
mStoredAnimateGifs = config.animateGifs
|
mStoredAnimateGifs = config.animateGifs
|
||||||
|
@ -97,17 +90,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
|
||||||
super.onConfigurationChanged(newConfig)
|
|
||||||
updateThumbnailSize()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateThumbnailSize() {
|
|
||||||
val metrics = DisplayMetrics()
|
|
||||||
windowManager.defaultDisplay.getMetrics(metrics)
|
|
||||||
thumbnailSize = metrics.widthPixels / config.mediaColumnCnt
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initializeGallery() {
|
private fun initializeGallery() {
|
||||||
if (isDirEmpty())
|
if (isDirEmpty())
|
||||||
return
|
return
|
||||||
|
@ -277,13 +259,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
private fun increaseColumnCount() {
|
private fun increaseColumnCount() {
|
||||||
config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount
|
config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
updateThumbnailSize()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reduceColumnCount() {
|
private fun reduceColumnCount() {
|
||||||
config.mediaColumnCnt = --(media_grid.layoutManager as GridLayoutManager).spanCount
|
config.mediaColumnCnt = --(media_grid.layoutManager as GridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
updateThumbnailSize()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteFiles(files: ArrayList<File>) {
|
override fun deleteFiles(files: ArrayList<File>) {
|
||||||
|
|
|
@ -182,6 +182,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
|
||||||
view_pager?.apply {
|
view_pager?.apply {
|
||||||
|
offscreenPageLimit = 2
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
currentItem = mPos
|
currentItem = mPos
|
||||||
addOnPageChangeListener(this@ViewPagerActivity)
|
addOnPageChangeListener(this@ViewPagerActivity)
|
||||||
|
|
|
@ -18,7 +18,6 @@ import com.simplemobiletools.commons.extensions.isImageVideoGif
|
||||||
import com.simplemobiletools.commons.extensions.needsStupidWritePermissions
|
import com.simplemobiletools.commons.extensions.needsStupidWritePermissions
|
||||||
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.MainActivity
|
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
import com.simplemobiletools.gallery.dialogs.CopyDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
||||||
|
@ -330,7 +329,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
||||||
photo_cnt.text = directory.mediaCnt.toString()
|
photo_cnt.text = directory.mediaCnt.toString()
|
||||||
dir_pin.visibility = if (isPinned) View.VISIBLE else View.GONE
|
dir_pin.visibility = if (isPinned) View.VISIBLE else View.GONE
|
||||||
toggleItemSelection(this, markedItems.contains(pos), pos)
|
toggleItemSelection(this, markedItems.contains(pos), pos)
|
||||||
activity.loadImage(directory.thumbnail, MainActivity.thumbnailSize, dir_thumbnail)
|
activity.loadImage(directory.thumbnail, dir_thumbnail)
|
||||||
|
|
||||||
setOnClickListener { viewClicked(multiSelector, directory, pos) }
|
setOnClickListener { viewClicked(multiSelector, directory, pos) }
|
||||||
setOnLongClickListener {
|
setOnLongClickListener {
|
||||||
|
|
|
@ -245,7 +245,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
photo_name.beVisibleIf(displayFilenames)
|
photo_name.beVisibleIf(displayFilenames)
|
||||||
photo_name.text = medium.name
|
photo_name.text = medium.name
|
||||||
toggleItemSelection(this, markedItems.contains(pos), pos)
|
toggleItemSelection(this, markedItems.contains(pos), pos)
|
||||||
activity.loadImage(medium.path, MediaActivity.thumbnailSize, medium_thumbnail)
|
activity.loadImage(medium.path, medium_thumbnail)
|
||||||
|
|
||||||
setOnClickListener { viewClicked(multiSelector, medium, pos) }
|
setOnClickListener { viewClicked(multiSelector, medium, pos) }
|
||||||
setOnLongClickListener {
|
setOnLongClickListener {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewConfiguration
|
import android.view.ViewConfiguration
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
|
@ -23,7 +24,6 @@ import com.simplemobiletools.gallery.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
import com.simplemobiletools.gallery.helpers.REQUEST_SET_WALLPAPER
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import com.simplemobiletools.gallery.views.MySquareImageView
|
import com.simplemobiletools.gallery.views.MySquareImageView
|
||||||
import com.squareup.picasso.Picasso
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ fun Activity.hasNavBar(): Boolean {
|
||||||
|
|
||||||
fun SimpleActivity.launchAbout() {
|
fun SimpleActivity.launchAbout() {
|
||||||
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_MULTISELECT or LICENSE_RTL
|
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_MULTISELECT or LICENSE_RTL
|
||||||
or LICENSE_PHOTOVIEW or LICENSE_PICASSO, BuildConfig.VERSION_NAME)
|
or LICENSE_PHOTOVIEW, BuildConfig.VERSION_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AppCompatActivity.showSystemUI() {
|
fun AppCompatActivity.showSystemUI() {
|
||||||
|
@ -186,20 +186,24 @@ fun SimpleActivity.removeNoMedia(path: String, callback: () -> Unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Activity.loadImage(path: String, size: Int, target: MySquareImageView) {
|
fun Activity.loadImage(path: String, target: MySquareImageView) {
|
||||||
if (path.isImageFast()) {
|
if (path.isImageFast() || path.isVideoFast()) {
|
||||||
Picasso.with(this)
|
if (path.isPng()) {
|
||||||
.load("file:$path")
|
Glide.with(this)
|
||||||
.resize(size, size)
|
.load(path)
|
||||||
.centerCrop()
|
.asBitmap()
|
||||||
.into(target)
|
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
} else if (path.isVideoFast()) {
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
Glide.with(this)
|
.centerCrop()
|
||||||
.load(path)
|
.into(target)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
} else {
|
||||||
.centerCrop()
|
Glide.with(this)
|
||||||
.crossFade()
|
.load(path)
|
||||||
.into(target)
|
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
|
.centerCrop()
|
||||||
|
.crossFade()
|
||||||
|
.into(target)
|
||||||
|
}
|
||||||
} else if (path.isGif()) {
|
} else if (path.isGif()) {
|
||||||
if (MediaAdapter.animateGifs) {
|
if (MediaAdapter.animateGifs) {
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
|
|
|
@ -11,16 +11,14 @@ 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.Priority
|
||||||
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
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.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.extensions.getRealPathFromURI
|
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
||||||
|
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
||||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import com.squareup.picasso.Picasso
|
|
||||||
import it.sephiroth.android.library.exif2.ExifInterface
|
import it.sephiroth.android.library.exif2.ExifInterface
|
||||||
import kotlinx.android.synthetic.main.pager_photo_item.view.*
|
import kotlinx.android.synthetic.main.pager_photo_item.view.*
|
||||||
import uk.co.senab.photoview.PhotoViewAttacher
|
import uk.co.senab.photoview.PhotoViewAttacher
|
||||||
|
@ -32,6 +30,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
lateinit var medium: Medium
|
lateinit var medium: Medium
|
||||||
lateinit var view: ViewGroup
|
lateinit var view: ViewGroup
|
||||||
private var isFragmentVisible = false
|
private var isFragmentVisible = false
|
||||||
|
private var wasInit = false
|
||||||
|
|
||||||
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
|
||||||
|
@ -73,7 +72,6 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view.gif_holder.setOnClickListener { photoClicked() }
|
|
||||||
view.photo_view.setOnPhotoTapListener(object : PhotoViewAttacher.OnPhotoTapListener {
|
view.photo_view.setOnPhotoTapListener(object : PhotoViewAttacher.OnPhotoTapListener {
|
||||||
override fun onPhotoTap(view: View?, x: Float, y: Float) {
|
override fun onPhotoTap(view: View?, x: Float, y: Float) {
|
||||||
photoClicked()
|
photoClicked()
|
||||||
|
@ -88,6 +86,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||||
listener?.systemUiVisibilityChanged(visibility)
|
listener?.systemUiVisibilityChanged(visibility)
|
||||||
}
|
}
|
||||||
|
wasInit = true
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
@ -119,28 +118,26 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun loadImage() {
|
private fun loadImage() {
|
||||||
if (medium.isGif()) {
|
if (medium.isGif()) {
|
||||||
view.photo_view.beGone()
|
|
||||||
view.gif_holder.beVisible()
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(medium.path)
|
.load(medium.path)
|
||||||
.asGif()
|
.asGif()
|
||||||
.crossFade()
|
.crossFade()
|
||||||
.priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.LOW)
|
.priority(if (isFragmentVisible) Priority.IMMEDIATE else Priority.LOW)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||||
.into(view.gif_holder)
|
.into(view.photo_view)
|
||||||
} else {
|
} else {
|
||||||
loadBitmap()
|
loadBitmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadBitmap(degrees: Float = 0f) {
|
private fun loadBitmap(degrees: Float = 0f) {
|
||||||
val density = ViewPagerActivity.screenDensity
|
Glide.with(this)
|
||||||
Picasso.with(activity)
|
.load(medium.path)
|
||||||
.load("file:${medium.path}")
|
.asBitmap()
|
||||||
.resize((ViewPagerActivity.screenWidth * density).toInt(), (ViewPagerActivity.screenHeight * density).toInt())
|
.transform(GlideRotateTransformation(context, degrees))
|
||||||
.priority(if (isFragmentVisible) Picasso.Priority.HIGH else Picasso.Priority.LOW)
|
.format(if (medium.isPng()) DecodeFormat.PREFER_ARGB_8888 else DecodeFormat.PREFER_RGB_565)
|
||||||
.rotate(degrees)
|
.thumbnail(0.1f)
|
||||||
.centerInside()
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
.into(view.photo_view)
|
.into(view.photo_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +147,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
Glide.clear(view.gif_holder)
|
Glide.clear(view.photo_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simplemobiletools.gallery.models
|
package com.simplemobiletools.gallery.models
|
||||||
|
|
||||||
import com.simplemobiletools.commons.extensions.isGif
|
import com.simplemobiletools.commons.extensions.isGif
|
||||||
|
import com.simplemobiletools.commons.extensions.isPng
|
||||||
import com.simplemobiletools.gallery.helpers.SORT_BY_DATE_MODIFIED
|
import com.simplemobiletools.gallery.helpers.SORT_BY_DATE_MODIFIED
|
||||||
import com.simplemobiletools.gallery.helpers.SORT_BY_NAME
|
import com.simplemobiletools.gallery.helpers.SORT_BY_NAME
|
||||||
import com.simplemobiletools.gallery.helpers.SORT_BY_SIZE
|
import com.simplemobiletools.gallery.helpers.SORT_BY_SIZE
|
||||||
|
@ -15,7 +16,7 @@ data class Medium(val name: String, var path: String, val isVideo: Boolean, val
|
||||||
|
|
||||||
fun isGif() = path.isGif()
|
fun isGif() = path.isGif()
|
||||||
|
|
||||||
fun isPng() = path.endsWith(".png", true)
|
fun isPng() = path.isPng()
|
||||||
|
|
||||||
fun isImage() = !isGif() && !isVideo
|
fun isImage() = !isGif() && !isVideo
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/gif_holder"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<uk.co.senab.photoview.PhotoView
|
<uk.co.senab.photoview.PhotoView
|
||||||
android:id="@+id/photo_view"
|
android:id="@+id/photo_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue