mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-31 12:16:44 +01:00
replace GridLayoutManager with MyGridLayoutManager
This commit is contained in:
parent
711c714686
commit
1bcbe96b04
4 changed files with 14 additions and 12 deletions
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue