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 6b722080a..3c59a8361 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -22,6 +22,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.Release +import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.gallery.BuildConfig import com.simplemobiletools.gallery.R @@ -369,7 +370,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun setupGridLayoutManager() { - val layoutManager = directories_grid.layoutManager as GridLayoutManager + val layoutManager = directories_grid.layoutManager as MyGridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = GridLayoutManager.HORIZONTAL directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) @@ -383,7 +384,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun initZoomListener() { if (config.viewTypeFolders == VIEW_TYPE_GRID) { - val layoutManager = directories_grid.layoutManager as GridLayoutManager + val layoutManager = directories_grid.layoutManager as MyGridLayoutManager mZoomListener = object : MyRecyclerView.MyZoomListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { @@ -405,7 +406,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun setupListLayoutManager() { - val layoutManager = directories_grid.layoutManager as GridLayoutManager + val layoutManager = directories_grid.layoutManager as MyGridLayoutManager layoutManager.spanCount = 1 layoutManager.orientation = GridLayoutManager.VERTICAL directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) @@ -424,7 +425,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun increaseColumnCount() { directories_vertical_fastscroller.measureRecyclerViewOnRedraw() directories_horizontal_fastscroller.measureRecyclerViewOnRedraw() - config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount + config.dirColumnCnt = ++(directories_grid.layoutManager as MyGridLayoutManager).spanCount invalidateOptionsMenu() directories_grid.adapter?.notifyDataSetChanged() } @@ -432,7 +433,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun reduceColumnCount() { directories_vertical_fastscroller.measureRecyclerViewOnRedraw() directories_horizontal_fastscroller.measureRecyclerViewOnRedraw() - config.dirColumnCnt = --(directories_grid.layoutManager as GridLayoutManager).spanCount + config.dirColumnCnt = --(directories_grid.layoutManager as MyGridLayoutManager).spanCount invalidateOptionsMenu() directories_grid.adapter?.notifyDataSetChanged() } 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 8051f0ded..82d8990ad 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -27,6 +27,7 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE import com.simplemobiletools.commons.models.RadioItem +import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.adapters.MediaAdapter @@ -502,7 +503,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun setupGridLayoutManager() { - val layoutManager = media_grid.layoutManager as GridLayoutManager + val layoutManager = media_grid.layoutManager as MyGridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = GridLayoutManager.HORIZONTAL media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) @@ -516,7 +517,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun initZoomListener() { if (config.viewTypeFiles == VIEW_TYPE_GRID) { - val layoutManager = media_grid.layoutManager as GridLayoutManager + val layoutManager = media_grid.layoutManager as MyGridLayoutManager mZoomListener = object : MyRecyclerView.MyZoomListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { @@ -538,7 +539,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun setupListLayoutManager() { - val layoutManager = media_grid.layoutManager as GridLayoutManager + val layoutManager = media_grid.layoutManager as MyGridLayoutManager layoutManager.spanCount = 1 layoutManager.orientation = GridLayoutManager.VERTICAL media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) @@ -548,7 +549,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun increaseColumnCount() { media_vertical_fastscroller.measureRecyclerViewOnRedraw() media_horizontal_fastscroller.measureRecyclerViewOnRedraw() - config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount + config.mediaColumnCnt = ++(media_grid.layoutManager as MyGridLayoutManager).spanCount invalidateOptionsMenu() media_grid.adapter?.notifyDataSetChanged() } @@ -556,7 +557,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun reduceColumnCount() { media_vertical_fastscroller.measureRecyclerViewOnRedraw() media_horizontal_fastscroller.measureRecyclerViewOnRedraw() - config.mediaColumnCnt = --(media_grid.layoutManager as GridLayoutManager).spanCount + config.mediaColumnCnt = --(media_grid.layoutManager as MyGridLayoutManager).spanCount invalidateOptionsMenu() media_grid.adapter?.notifyDataSetChanged() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt index cbaa30443..ab5c51e01 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickDirectoryDialog.kt @@ -26,7 +26,7 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID init { - (view.directories_grid.layoutManager as GridLayoutManager).apply { + (view.directories_grid.layoutManager as MyGridLayoutManager).apply { orientation = if (activity.config.scrollHorizontally && isGridViewType) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1 } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt index b94fd0aed..2fd295e6f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/PickMediumDialog.kt @@ -22,7 +22,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c var isGridViewType = activity.config.viewTypeFiles == VIEW_TYPE_GRID init { - (view.media_grid.layoutManager as GridLayoutManager).apply { + (view.media_grid.layoutManager as MyGridLayoutManager).apply { orientation = if (activity.config.scrollHorizontally && isGridViewType) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL spanCount = if (isGridViewType) activity.config.mediaColumnCnt else 1 }