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.helpers.SORT_BY_DATE_TAKEN
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.BuildConfig
|
import com.simplemobiletools.gallery.BuildConfig
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
|
@ -369,7 +370,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
layoutManager.orientation = GridLayoutManager.HORIZONTAL
|
layoutManager.orientation = GridLayoutManager.HORIZONTAL
|
||||||
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
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() {
|
private fun initZoomListener() {
|
||||||
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
||||||
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
|
@ -405,7 +406,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = directories_grid.layoutManager as GridLayoutManager
|
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
layoutManager.orientation = GridLayoutManager.VERTICAL
|
layoutManager.orientation = GridLayoutManager.VERTICAL
|
||||||
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
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() {
|
private fun increaseColumnCount() {
|
||||||
directories_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
directories_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
directories_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
directories_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
config.dirColumnCnt = ++(directories_grid.layoutManager as GridLayoutManager).spanCount
|
config.dirColumnCnt = ++(directories_grid.layoutManager as MyGridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
directories_grid.adapter?.notifyDataSetChanged()
|
directories_grid.adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
@ -432,7 +433,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun reduceColumnCount() {
|
private fun reduceColumnCount() {
|
||||||
directories_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
directories_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
directories_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
directories_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
config.dirColumnCnt = --(directories_grid.layoutManager as GridLayoutManager).spanCount
|
config.dirColumnCnt = --(directories_grid.layoutManager as MyGridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
directories_grid.adapter?.notifyDataSetChanged()
|
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.PERMISSION_WRITE_STORAGE
|
||||||
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
import com.simplemobiletools.commons.helpers.REQUEST_EDIT_IMAGE
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
|
import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
import com.simplemobiletools.gallery.adapters.MediaAdapter
|
||||||
|
@ -502,7 +503,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
layoutManager.orientation = GridLayoutManager.HORIZONTAL
|
layoutManager.orientation = GridLayoutManager.HORIZONTAL
|
||||||
media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
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() {
|
private fun initZoomListener() {
|
||||||
if (config.viewTypeFiles == VIEW_TYPE_GRID) {
|
if (config.viewTypeFiles == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||||
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
|
@ -538,7 +539,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
layoutManager.orientation = GridLayoutManager.VERTICAL
|
layoutManager.orientation = GridLayoutManager.VERTICAL
|
||||||
media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
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() {
|
private fun increaseColumnCount() {
|
||||||
media_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
media_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
media_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
media_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount
|
config.mediaColumnCnt = ++(media_grid.layoutManager as MyGridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
media_grid.adapter?.notifyDataSetChanged()
|
media_grid.adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
@ -556,7 +557,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
private fun reduceColumnCount() {
|
private fun reduceColumnCount() {
|
||||||
media_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
media_vertical_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
media_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
media_horizontal_fastscroller.measureRecyclerViewOnRedraw()
|
||||||
config.mediaColumnCnt = --(media_grid.layoutManager as GridLayoutManager).spanCount
|
config.mediaColumnCnt = --(media_grid.layoutManager as MyGridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
media_grid.adapter?.notifyDataSetChanged()
|
media_grid.adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri
|
||||||
var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID
|
var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID
|
||||||
|
|
||||||
init {
|
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
|
orientation = if (activity.config.scrollHorizontally && isGridViewType) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL
|
||||||
spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1
|
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
|
var isGridViewType = activity.config.viewTypeFiles == VIEW_TYPE_GRID
|
||||||
|
|
||||||
init {
|
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
|
orientation = if (activity.config.scrollHorizontally && isGridViewType) GridLayoutManager.HORIZONTAL else GridLayoutManager.VERTICAL
|
||||||
spanCount = if (isGridViewType) activity.config.mediaColumnCnt else 1
|
spanCount = if (isGridViewType) activity.config.mediaColumnCnt else 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue