From e41010603fb644177d3c1a33cd9fb28732c33d6c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 11 Feb 2017 20:14:03 +0100 Subject: [PATCH] update event type at event activity --- .../calendar/activities/EventActivity.kt | 6 ++++-- .../calendar/helpers/DBHelper.kt | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 117734552..f1b183161 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -29,6 +29,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { private var mReminder3Minutes = 0 private var mRepeatInterval = 0 private var mRepeatLimit = 0 + private var mEventType = DBHelper.REGULAR_EVENT_ID private var mDialogTheme = 0 lateinit var mEventStartDateTime: DateTime @@ -83,7 +84,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { event_reminder_2.setOnClickListener { showReminder2Dialog() } event_reminder_3.setOnClickListener { showReminder3Dialog() } - event_type.setOnClickListener { } + event_type.setOnClickListener { } if (mEvent.flags and FLAG_ALL_DAY != 0) event_all_day.toggle() @@ -104,6 +105,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { mReminder3Minutes = mEvent.reminder3Minutes mRepeatInterval = mEvent.repeatInterval mRepeatLimit = mEvent.repeatLimit + mEventType = mEvent.eventType checkRepeatLimit(mRepeatInterval) } @@ -223,7 +225,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener { } private fun updateEventType() { - + event_type.text = DBHelper.newInstance(applicationContext).getEventTypeTitle(mEventType) } private fun getRepetitionToString(seconds: Int) = getString(when (seconds) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index aaff06d10..ab4c9b7b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -226,6 +226,22 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont return -1 } + fun getEventTypeTitle(id: Int): String { + val cols = arrayOf(COL_TYPE_TITLE) + val selection = "$COL_TYPE_ID = ?" + val selectionArgs = arrayOf(id.toString()) + var cursor: Cursor? = null + try { + cursor = mDb.query(TYPES_TABLE_NAME, cols, selection, selectionArgs, null, null, null) + if (cursor?.moveToFirst() == true) { + return cursor.getStringValue(COL_TYPE_TITLE) + } + } finally { + cursor?.close() + } + return context.resources.getString(R.string.regular_event) + } + fun deleteEvents(ids: Array) { val args = TextUtils.join(", ", ids) val selection = "$COL_ID IN ($args)"