From 26715f2f34b4c45c564961f380d52fe03169d6de Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 5 Jan 2019 12:40:22 +0000 Subject: [PATCH] Kotlin: fix some wrong null assertions. --- .../etesync/syncadapter/syncadapter/CalendarSyncManager.kt | 2 +- .../etesync/syncadapter/syncadapter/ContactsSyncManager.kt | 2 +- .../main/java/com/etesync/syncadapter/ui/AccountActivity.kt | 2 +- .../java/com/etesync/syncadapter/ui/AppSettingsActivity.kt | 2 +- .../main/java/com/etesync/syncadapter/ui/DebugInfoActivity.kt | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.kt index 2daaf827..17c7d194 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.kt +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/CalendarSyncManager.kt @@ -111,7 +111,7 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra } val event = events[0] - val local = localCollection!!.getByUid(event.uid) as LocalEvent + val local = localCollection!!.getByUid(event.uid) as LocalEvent? if (cEntry.isAction(SyncEntry.Actions.ADD) || cEntry.isAction(SyncEntry.Actions.CHANGE)) { processEvent(event, local) diff --git a/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.kt b/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.kt index 51109d21..5b2f7e7c 100644 --- a/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.kt +++ b/app/src/main/java/com/etesync/syncadapter/syncadapter/ContactsSyncManager.kt @@ -163,7 +163,7 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra App.log.warning("Received multiple VCards, using first one") val contact = contacts[0] - val local = localCollection!!.getByUid(contact.uid) as LocalResource + val local = localCollection!!.getByUid(contact.uid) as LocalResource? if (cEntry.isAction(SyncEntry.Actions.ADD) || cEntry.isAction(SyncEntry.Actions.CHANGE)) { diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt index 0191e2d9..1d234b6b 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AccountActivity.kt @@ -180,7 +180,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe } } - override fun onCreateLoader(id: Int, args: Bundle): Loader { + override fun onCreateLoader(id: Int, args: Bundle?): Loader { return AccountLoader(this, account!!) } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt index 7b09deda..6b9921b7 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/AppSettingsActivity.kt @@ -60,7 +60,7 @@ class AppSettingsActivity : BaseActivity() { dbHelper.close() } - override fun onCreatePreferences(bundle: Bundle, s: String) { + override fun onCreatePreferences(bundle: Bundle?, s: String?) { addPreferencesFromResource(R.xml.settings_app) prefResetHints = findPreference("reset_hints") diff --git a/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.kt b/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.kt index f14feac3..d9a41cca 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/DebugInfoActivity.kt @@ -72,7 +72,7 @@ class DebugInfoActivity : BaseActivity(), LoaderManager.LoaderCallbacks ACRA.getErrorReporter().removeCustomData("debug_info") } - override fun onCreateLoader(id: Int, args: Bundle): Loader { + override fun onCreateLoader(id: Int, args: Bundle?): Loader { return ReportLoader(this, args) } @@ -101,7 +101,7 @@ class DebugInfoActivity : BaseActivity(), LoaderManager.LoaderCallbacks var phase: String? = null if (extras != null) { - throwable = extras.getSerializable(KEY_THROWABLE) as Throwable + throwable = extras.getSerializable(KEY_THROWABLE) as Throwable? logs = extras.getString(KEY_LOGS) account = extras.getParcelable(KEY_ACCOUNT) authority = extras.getString(KEY_AUTHORITY)