From 5be34f27eea021493390bd699d3e5ee2d468d10d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 18 Jun 2017 21:12:50 +0200 Subject: [PATCH] set thumbnail holder properties based on the scroll orientation --- .../gallery/activities/MainActivity.kt | 15 ++++++++++++--- .../gallery/activities/MediaActivity.kt | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) 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 24107cc95..a8efedb8a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -14,6 +14,8 @@ import android.support.v4.app.ActivityCompat import android.support.v7.widget.GridLayoutManager import android.view.Menu import android.view.MenuItem +import android.view.ViewGroup +import android.widget.FrameLayout import com.google.gson.Gson import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.models.Release @@ -138,7 +140,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { showAllMedia() else getDirectories() - handleZooming() + setupLayoutManager() checkIfColorChanged() } else { ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION) @@ -218,9 +220,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter) - private fun handleZooming() { + private fun setupLayoutManager() { val layoutManager = directories_grid.layoutManager as GridLayoutManager - layoutManager.orientation = if (config.scrollHorizontally) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL + if (config.scrollHorizontally) { + layoutManager.orientation = GridLayoutManager.HORIZONTAL + directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) + } else { + layoutManager.orientation = GridLayoutManager.VERTICAL + directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + } + layoutManager.spanCount = config.dirColumnCnt MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener { override fun zoomIn() { 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 fd7449061..3967ed214 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -12,6 +12,8 @@ import android.support.v7.widget.GridLayoutManager import android.util.Log import android.view.Menu import android.view.MenuItem +import android.view.ViewGroup +import android.widget.FrameLayout import com.bumptech.glide.Glide import com.bumptech.glide.request.animation.GlideAnimation import com.bumptech.glide.request.target.SimpleTarget @@ -107,7 +109,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val dirName = getHumanizedFilename(mPath) title = if (mShowAll) resources.getString(R.string.all_folders) else dirName getMedia() - handleZooming() + setupLayoutManager() checkIfColorChanged() } else { finish() @@ -294,9 +296,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter) - private fun handleZooming() { + private fun setupLayoutManager() { val layoutManager = media_grid.layoutManager as GridLayoutManager - layoutManager.orientation = if (config.scrollHorizontally) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL + if (config.scrollHorizontally) { + layoutManager.orientation = GridLayoutManager.HORIZONTAL + media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) + } else { + layoutManager.orientation = GridLayoutManager.VERTICAL + media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + } + layoutManager.spanCount = config.mediaColumnCnt MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener { override fun zoomIn() {