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