From ad4f92deef277f91488d1a321ccf4035bfdb9500 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 6 Jan 2019 15:43:47 +0000 Subject: [PATCH] snap --- .../syncadapter/CalendarsSyncAdapterService.kt | 4 ++-- .../com/etesync/syncadapter/syncadapter/SyncManager.kt | 2 +- .../com/etesync/syncadapter/ui/JournalItemActivity.kt | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarsSyncAdapterService.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarsSyncAdapterService.kt index 8e5692f3..0d44ada6 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarsSyncAdapterService.kt +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarsSyncAdapterService.kt @@ -68,7 +68,7 @@ class CalendarsSyncAdapterService : SyncAdapterService() { val principal = HttpUrl.get(settings.uri!!)!! - for (calendar in AndroidCalendar.find(account, provider, LocalCalendar.Factory, CalendarContract.Calendars.SYNC_EVENTS + "!=0", null) as Array) { + for (calendar in AndroidCalendar.find(account, provider, LocalCalendar.Factory, CalendarContract.Calendars.SYNC_EVENTS + "!=0", null)) { App.log.info("Synchronizing calendar #" + calendar.id + ", URL: " + calendar.name) val syncManager = CalendarSyncManager(context, account, settings, extras, authority, syncResult, calendar, principal) syncManager.performSync() @@ -118,7 +118,7 @@ class CalendarsSyncAdapterService : SyncAdapterService() { remote[journalEntity.uid] = journalEntity } - val local = AndroidCalendar.find(account, provider, LocalCalendar.Factory, null, null) as Array + val local = AndroidCalendar.find(account, provider, LocalCalendar.Factory, null, null) val updateColors = settings.manageCalendarColors diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt index 421fb073..e9ff4cb5 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/SyncManager.kt @@ -448,7 +448,7 @@ constructor(protected val context: Context, protected val account: Account, prot val entry = SyncEntry(local.content, action) val tmp = JournalEntryManager.Entry() - tmp.update(crypto, entry.toJson(), previousEntry!!) + tmp.update(crypto, entry.toJson(), previousEntry) previousEntry = tmp localEntries!!.add(previousEntry) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt index b395cd4d..70eebf04 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/JournalItemActivity.kt @@ -314,11 +314,11 @@ class JournalItemActivity : BaseActivity(), Refreshable { // ANNIVERSARY if (contact.anniversary != null) { - addInfoItem(view.context, aboutCard, getString(R.string.journal_item_anniversary), null, getDisplayedDate(contact.anniversary?.date, contact.anniversary?.partialDate!!)) + addInfoItem(view.context, aboutCard, getString(R.string.journal_item_anniversary), null, getDisplayedDate(contact.anniversary?.date, contact.anniversary?.partialDate)) } // BDAY if (contact.birthDay != null) { - addInfoItem(view.context, aboutCard, getString(R.string.journal_item_birthday), null, getDisplayedDate(contact.birthDay?.date, contact.birthDay?.partialDate!!)) + addInfoItem(view.context, aboutCard, getString(R.string.journal_item_birthday), null, getDisplayedDate(contact.birthDay?.date, contact.birthDay?.partialDate)) } // RELATED @@ -333,17 +333,19 @@ class JournalItemActivity : BaseActivity(), Refreshable { } } - private fun getDisplayedDate(date: Date?, partialDate: PartialDate): String? { + private fun getDisplayedDate(date: Date?, partialDate: PartialDate?): String? { if (date != null) { val epochDate = date.time return getDisplayedDatetime(epochDate, epochDate, true, context) - } else { + } else if (partialDate != null){ val formatter = SimpleDateFormat("d MMMM", Locale.getDefault()) val calendar = GregorianCalendar() calendar.set(Calendar.DAY_OF_MONTH, partialDate.date!!) calendar.set(Calendar.MONTH, partialDate.month!! - 1) return formatter.format(calendar.time) } + + return null } companion object {