pass the event ids to the confirmation dialog
This commit is contained in:
parent
798e77b4e7
commit
453177382e
|
@ -15,7 +15,6 @@ import com.simplemobiletools.calendar.dialogs.SelectEventTypeDialog
|
|||
import com.simplemobiletools.calendar.extensions.*
|
||||
import com.simplemobiletools.calendar.helpers.*
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import kotlinx.android.synthetic.main.activity_event.*
|
||||
import org.joda.time.DateTime
|
||||
|
@ -258,7 +257,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
}
|
||||
|
||||
private fun deleteEvent() {
|
||||
DeleteEventDialog(this) {
|
||||
DeleteEventDialog(this, arrayListOf(mEvent.id)) {
|
||||
DBHelper.newInstance(applicationContext, this).deleteEvents(arrayOf(mEvent.id.toString()))
|
||||
finish()
|
||||
}
|
||||
|
|
|
@ -72,17 +72,14 @@ class DayEventsAdapter(val activity: SimpleActivity, val mItems: List<Event>, va
|
|||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
DeleteEventDialog(activity) {
|
||||
actMode?.finish()
|
||||
deleteEvents()
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteEvents() {
|
||||
val selections = multiSelector.selectedPositions
|
||||
val ids = ArrayList<Int>(selections.size)
|
||||
selections.forEach { ids.add(mItems[it].id) }
|
||||
listener?.deleteItems(ids)
|
||||
val eventIds = ArrayList<Int>(selections.size)
|
||||
selections.forEach { eventIds.add(mItems[it].id) }
|
||||
|
||||
DeleteEventDialog(activity, eventIds) {
|
||||
actMode?.finish()
|
||||
listener?.deleteItems(eventIds)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||
|
|
|
@ -88,17 +88,14 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
|||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
DeleteEventDialog(activity) {
|
||||
actMode?.finish()
|
||||
prepareForDeleting()
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepareForDeleting() {
|
||||
val selections = multiSelector.selectedPositions
|
||||
val ids = ArrayList<Int>(selections.size)
|
||||
selections.forEach { ids.add((mItems[it] as ListEvent).id) }
|
||||
listener?.deleteItems(ids)
|
||||
val eventIds = ArrayList<Int>(selections.size)
|
||||
selections.forEach { eventIds.add((mItems[it] as ListEvent).id) }
|
||||
|
||||
DeleteEventDialog(activity, eventIds) {
|
||||
actMode?.finish()
|
||||
listener?.deleteItems(eventIds)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int) = if (mItems[position] is ListEvent) ITEM_EVENT else ITEM_HEADER
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.view.LayoutInflater
|
|||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
|
||||
class DeleteEventDialog(val activity: Activity, val callback: () -> 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,6 +22,6 @@ class DeleteEventDialog(val activity: Activity, val callback: () -> Unit) : Aler
|
|||
|
||||
private fun dialogConfirmed() {
|
||||
dialog?.dismiss()
|
||||
callback.invoke()
|
||||
callback.invoke(true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue