check if we should delete all repeatable event occurrences, or just one
This commit is contained in:
parent
81301babf0
commit
66a9c31830
|
@ -258,7 +258,11 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
|
||||
private fun deleteEvent() {
|
||||
DeleteEventDialog(this, arrayListOf(mEvent.id)) {
|
||||
DBHelper.newInstance(applicationContext, this).deleteEvents(arrayOf(mEvent.id.toString()))
|
||||
if (it) {
|
||||
DBHelper.newInstance(applicationContext, this).deleteEvents(arrayOf(mEvent.id.toString()))
|
||||
} else {
|
||||
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,12 @@ class DayEventsAdapter(val activity: SimpleActivity, val mItems: List<Event>, va
|
|||
selections.forEach { eventIds.add(mItems[it].id) }
|
||||
|
||||
DeleteEventDialog(activity, eventIds) {
|
||||
if (it) {
|
||||
listener?.deleteItems(eventIds)
|
||||
} else {
|
||||
|
||||
}
|
||||
actMode?.finish()
|
||||
listener?.deleteItems(eventIds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,12 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
|||
selections.forEach { eventIds.add((mItems[it] as ListEvent).id) }
|
||||
|
||||
DeleteEventDialog(activity, eventIds) {
|
||||
if (it) {
|
||||
listener?.deleteItems(eventIds)
|
||||
} else {
|
||||
|
||||
}
|
||||
actMode?.finish()
|
||||
listener?.deleteItems(eventIds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@ package com.simplemobiletools.calendar.dialogs
|
|||
import android.app.Activity
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import kotlinx.android.synthetic.main.dialog_delete_event.view.*
|
||||
|
||||
class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callback: (allOccurrences: Boolean) -> Unit) : AlertDialog.Builder(activity) {
|
||||
class DeleteEventDialog(val activity: Activity, val eventIds: List<Int>, val callback: (allOccurrences: Boolean) -> Unit) : AlertDialog.Builder(activity) {
|
||||
val dialog: AlertDialog?
|
||||
|
||||
init {
|
||||
|
@ -22,15 +23,16 @@ class DeleteEventDialog(val activity: Activity, eventIds: List<Int>, val callbac
|
|||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() })
|
||||
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed(view as ViewGroup, hasRepeatableEvent) })
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialogConfirmed() {
|
||||
private fun dialogConfirmed(view: ViewGroup, hasRepeatableEvent: Boolean) {
|
||||
val deleteAllOccurrences = !hasRepeatableEvent || view.delete_event_radio_view.checkedRadioButtonId == R.id.delete_event_all
|
||||
dialog?.dismiss()
|
||||
callback.invoke(true)
|
||||
callback.invoke(deleteAllOccurrences)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue