do not allow selecting a caldav event type at non-synced event types

This commit is contained in:
tibbi 2017-08-22 11:57:46 +02:00
parent 1786704213
commit 460bbfbb51
2 changed files with 4 additions and 3 deletions

View File

@ -33,7 +33,7 @@ class SelectEventTypeDialog(val activity: Activity, val currEventType: Int, val
activity.dbHelper.getEventTypes {
eventTypes = it
activity.runOnUiThread {
eventTypes.forEach {
eventTypes.filter { it.caldavCalendarId == 0 }.forEach {
addRadioButton(it.title, it.id, it.color)
}
addRadioButton(activity.getString(R.string.add_new_type), NEW_TYPE_ID, Color.TRANSPARENT)

View File

@ -774,7 +774,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
fun fetchEventTypes(): ArrayList<EventType> {
val eventTypes = ArrayList<EventType>(4)
val cols = arrayOf(COL_TYPE_ID, COL_TYPE_TITLE, COL_TYPE_COLOR)
val cols = arrayOf(COL_TYPE_ID, COL_TYPE_TITLE, COL_TYPE_COLOR, COL_TYPE_CALDAV_CALENDAR_ID)
var cursor: Cursor? = null
try {
cursor = mDb.query(TYPES_TABLE_NAME, cols, null, null, null, null, "$COL_TYPE_TITLE ASC")
@ -783,7 +783,8 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
val id = cursor.getIntValue(COL_TYPE_ID)
val title = cursor.getStringValue(COL_TYPE_TITLE)
val color = cursor.getIntValue(COL_TYPE_COLOR)
val eventType = EventType(id, title, color)
val calendarId = cursor.getIntValue(COL_TYPE_CALDAV_CALENDAR_ID)
val eventType = EventType(id, title, color, calendarId)
eventTypes.add(eventType)
} while (cursor.moveToNext())
}