I know there're lots of compile errors unfixed, but -
fixed some nullability errors
This commit is contained in:
parent
a87ba42398
commit
8036d4b3e6
|
@ -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<String>?) {
|
|||
return putStringArray(key, value)
|
||||
}
|
||||
|
||||
inline fun <reified T: Parcelable> Bundle.getTypedArray(key: String): Array<T> {
|
||||
inline fun <reified T : Parcelable> Bundle.getTypedArray(key: String): Array<T> {
|
||||
val parcelable = getParcelableArray(key)
|
||||
return Array(parcelable.size) { parcelable[it] as T }
|
||||
}
|
||||
|
||||
inline fun <reified T: Parcelable> Bundle.getNullableTypedArray(key: String): Array<T>? {
|
||||
inline fun <reified T : Parcelable> Bundle.getNullableTypedArray(key: String): Array<T>? {
|
||||
val parcelable = getParcelableArray(key) ?: return null
|
||||
return Array(parcelable.size) { parcelable[it] as T }
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ import org.mariotaku.twidere.model.ParcelableUser
|
|||
|
||||
abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
||||
|
||||
private val user: ParcelableUser by lazy { arguments.getParcelable<ParcelableUser>(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)
|
||||
|
|
|
@ -34,6 +34,6 @@ class AccountStreamingSettingsFragment : BaseAccountPreferenceFragment() {
|
|||
|
||||
override fun onSwitchPreferenceChanged(isChecked: Boolean) {
|
||||
super.onSwitchPreferenceChanged(isChecked)
|
||||
StreamingService.startOrStopService(context)
|
||||
StreamingService.startOrStopService(context!!)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
linkHandlerTitle = getString(R.string.title_accounts)
|
||||
val context = context!!
|
||||
val am = AccountManager.get(context)
|
||||
adapter = AccountDetailsAdapter(context, requestManager).apply {
|
||||
sortEnabled = true
|
||||
|
@ -107,8 +108,9 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
val details = adapter.findItem(accountKey) ?: return
|
||||
details.color = color
|
||||
details.account.setColor(am, color)
|
||||
val resolver = context.contentResolver
|
||||
val weakThis by weak(this)
|
||||
task {
|
||||
val resolver = weakThis?.context?.contentResolver ?: throw InterruptedException()
|
||||
updateContentsColor(resolver, details)
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
|
@ -158,12 +160,12 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
|
||||
override fun onItemClick(parent: AdapterView<*>, 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<List<AccountDetails>> {
|
||||
return AccountDetailsLoader(context)
|
||||
return AccountDetailsLoader(context!!)
|
||||
}
|
||||
|
||||
override fun onLoaderReset(loader: Loader<List<AccountDetails>>) {
|
||||
|
@ -201,8 +203,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
showProgressDialog("remove_account") and (task {
|
||||
return@task account.getAccountKey(am)
|
||||
} and am.removeAccount(account).deadline(5, TimeUnit.SECONDS)).then { (key, _) ->
|
||||
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<Li
|
|||
class AccountDeletionDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
||||
|
||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||
val account: Account = arguments.getParcelable(EXTRA_ACCOUNT)
|
||||
val account: Account = arguments!!.getParcelable(EXTRA_ACCOUNT)
|
||||
when (which) {
|
||||
DialogInterface.BUTTON_POSITIVE -> {
|
||||
(parentFragment as AccountsManagerFragment).performRemoveAccount(account)
|
||||
|
@ -242,7 +243,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
|||
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val context = context
|
||||
val context = context!!
|
||||
val builder = AlertDialog.Builder(context)
|
||||
builder.setNegativeButton(android.R.string.cancel, null)
|
||||
builder.setPositiveButton(android.R.string.ok, this)
|
||||
|
|
Loading…
Reference in New Issue