fix a crash at trying to import an .ics file
This commit is contained in:
parent
66ceb69d01
commit
7f36b62798
|
@ -25,6 +25,20 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
|
|||
if (activity.eventTypesDB.getEventTypeWithId(config.lastUsedLocalEventTypeId) == null) {
|
||||
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 {
|
||||
initDialog()
|
||||
}
|
||||
|
@ -32,19 +46,6 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal
|
|||
}
|
||||
|
||||
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 {
|
||||
updateEventType(this)
|
||||
import_event_type_holder.setOnClickListener {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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
|
||||
android:id="@+id/import_events_event_type_label"
|
||||
|
@ -29,6 +29,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/import_event_type_color"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"/>
|
||||
|
||||
|
@ -49,8 +50,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/override_event_types"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue