diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index e0220548e..2c1702a3b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -4,10 +4,12 @@ import android.Manifest import android.app.Activity import android.content.Intent import android.content.pm.PackageManager +import android.content.res.Configuration import android.os.Bundle import android.provider.MediaStore import android.support.v4.app.ActivityCompat import android.support.v7.widget.GridLayoutManager +import android.util.DisplayMetrics import android.view.Menu import android.view.MenuItem import com.google.gson.Gson @@ -49,9 +51,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mCurrAsyncTask: GetDirectoriesAsynctask? = null + companion object { + var thumbnailSize = 0 + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + updateThumbnailSize() mIsPickImageIntent = isPickImageIntent(intent) mIsPickVideoIntent = isPickVideoIntent(intent) @@ -115,6 +122,17 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { 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() { if (hasWriteStoragePermission()) { if (config.showAll) @@ -216,11 +234,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun increaseColumnCount() { config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() + updateThumbnailSize() } private fun reduceColumnCount() { config.dirColumnCnt = --(directories_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() + updateThumbnailSize() } private fun isPickImageIntent(intent: Intent) = isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 5beaeff18..8e52c7a3a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -61,7 +61,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false) } - updateThumbnailWidth() + updateThumbnailSize() media_refresh_layout.setOnRefreshListener({ getMedia() }) mPath = intent.getStringExtra(DIRECTORY) mStoredAnimateGifs = config.animateGifs @@ -99,10 +99,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { override fun onConfigurationChanged(newConfig: Configuration?) { super.onConfigurationChanged(newConfig) - updateThumbnailWidth() + updateThumbnailSize() } - private fun updateThumbnailWidth() { + private fun updateThumbnailSize() { val metrics = DisplayMetrics() windowManager.defaultDisplay.getMetrics(metrics) thumbnailSize = metrics.widthPixels / config.mediaColumnCnt @@ -277,13 +277,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun increaseColumnCount() { config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() - updateThumbnailWidth() + updateThumbnailSize() } private fun reduceColumnCount() { config.mediaColumnCnt = --(media_grid.layoutManager as GridLayoutManager).spanCount invalidateOptionsMenu() - updateThumbnailWidth() + updateThumbnailSize() } override fun deleteFiles(files: ArrayList) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index b50ac2d51..b8b995aba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -9,7 +9,6 @@ import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback import com.bignerdranch.android.multiselector.MultiSelector import com.bignerdranch.android.multiselector.SwappingHolder import com.bumptech.glide.Glide -import com.bumptech.glide.load.DecodeFormat import com.bumptech.glide.load.engine.DiskCacheStrategy import com.simplemobiletools.commons.asynctasks.CopyMoveTask import com.simplemobiletools.commons.dialogs.ConfirmationDialog @@ -17,11 +16,13 @@ import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.RenameItemDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.R +import com.simplemobiletools.gallery.activities.MainActivity import com.simplemobiletools.gallery.activities.SimpleActivity import com.simplemobiletools.gallery.dialogs.CopyDialog import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog import com.simplemobiletools.gallery.extensions.* import com.simplemobiletools.gallery.models.Directory +import com.squareup.picasso.Picasso import kotlinx.android.synthetic.main.directory_item.view.* import kotlinx.android.synthetic.main.directory_tmb.view.* import java.io.File @@ -328,21 +329,32 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { + var size: Long) : Serializable, Comparable { companion object { private val serialVersionUID = -6553649863575455L var sorting: Int = 0