make zooming disabled by default in the recyclerview
This commit is contained in:
parent
39196be6d5
commit
54c56c559e
5 changed files with 19 additions and 21 deletions
|
@ -239,6 +239,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
directories_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
|
||||
directories_grid.isZoomingEnabled = true
|
||||
layoutManager.spanCount = config.dirColumnCnt
|
||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||
override fun zoomIn() {
|
||||
|
|
|
@ -315,6 +315,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
media_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
|
||||
media_grid.isZoomingEnabled = true
|
||||
layoutManager.spanCount = config.mediaColumnCnt
|
||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||
override fun zoomIn() {
|
||||
|
|
|
@ -39,7 +39,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
var actMode: ActionMode? = null
|
||||
var itemViews = SparseArray<View>()
|
||||
val selectedPositions = HashSet<Int>()
|
||||
var foregroundColor = 0
|
||||
var foregroundColor = config.primaryColor
|
||||
var pinnedFolders = config.pinnedFolders
|
||||
var scrollVertically = !config.scrollHorizontally
|
||||
|
||||
|
@ -97,10 +97,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||
}
|
||||
|
||||
init {
|
||||
foregroundColor = config.primaryColor
|
||||
}
|
||||
|
||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
|
@ -423,7 +419,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
}
|
||||
}
|
||||
|
||||
class ViewHolder(val view: View, val adapter: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val itemClick: (Directory) -> (Unit)) :
|
||||
SwappingHolder(view, MultiSelector()) {
|
||||
fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View {
|
||||
|
@ -436,15 +432,15 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
setOnClickListener { viewClicked(directory) }
|
||||
setOnLongClickListener { viewLongClicked(); true }
|
||||
|
||||
adapter.setupItemForeground(this)
|
||||
adapterListener.setupItemForeground(this)
|
||||
}
|
||||
return itemView
|
||||
}
|
||||
|
||||
fun viewClicked(directory: Directory) {
|
||||
if (multiSelector.isSelectable) {
|
||||
val isSelected = adapter.getSelectedPositions().contains(layoutPosition)
|
||||
adapter.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
|
||||
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||
} else {
|
||||
itemClick(directory)
|
||||
}
|
||||
|
@ -454,7 +450,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
if (listener != null) {
|
||||
if (!multiSelector.isSelectable) {
|
||||
activity.startSupportActionMode(multiSelectorCallback)
|
||||
adapter.toggleItemSelectionAdapter(true, layoutPosition)
|
||||
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
|
||||
}
|
||||
|
||||
listener.itemLongClicked(layoutPosition)
|
||||
|
|
|
@ -32,7 +32,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
var actMode: ActionMode? = null
|
||||
var itemViews = SparseArray<View>()
|
||||
val selectedPositions = HashSet<Int>()
|
||||
var foregroundColor = 0
|
||||
var foregroundColor = config.primaryColor
|
||||
var displayFilenames = config.displayFileNames
|
||||
var scrollVertically = !config.scrollHorizontally
|
||||
|
||||
|
@ -90,10 +90,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||
}
|
||||
|
||||
init {
|
||||
foregroundColor = config.primaryColor
|
||||
}
|
||||
|
||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
|
@ -336,7 +332,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
}
|
||||
}
|
||||
|
||||
class ViewHolder(val view: View, val adapter: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||
val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||
fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View {
|
||||
itemView.apply {
|
||||
|
@ -348,15 +344,15 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
setOnClickListener { viewClicked(medium) }
|
||||
setOnLongClickListener { viewLongClicked(); true }
|
||||
|
||||
adapter.setupItemForeground(this)
|
||||
adapterListener.setupItemForeground(this)
|
||||
}
|
||||
return itemView
|
||||
}
|
||||
|
||||
fun viewClicked(medium: Medium) {
|
||||
if (multiSelector.isSelectable) {
|
||||
val isSelected = adapter.getSelectedPositions().contains(layoutPosition)
|
||||
adapter.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
|
||||
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||
} else {
|
||||
itemClick(medium)
|
||||
}
|
||||
|
@ -366,7 +362,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
if (listener != null) {
|
||||
if (!multiSelector.isSelectable) {
|
||||
activity.startSupportActionMode(multiSelectorCallback)
|
||||
adapter.toggleItemSelectionAdapter(true, layoutPosition)
|
||||
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
|
||||
}
|
||||
|
||||
listener.itemLongClicked(layoutPosition)
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simplemobiletools.gallery.R
|
|||
// drag selection is based on https://github.com/afollestad/drag-select-recyclerview
|
||||
class MyScalableRecyclerView : RecyclerView {
|
||||
private val AUTO_SCROLL_DELAY = 25L
|
||||
var isZoomingEnabled = false
|
||||
|
||||
private var mScaleDetector: ScaleGestureDetector
|
||||
|
||||
|
@ -149,7 +150,10 @@ class MyScalableRecyclerView : RecyclerView {
|
|||
}
|
||||
}
|
||||
}
|
||||
return mScaleDetector.onTouchEvent(ev)
|
||||
return if (isZoomingEnabled)
|
||||
mScaleDetector.onTouchEvent(ev)
|
||||
else
|
||||
true
|
||||
}
|
||||
|
||||
fun setDragSelectActive(initialSelection: Int) {
|
||||
|
|
Loading…
Reference in a new issue