create a new confirmation dialog for deleting events

This commit is contained in:
tibbi 2017-03-05 15:38:33 +01:00
parent c43275c7ff
commit 798e77b4e7
5 changed files with 50 additions and 5 deletions

View File

@ -8,6 +8,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.WindowManager
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.DeleteEventDialog
import com.simplemobiletools.calendar.dialogs.EventReminderDialog
import com.simplemobiletools.calendar.dialogs.EventRepeatIntervalDialog
import com.simplemobiletools.calendar.dialogs.SelectEventTypeDialog
@ -257,7 +258,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
}
private fun deleteEvent() {
ConfirmationDialog(this) {
DeleteEventDialog(this) {
DBHelper.newInstance(applicationContext, this).deleteEvents(arrayOf(mEvent.id.toString()))
finish()
}

View File

@ -8,11 +8,11 @@ import com.bignerdranch.android.multiselector.MultiSelector
import com.bignerdranch.android.multiselector.SwappingHolder
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity
import com.simplemobiletools.calendar.dialogs.DeleteEventDialog
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.helpers.Formatter
import com.simplemobiletools.calendar.interfaces.DeleteItemsListener
import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.beInvisible
import com.simplemobiletools.commons.extensions.beInvisibleIf
import kotlinx.android.synthetic.main.event_item_day_view.view.*
@ -72,7 +72,7 @@ class DayEventsAdapter(val activity: SimpleActivity, val mItems: List<Event>, va
}
private fun askConfirmDelete() {
ConfirmationDialog(activity) {
DeleteEventDialog(activity) {
actMode?.finish()
deleteEvents()
}

View File

@ -9,13 +9,13 @@ import com.bignerdranch.android.multiselector.MultiSelector
import com.bignerdranch.android.multiselector.SwappingHolder
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity
import com.simplemobiletools.calendar.dialogs.DeleteEventDialog
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.helpers.Formatter
import com.simplemobiletools.calendar.interfaces.DeleteItemsListener
import com.simplemobiletools.calendar.models.ListEvent
import com.simplemobiletools.calendar.models.ListItem
import com.simplemobiletools.calendar.models.ListSection
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.beInvisible
import com.simplemobiletools.commons.extensions.beInvisibleIf
import kotlinx.android.synthetic.main.event_list_item.view.*
@ -88,7 +88,7 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
}
private fun askConfirmDelete() {
ConfirmationDialog(activity) {
DeleteEventDialog(activity) {
actMode?.finish()
prepareForDeleting()
}

View File

@ -0,0 +1,27 @@
package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
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) {
val dialog: AlertDialog?
init {
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_delete_event, null)
dialog = AlertDialog.Builder(activity)
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() })
.setNegativeButton(R.string.no, null)
.create().apply {
activity.setupDialogStuff(view, this)
}
}
private fun dialogConfirmed() {
dialog?.dismiss()
callback.invoke()
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/delete_event_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/big_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/delete_event_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/proceed_with_deletion"
android:textSize="@dimen/bigger_text_size"/>
</LinearLayout>