set thumbnail holder properties based on the scroll orientation
This commit is contained in:
parent
88de8a4d2a
commit
5be34f27ee
2 changed files with 24 additions and 6 deletions
|
@ -14,6 +14,8 @@ import android.support.v4.app.ActivityCompat
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.FrameLayout
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
|
@ -138,7 +140,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
showAllMedia()
|
showAllMedia()
|
||||||
else
|
else
|
||||||
getDirectories()
|
getDirectories()
|
||||||
handleZooming()
|
setupLayoutManager()
|
||||||
checkIfColorChanged()
|
checkIfColorChanged()
|
||||||
} else {
|
} else {
|
||||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION)
|
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 getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter)
|
||||||
|
|
||||||
private fun handleZooming() {
|
private fun setupLayoutManager() {
|
||||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
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
|
layoutManager.spanCount = config.dirColumnCnt
|
||||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
|
|
|
@ -12,6 +12,8 @@ import android.support.v7.widget.GridLayoutManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.FrameLayout
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
import com.bumptech.glide.request.target.SimpleTarget
|
import com.bumptech.glide.request.target.SimpleTarget
|
||||||
|
@ -107,7 +109,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
val dirName = getHumanizedFilename(mPath)
|
val dirName = getHumanizedFilename(mPath)
|
||||||
title = if (mShowAll) resources.getString(R.string.all_folders) else dirName
|
title = if (mShowAll) resources.getString(R.string.all_folders) else dirName
|
||||||
getMedia()
|
getMedia()
|
||||||
handleZooming()
|
setupLayoutManager()
|
||||||
checkIfColorChanged()
|
checkIfColorChanged()
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
|
@ -294,9 +296,16 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
|
|
||||||
private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter)
|
private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter)
|
||||||
|
|
||||||
private fun handleZooming() {
|
private fun setupLayoutManager() {
|
||||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
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
|
layoutManager.spanCount = config.mediaColumnCnt
|
||||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
|
|
Loading…
Reference in a new issue