prevent Event Type remove animation if it wasnt deleted

This commit is contained in:
tibbi 2018-01-19 20:20:56 +01:00
parent 9e7d99b822
commit fff3f05a99
3 changed files with 9 additions and 4 deletions

View File

@ -54,9 +54,12 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
return true
}
override fun deleteEventTypes(eventTypes: ArrayList<EventType>, deleteEvents: Boolean) {
override fun deleteEventTypes(eventTypes: ArrayList<EventType>, deleteEvents: Boolean): Boolean {
if (eventTypes.any { it.caldavCalendarId != 0 }) {
toast(R.string.unsync_caldav_calendar)
if (eventTypes.size == 1) {
return false
}
}
dbHelper.deleteEventTypes(eventTypes, deleteEvents) {
@ -64,5 +67,6 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteEventTypesListener {
toast(R.string.unknown_error_occurred)
}
}
return true
}
}

View File

@ -101,7 +101,8 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis
}
eventTypes.removeAll(eventTypesToDelete)
listener?.deleteEventTypes(eventTypesToDelete, deleteEvents)
removeSelectedItems()
if (listener?.deleteEventTypes(eventTypesToDelete, deleteEvents) == true) {
removeSelectedItems()
}
}
}

View File

@ -4,5 +4,5 @@ import com.simplemobiletools.calendar.models.EventType
import java.util.*
interface DeleteEventTypesListener {
fun deleteEventTypes(eventTypes: ArrayList<EventType>, deleteEvents: Boolean)
fun deleteEventTypes(eventTypes: ArrayList<EventType>, deleteEvents: Boolean): Boolean
}