mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-03-27 08:30:03 +01:00
do not allow confirming the import/export dialogs multiple times
This commit is contained in:
parent
0342035b27
commit
e6c031885c
@ -16,6 +16,7 @@ import java.util.*
|
||||
|
||||
class ExportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (file: File, ignoredContactSources: HashSet<String>) -> Unit) {
|
||||
private var contactSources = ArrayList<ContactSource>()
|
||||
private var ignoreClicks = false
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_contacts, null) as ViewGroup).apply {
|
||||
@ -36,7 +37,7 @@ class ExportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.export_contacts) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
if (view.export_contacts_list.adapter == null) {
|
||||
if (view.export_contacts_list.adapter == null || ignoreClicks) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
@ -50,6 +51,7 @@ class ExportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
ignoreClicks = true
|
||||
ensureBackgroundThread {
|
||||
val selectedSources = (view.export_contacts_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
|
||||
val ignoredSources = contactSources.filter { !selectedSources.contains(it) }.map { it.getFullIdentifier() }.toHashSet()
|
||||
|
@ -18,6 +18,7 @@ import kotlinx.android.synthetic.main.dialog_import_contacts.view.*
|
||||
|
||||
class ImportContactsDialog(val activity: SimpleActivity, val path: String, private val callback: (refreshView: Boolean) -> Unit) {
|
||||
private var targetContactSource = ""
|
||||
private var ignoreClicks = false
|
||||
|
||||
init {
|
||||
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply {
|
||||
@ -53,6 +54,11 @@ class ImportContactsDialog(val activity: SimpleActivity, val path: String, priva
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.import_contacts) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
if (ignoreClicks) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
ignoreClicks = true
|
||||
activity.toast(R.string.importing)
|
||||
ensureBackgroundThread {
|
||||
val result = VcfImporter(activity).importContacts(path, targetContactSource)
|
||||
|
Loading…
x
Reference in New Issue
Block a user