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 232e2835a..a3883847d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -342,11 +342,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } else { setupListLayoutManager() } - - getDirectoryAdapter()?.apply { - setupZoomListener(mZoomListener) - setupDragListener(true) - } } private fun setupGridLayoutManager() { @@ -360,20 +355,28 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } layoutManager.spanCount = config.dirColumnCnt - mZoomListener = object : MyRecyclerView.MyZoomListener { - override fun zoomIn() { - if (layoutManager.spanCount > 1) { - reduceColumnCount() - getRecyclerAdapter().finishActMode() - } - } + } - override fun zoomOut() { - if (layoutManager.spanCount < MAX_COLUMN_COUNT) { - increaseColumnCount() - getRecyclerAdapter().finishActMode() + private fun initZoomListener() { + if (config.viewTypeFolders == VIEW_TYPE_GRID) { + val layoutManager = directories_grid.layoutManager as GridLayoutManager + mZoomListener = object : MyRecyclerView.MyZoomListener { + override fun zoomIn() { + if (layoutManager.spanCount > 1) { + reduceColumnCount() + getRecyclerAdapter().finishActMode() + } + } + + override fun zoomOut() { + if (layoutManager.spanCount < MAX_COLUMN_COUNT) { + increaseColumnCount() + getRecyclerAdapter().finishActMode() + } } } + } else { + mZoomListener = null } } @@ -554,12 +557,18 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun setupAdapter() { val currAdapter = directories_grid.adapter if (currAdapter == null) { - directories_grid.adapter = DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) { + initZoomListener() + DirectoryAdapter(this, mDirs, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent)) { itemClicked((it as Directory).path) + }.apply { + setupZoomListener(mZoomListener) + setupDragListener(true) + directories_grid.adapter = this } } else { (currAdapter as DirectoryAdapter).updateDirs(mDirs) } + setupScrollDirection() } 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 d4fdd4955..0b5622186 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -176,8 +176,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val currAdapter = media_grid.adapter if (currAdapter == null) { - media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) { + initZoomListener() + MediaAdapter(this, mMedia, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, mAllowPickingMultiple, media_grid) { itemClicked((it as Medium).path) + }.apply { + setupZoomListener(mZoomListener) + setupDragListener(true) + media_grid.adapter = this } } else { (currAdapter as MediaAdapter).updateMedia(mMedia) @@ -402,11 +407,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } else { setupListLayoutManager() } - - getMediaAdapter()?.apply { - setupZoomListener(mZoomListener) - setupDragListener(true) - } } private fun setupGridLayoutManager() { @@ -420,20 +420,28 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } layoutManager.spanCount = config.mediaColumnCnt - mZoomListener = object : MyRecyclerView.MyZoomListener { - override fun zoomIn() { - if (layoutManager.spanCount > 1) { - reduceColumnCount() - getRecyclerAdapter().finishActMode() - } - } + } - override fun zoomOut() { - if (layoutManager.spanCount < MAX_COLUMN_COUNT) { - increaseColumnCount() - getRecyclerAdapter().finishActMode() + private fun initZoomListener() { + if (config.viewTypeFiles == VIEW_TYPE_GRID) { + val layoutManager = media_grid.layoutManager as GridLayoutManager + mZoomListener = object : MyRecyclerView.MyZoomListener { + override fun zoomIn() { + if (layoutManager.spanCount > 1) { + reduceColumnCount() + getRecyclerAdapter().finishActMode() + } + } + + override fun zoomOut() { + if (layoutManager.spanCount < MAX_COLUMN_COUNT) { + increaseColumnCount() + getRecyclerAdapter().finishActMode() + } } } + } else { + mZoomListener = null } }