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 59807e256..2125eab79 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -222,7 +222,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun handleZooming() { val layoutManager = directories_grid.layoutManager as GridLayoutManager layoutManager.spanCount = config.dirColumnCnt - MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener { + MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { reduceColumnCount() @@ -236,6 +236,14 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { DirectoryAdapter.actMode?.finish() } } + + override fun selectItem(position: Int) { + (directories_grid.adapter as DirectoryAdapter).selectItem(position) + } + + override fun selectRange(initialSelection: Int, lastDraggedIndex: Int, minReached: Int, maxReached: Int) { + (directories_grid.adapter as DirectoryAdapter).selectRange(initialSelection, lastDraggedIndex, minReached, maxReached) + } } } 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 06e1fb9c4..17c6df185 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -260,7 +260,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun handleZooming() { val layoutManager = media_grid.layoutManager as GridLayoutManager layoutManager.spanCount = config.mediaColumnCnt - MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener { + MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { reduceColumnCount() @@ -274,6 +274,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { MediaAdapter.actMode?.finish() } } + override fun selectItem(position: Int) { + + } + + override fun selectRange(initialSelection: Int, lastDraggedIndex: Int, minReached: Int, maxReached: Int) { + + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt index 356b31187..07b2f8139 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MyScalableRecyclerView.kt @@ -7,7 +7,6 @@ import android.util.AttributeSet import android.view.MotionEvent import android.view.ScaleGestureDetector import com.simplemobiletools.gallery.R -import com.simplemobiletools.gallery.adapters.DirectoryAdapter // drag selection is based on https://github.com/afollestad/drag-select-recyclerview class MyScalableRecyclerView : RecyclerView { @@ -35,7 +34,7 @@ class MyScalableRecyclerView : RecyclerView { private var inBottomHotspot = false companion object { - var mListener: ZoomListener? = null + var mListener: MyScalableRecyclerViewListener? = null var mCurrScaleFactor = 1.0f var mLastUp = 0L // allow only pinch zoom, not double tap } @@ -135,7 +134,7 @@ class MyScalableRecyclerView : RecyclerView { minReached = lastDraggedIndex } - (adapter as DirectoryAdapter).selectRange(initialSelection, lastDraggedIndex, minReached, maxReached) + mListener?.selectRange(initialSelection, lastDraggedIndex, minReached, maxReached) if (initialSelection == lastDraggedIndex) { minReached = lastDraggedIndex @@ -159,7 +158,7 @@ class MyScalableRecyclerView : RecyclerView { maxReached = -1 this.initialSelection = initialSelection dragSelectActive = true - (adapter as DirectoryAdapter).selectItem(initialSelection) + mListener?.selectItem(initialSelection) } private fun getItemPosition(e: MotionEvent): Int { @@ -194,9 +193,13 @@ class MyScalableRecyclerView : RecyclerView { } } - interface ZoomListener { + interface MyScalableRecyclerViewListener { fun zoomOut() fun zoomIn() + + fun selectItem(position: Int) + + fun selectRange(initialSelection: Int, lastDraggedIndex: Int, minReached: Int, maxReached: Int) } }