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_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directories_grid.isZoomingEnabled = true
|
||||||
layoutManager.spanCount = config.dirColumnCnt
|
layoutManager.spanCount = config.dirColumnCnt
|
||||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||||
override fun zoomIn() {
|
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_refresh_layout.layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
media_grid.isZoomingEnabled = true
|
||||||
layoutManager.spanCount = config.mediaColumnCnt
|
layoutManager.spanCount = config.mediaColumnCnt
|
||||||
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.MyScalableRecyclerViewListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
var actMode: ActionMode? = null
|
var actMode: ActionMode? = null
|
||||||
var itemViews = SparseArray<View>()
|
var itemViews = SparseArray<View>()
|
||||||
val selectedPositions = HashSet<Int>()
|
val selectedPositions = HashSet<Int>()
|
||||||
var foregroundColor = 0
|
var foregroundColor = config.primaryColor
|
||||||
var pinnedFolders = config.pinnedFolders
|
var pinnedFolders = config.pinnedFolders
|
||||||
var scrollVertically = !config.scrollHorizontally
|
var scrollVertically = !config.scrollHorizontally
|
||||||
|
|
||||||
|
@ -97,10 +97,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
foregroundColor = config.primaryColor
|
|
||||||
}
|
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
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)) :
|
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val itemClick: (Directory) -> (Unit)) :
|
||||||
SwappingHolder(view, MultiSelector()) {
|
SwappingHolder(view, MultiSelector()) {
|
||||||
fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View {
|
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) }
|
setOnClickListener { viewClicked(directory) }
|
||||||
setOnLongClickListener { viewLongClicked(); true }
|
setOnLongClickListener { viewLongClicked(); true }
|
||||||
|
|
||||||
adapter.setupItemForeground(this)
|
adapterListener.setupItemForeground(this)
|
||||||
}
|
}
|
||||||
return itemView
|
return itemView
|
||||||
}
|
}
|
||||||
|
|
||||||
fun viewClicked(directory: Directory) {
|
fun viewClicked(directory: Directory) {
|
||||||
if (multiSelector.isSelectable) {
|
if (multiSelector.isSelectable) {
|
||||||
val isSelected = adapter.getSelectedPositions().contains(layoutPosition)
|
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
|
||||||
adapter.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||||
} else {
|
} else {
|
||||||
itemClick(directory)
|
itemClick(directory)
|
||||||
}
|
}
|
||||||
|
@ -454,7 +450,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
if (!multiSelector.isSelectable) {
|
if (!multiSelector.isSelectable) {
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
activity.startSupportActionMode(multiSelectorCallback)
|
||||||
adapter.toggleItemSelectionAdapter(true, layoutPosition)
|
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.itemLongClicked(layoutPosition)
|
listener.itemLongClicked(layoutPosition)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
var actMode: ActionMode? = null
|
var actMode: ActionMode? = null
|
||||||
var itemViews = SparseArray<View>()
|
var itemViews = SparseArray<View>()
|
||||||
val selectedPositions = HashSet<Int>()
|
val selectedPositions = HashSet<Int>()
|
||||||
var foregroundColor = 0
|
var foregroundColor = config.primaryColor
|
||||||
var displayFilenames = config.displayFileNames
|
var displayFilenames = config.displayFileNames
|
||||||
var scrollVertically = !config.scrollHorizontally
|
var scrollVertically = !config.scrollHorizontally
|
||||||
|
|
||||||
|
@ -90,10 +90,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
|
||||||
foregroundColor = config.primaryColor
|
|
||||||
}
|
|
||||||
|
|
||||||
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
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()) {
|
val multiSelector: MultiSelector, val listener: MediaOperationsListener?, val itemClick: (Medium) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
|
||||||
fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View {
|
fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View {
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
|
@ -348,15 +344,15 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
setOnClickListener { viewClicked(medium) }
|
setOnClickListener { viewClicked(medium) }
|
||||||
setOnLongClickListener { viewLongClicked(); true }
|
setOnLongClickListener { viewLongClicked(); true }
|
||||||
|
|
||||||
adapter.setupItemForeground(this)
|
adapterListener.setupItemForeground(this)
|
||||||
}
|
}
|
||||||
return itemView
|
return itemView
|
||||||
}
|
}
|
||||||
|
|
||||||
fun viewClicked(medium: Medium) {
|
fun viewClicked(medium: Medium) {
|
||||||
if (multiSelector.isSelectable) {
|
if (multiSelector.isSelectable) {
|
||||||
val isSelected = adapter.getSelectedPositions().contains(layoutPosition)
|
val isSelected = adapterListener.getSelectedPositions().contains(layoutPosition)
|
||||||
adapter.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
adapterListener.toggleItemSelectionAdapter(!isSelected, layoutPosition)
|
||||||
} else {
|
} else {
|
||||||
itemClick(medium)
|
itemClick(medium)
|
||||||
}
|
}
|
||||||
|
@ -366,7 +362,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
if (!multiSelector.isSelectable) {
|
if (!multiSelector.isSelectable) {
|
||||||
activity.startSupportActionMode(multiSelectorCallback)
|
activity.startSupportActionMode(multiSelectorCallback)
|
||||||
adapter.toggleItemSelectionAdapter(true, layoutPosition)
|
adapterListener.toggleItemSelectionAdapter(true, layoutPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.itemLongClicked(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
|
// drag selection is based on https://github.com/afollestad/drag-select-recyclerview
|
||||||
class MyScalableRecyclerView : RecyclerView {
|
class MyScalableRecyclerView : RecyclerView {
|
||||||
private val AUTO_SCROLL_DELAY = 25L
|
private val AUTO_SCROLL_DELAY = 25L
|
||||||
|
var isZoomingEnabled = false
|
||||||
|
|
||||||
private var mScaleDetector: ScaleGestureDetector
|
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) {
|
fun setDragSelectActive(initialSelection: Int) {
|
||||||
|
|
Loading…
Reference in a new issue