fix a crash at trying to import an .ics file

This commit is contained in:
tibbi 2018-11-18 16:46:44 +01:00
parent 66ceb69d01
commit 7f36b62798
2 changed files with 18 additions and 16 deletions

View File

@ -25,6 +25,20 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
if (activity.eventTypesDB.getEventTypeWithId(config.lastUsedLocalEventTypeId) == null) { if (activity.eventTypesDB.getEventTypeWithId(config.lastUsedLocalEventTypeId) == null) {
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
} }
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId)
currEventTypeId = if (isLastCaldavCalendarOK) {
val lastUsedCalDAVCalendar = activity.eventsHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendarId)
if (lastUsedCalDAVCalendar != null) {
currEventTypeCalDAVCalendarId = config.lastUsedCaldavCalendarId
lastUsedCalDAVCalendar.id!!
} else {
REGULAR_EVENT_TYPE_ID
}
} else {
config.lastUsedLocalEventTypeId
}
activity.runOnUiThread { activity.runOnUiThread {
initDialog() initDialog()
} }
@ -32,19 +46,6 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
} }
private fun initDialog() { private fun initDialog() {
val isLastCaldavCalendarOK = config.caldavSync && config.getSyncedCalendarIdsAsList().contains(config.lastUsedCaldavCalendarId)
currEventTypeId = if (isLastCaldavCalendarOK) {
val lastUsedCalDAVCalendar = activity.eventsHelper.getEventTypeWithCalDAVCalendarId(config.lastUsedCaldavCalendarId)
if (lastUsedCalDAVCalendar != null) {
currEventTypeCalDAVCalendarId = config.lastUsedCaldavCalendarId
lastUsedCalDAVCalendar.id!!
} else {
REGULAR_EVENT_TYPE_ID
}
} else {
config.lastUsedLocalEventTypeId
}
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_events, null) as ViewGroup).apply { val view = (activity.layoutInflater.inflate(R.layout.dialog_import_events, null) as ViewGroup).apply {
updateEventType(this) updateEventType(this)
import_event_type_holder.setOnClickListener { import_event_type_holder.setOnClickListener {

View File

@ -5,8 +5,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingRight="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"> android:paddingRight="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/import_events_event_type_label" android:id="@+id/import_events_event_type_label"
@ -29,6 +29,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/import_event_type_color"
android:paddingLeft="@dimen/medium_margin" android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"/> android:paddingRight="@dimen/medium_margin"/>
@ -49,8 +50,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/normal_margin" android:layout_marginLeft="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin"
android:text="@string/override_event_types"/> android:text="@string/override_event_types"/>
</LinearLayout> </LinearLayout>