avoid deleting default event type
This commit is contained in:
parent
cb009345e4
commit
c867e44cdc
|
@ -52,6 +52,10 @@ class ManageEventTypesActivity : SimpleActivity(), DeleteItemsListener {
|
|||
}
|
||||
|
||||
override fun deleteItems(ids: ArrayList<Int>) {
|
||||
if (ids.contains(DBHelper.REGULAR_EVENT_ID)) {
|
||||
toast(R.string.cannot_delete_default_type)
|
||||
}
|
||||
|
||||
DBHelper.newInstance(applicationContext).deleteEventTypes(ids) {
|
||||
if (it > 0) {
|
||||
getEventTypes()
|
||||
|
|
|
@ -51,6 +51,8 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
companion object {
|
||||
private val DB_NAME = "events.db"
|
||||
private val DB_VERSION = 7
|
||||
val REGULAR_EVENT_ID = 1
|
||||
|
||||
private var mEventsListener: EventUpdateListener? = null
|
||||
|
||||
fun newInstance(context: Context, callback: EventUpdateListener? = null): DBHelper {
|
||||
|
@ -237,7 +239,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
|||
}
|
||||
|
||||
fun deleteEventTypes(ids: ArrayList<Int>, callback: (deletedCnt: Int) -> Unit) {
|
||||
val args = TextUtils.join(", ", ids)
|
||||
var deleteIds = ids
|
||||
if (ids.contains(DBHelper.REGULAR_EVENT_ID))
|
||||
deleteIds = ids.filter { it != DBHelper.REGULAR_EVENT_ID } as ArrayList<Int>
|
||||
|
||||
if (deleteIds.isEmpty())
|
||||
return
|
||||
|
||||
val args = TextUtils.join(", ", deleteIds)
|
||||
val selection = "$COL_TYPE_ID IN ($args)"
|
||||
callback.invoke(mDb.delete(TYPES_TABLE_NAME, selection, null))
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Typ s daným názvom už existuje</string>
|
||||
<string name="color">Farba</string>
|
||||
<string name="regular_event">Bežná udalosť</string>
|
||||
<string name="cannot_delete_default_type">Predvolený typ nie je možné vymazať</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
<string name="type_already_exists">Type with this title already exists</string>
|
||||
<string name="color">Color</string>
|
||||
<string name="regular_event">Regular event</string>
|
||||
<string name="cannot_delete_default_type">Default event type cannot be deleted</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="manage_event_types">Manage event types</string>
|
||||
|
|
Loading…
Reference in New Issue