From 8036d4b3e6fcaf47a92f59012ca64afa88f710a2 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Thu, 16 Nov 2017 00:48:06 +0800 Subject: [PATCH] I know there're lots of compile errors unfixed, but - fixed some nullability errors --- .../org/mariotaku/ktextension/BundleExtensions.kt | 7 ++----- .../fragment/AbsToolbarTabPagesFragment.kt | 4 ++-- .../fragment/AbsUserMuteBlockDialogFragment.kt | 5 +++-- .../fragment/AccountStreamingSettingsFragment.kt | 2 +- .../twidere/fragment/AccountsManagerFragment.kt | 15 ++++++++------- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/ktextension/BundleExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/ktextension/BundleExtensions.kt index 2fbdcfb2b..906b54120 100644 --- a/twidere/src/main/kotlin/org/mariotaku/ktextension/BundleExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/ktextension/BundleExtensions.kt @@ -2,9 +2,6 @@ package org.mariotaku.ktextension import android.os.Bundle import android.os.Parcelable -import java.lang.ref.WeakReference -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty inline fun Bundle(copyFrom: Bundle? = null, action: Bundle.() -> Unit): Bundle { val bundle = Bundle() @@ -47,12 +44,12 @@ operator fun Bundle.set(key: String, value: Array?) { return putStringArray(key, value) } -inline fun Bundle.getTypedArray(key: String): Array { +inline fun Bundle.getTypedArray(key: String): Array { val parcelable = getParcelableArray(key) return Array(parcelable.size) { parcelable[it] as T } } -inline fun Bundle.getNullableTypedArray(key: String): Array? { +inline fun Bundle.getNullableTypedArray(key: String): Array? { val parcelable = getParcelableArray(key) ?: return null return Array(parcelable.size) { parcelable[it] as T } } \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt index e65a9ce26..7685e7819 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsToolbarTabPagesFragment.kt @@ -45,7 +45,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) - val activity = activity + val activity = activity!! pagerAdapter = SupportTabsAdapter(activity, childFragmentManager, null) viewPager.adapter = pagerAdapter viewPager.offscreenPageLimit = 2 @@ -148,7 +148,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte if (height != 0) { insets.top = height } else { - insets.top = ThemeUtils.getActionBarHeight(context) + insets.top = ThemeUtils.getActionBarHeight(context!!) } return true } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt index ed8213170..5c9735973 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AbsUserMuteBlockDialogFragment.kt @@ -34,7 +34,8 @@ import org.mariotaku.twidere.model.ParcelableUser abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener { - private val user: ParcelableUser by lazy { arguments.getParcelable(EXTRA_USER) } + private val user: ParcelableUser + get() = arguments!!.getParcelable(EXTRA_USER) override fun onClick(dialog: DialogInterface, which: Int) { when (which) { @@ -48,7 +49,7 @@ abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInte } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val builder = AlertDialog.Builder(context) + val builder = AlertDialog.Builder(context!!) builder.setTitle(getTitle(user)) builder.setView(R.layout.dialog_block_mute_filter_user_confirm) builder.setPositiveButton(getPositiveButtonTitle(user), this) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountStreamingSettingsFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountStreamingSettingsFragment.kt index 4025209e9..e1fb317d3 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountStreamingSettingsFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountStreamingSettingsFragment.kt @@ -34,6 +34,6 @@ class AccountStreamingSettingsFragment : BaseAccountPreferenceFragment() { override fun onSwitchPreferenceChanged(isChecked: Boolean) { super.onSwitchPreferenceChanged(isChecked) - StreamingService.startOrStopService(context) + StreamingService.startOrStopService(context!!) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt index 056ca95b1..fc20d9f66 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt @@ -66,6 +66,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • , view: View, position: Int, id: Long) { val account = adapter.getItem(position) - IntentUtils.openUserProfile(context, account.user, preferences[newDocumentApiKey], + IntentUtils.openUserProfile(context!!, account.user, preferences[newDocumentApiKey], null) } override fun onCreateLoader(id: Int, args: Bundle?): Loader> { - return AccountDetailsLoader(context) + return AccountDetailsLoader(context!!) } override fun onLoaderReset(loader: Loader>) { @@ -201,8 +203,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • - val f = weakThis ?: throw InterruptedException() - val context = f.context + val context = weakThis?.context ?: throw InterruptedException() val resolver = context.contentResolver resolver.deleteAccountData(key) AccountPreferences.getSharedPreferencesForAccount(context, key).edit().clear().apply() @@ -232,7 +233,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • { (parentFragment as AccountsManagerFragment).performRemoveAccount(account) @@ -242,7 +243,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks