mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
do not allow long pressing items if its a third party pick intent
This commit is contained in:
parent
bbdf72b52e
commit
a0b9dc7754
6 changed files with 21 additions and 20 deletions
|
@ -392,12 +392,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
private fun setupAdapter() {
|
||||
val currAdapter = directories_grid.adapter
|
||||
if (currAdapter != null) {
|
||||
(currAdapter as DirectoryAdapter).updateDirs(mDirs)
|
||||
} else {
|
||||
directories_grid.adapter = DirectoryAdapter(this, mDirs, this) {
|
||||
if (currAdapter == null) {
|
||||
directories_grid.adapter = DirectoryAdapter(this, mDirs, this, isPickIntent(intent) || isGetAnyContentIntent(intent)) {
|
||||
itemClicked(it.path)
|
||||
}
|
||||
} else {
|
||||
(currAdapter as DirectoryAdapter).updateDirs(mDirs)
|
||||
}
|
||||
setupScrollDirection()
|
||||
}
|
||||
|
|
|
@ -141,12 +141,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
return
|
||||
|
||||
val currAdapter = media_grid.adapter
|
||||
if (currAdapter != null) {
|
||||
(currAdapter as MediaAdapter).updateMedia(mMedia)
|
||||
} else {
|
||||
media_grid.adapter = MediaAdapter(this, mMedia, this) {
|
||||
if (currAdapter == null) {
|
||||
media_grid.adapter = MediaAdapter(this, mMedia, this, mIsGetAnyIntent) {
|
||||
itemClicked(it.path)
|
||||
}
|
||||
} else {
|
||||
(currAdapter as MediaAdapter).updateMedia(mMedia)
|
||||
}
|
||||
setupScrollDirection()
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import kotlinx.android.synthetic.main.directory_tmb.view.*
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, val itemClick: (Directory) -> Unit) :
|
||||
RecyclerView.Adapter<DirectoryAdapter.ViewHolder>() {
|
||||
class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, val isPickIntent: Boolean,
|
||||
val itemClick: (Directory) -> Unit) : RecyclerView.Adapter<DirectoryAdapter.ViewHolder>() {
|
||||
|
||||
val multiSelector = MultiSelector()
|
||||
val config = activity.config
|
||||
|
@ -357,7 +357,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent?.context).inflate(R.layout.directory_item, parent, false)
|
||||
return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, itemClick)
|
||||
return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, isPickIntent, itemClick)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
|
@ -419,7 +419,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
}
|
||||
|
||||
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 isPickIntent: Boolean, val itemClick: (Directory) -> (Unit)) :
|
||||
SwappingHolder(view, MultiSelector()) {
|
||||
fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean): View {
|
||||
itemView.apply {
|
||||
|
@ -429,7 +429,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
activity.loadImage(directory.tmb, dir_thumbnail, scrollVertically)
|
||||
|
||||
setOnClickListener { viewClicked(directory) }
|
||||
setOnLongClickListener { viewLongClicked(); true }
|
||||
setOnLongClickListener { if (isPickIntent) viewClicked(directory) else viewLongClicked(); true }
|
||||
|
||||
adapterListener.setupItemForeground(this)
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import kotlinx.android.synthetic.main.photo_video_tmb.view.*
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val itemClick: (Medium) -> Unit) :
|
||||
RecyclerView.Adapter<MediaAdapter.ViewHolder>() {
|
||||
class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>, val listener: MediaOperationsListener?, val isPickIntent: Boolean,
|
||||
val itemClick: (Medium) -> Unit) : RecyclerView.Adapter<MediaAdapter.ViewHolder>() {
|
||||
|
||||
val multiSelector = MultiSelector()
|
||||
val config = activity.config
|
||||
|
@ -266,7 +266,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent?.context).inflate(R.layout.photo_video_item, parent, false)
|
||||
return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, itemClick)
|
||||
return ViewHolder(view, adapterListener, activity, multiSelectorMode, multiSelector, listener, isPickIntent, itemClick)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
|
@ -332,7 +332,8 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
}
|
||||
|
||||
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 isPickIntent: Boolean, val itemClick: (Medium) -> (Unit)) :
|
||||
SwappingHolder(view, MultiSelector()) {
|
||||
fun bindView(medium: Medium, displayFilenames: Boolean, scrollVertically: Boolean): View {
|
||||
itemView.apply {
|
||||
play_outline.visibility = if (medium.video) View.VISIBLE else View.GONE
|
||||
|
@ -341,7 +342,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
activity.loadImage(medium.path, medium_thumbnail, scrollVertically)
|
||||
|
||||
setOnClickListener { viewClicked(medium) }
|
||||
setOnLongClickListener { viewLongClicked(); true }
|
||||
setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true }
|
||||
|
||||
adapterListener.setupItemForeground(this)
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class PickDirectoryDialog(val activity: SimpleActivity, val sourcePath: String,
|
|||
return
|
||||
|
||||
shownDirectories = directories
|
||||
val adapter = DirectoryAdapter(activity, directories, null) {
|
||||
val adapter = DirectoryAdapter(activity, directories, null, true) {
|
||||
if (it.path.trimEnd('/') == sourcePath) {
|
||||
activity.toast(R.string.source_and_destination_same)
|
||||
return@DirectoryAdapter
|
||||
|
|
|
@ -47,7 +47,7 @@ class PickMediumDialog(val activity: SimpleActivity, val path: String, val callb
|
|||
return
|
||||
|
||||
shownMedia = media
|
||||
val adapter = MediaAdapter(activity, media, null) {
|
||||
val adapter = MediaAdapter(activity, media, null, true) {
|
||||
callback(it.path)
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue