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.Bundle
|
||||||
import android.os.Parcelable
|
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 {
|
inline fun Bundle(copyFrom: Bundle? = null, action: Bundle.() -> Unit): Bundle {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
|
@ -47,12 +44,12 @@ operator fun Bundle.set(key: String, value: Array<String>?) {
|
||||||
return putStringArray(key, value)
|
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)
|
val parcelable = getParcelableArray(key)
|
||||||
return Array(parcelable.size) { parcelable[it] as T }
|
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
|
val parcelable = getParcelableArray(key) ?: return null
|
||||||
return Array(parcelable.size) { parcelable[it] as T }
|
return Array(parcelable.size) { parcelable[it] as T }
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
val activity = activity
|
val activity = activity!!
|
||||||
pagerAdapter = SupportTabsAdapter(activity, childFragmentManager, null)
|
pagerAdapter = SupportTabsAdapter(activity, childFragmentManager, null)
|
||||||
viewPager.adapter = pagerAdapter
|
viewPager.adapter = pagerAdapter
|
||||||
viewPager.offscreenPageLimit = 2
|
viewPager.offscreenPageLimit = 2
|
||||||
|
@ -148,7 +148,7 @@ abstract class AbsToolbarTabPagesFragment : BaseFragment(), RefreshScrollTopInte
|
||||||
if (height != 0) {
|
if (height != 0) {
|
||||||
insets.top = height
|
insets.top = height
|
||||||
} else {
|
} else {
|
||||||
insets.top = ThemeUtils.getActionBarHeight(context)
|
insets.top = ThemeUtils.getActionBarHeight(context!!)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ import org.mariotaku.twidere.model.ParcelableUser
|
||||||
|
|
||||||
abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
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) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
when (which) {
|
when (which) {
|
||||||
|
@ -48,7 +49,7 @@ abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInte
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context!!)
|
||||||
builder.setTitle(getTitle(user))
|
builder.setTitle(getTitle(user))
|
||||||
builder.setView(R.layout.dialog_block_mute_filter_user_confirm)
|
builder.setView(R.layout.dialog_block_mute_filter_user_confirm)
|
||||||
builder.setPositiveButton(getPositiveButtonTitle(user), this)
|
builder.setPositiveButton(getPositiveButtonTitle(user), this)
|
||||||
|
|
|
@ -34,6 +34,6 @@ class AccountStreamingSettingsFragment : BaseAccountPreferenceFragment() {
|
||||||
|
|
||||||
override fun onSwitchPreferenceChanged(isChecked: Boolean) {
|
override fun onSwitchPreferenceChanged(isChecked: Boolean) {
|
||||||
super.onSwitchPreferenceChanged(isChecked)
|
super.onSwitchPreferenceChanged(isChecked)
|
||||||
StreamingService.startOrStopService(context)
|
StreamingService.startOrStopService(context!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
linkHandlerTitle = getString(R.string.title_accounts)
|
linkHandlerTitle = getString(R.string.title_accounts)
|
||||||
|
val context = context!!
|
||||||
val am = AccountManager.get(context)
|
val am = AccountManager.get(context)
|
||||||
adapter = AccountDetailsAdapter(context, requestManager).apply {
|
adapter = AccountDetailsAdapter(context, requestManager).apply {
|
||||||
sortEnabled = true
|
sortEnabled = true
|
||||||
|
@ -107,8 +108,9 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
val details = adapter.findItem(accountKey) ?: return
|
val details = adapter.findItem(accountKey) ?: return
|
||||||
details.color = color
|
details.color = color
|
||||||
details.account.setColor(am, color)
|
details.account.setColor(am, color)
|
||||||
val resolver = context.contentResolver
|
val weakThis by weak(this)
|
||||||
task {
|
task {
|
||||||
|
val resolver = weakThis?.context?.contentResolver ?: throw InterruptedException()
|
||||||
updateContentsColor(resolver, details)
|
updateContentsColor(resolver, details)
|
||||||
}
|
}
|
||||||
adapter.notifyDataSetChanged()
|
adapter.notifyDataSetChanged()
|
||||||
|
@ -158,12 +160,12 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
|
|
||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val account = adapter.getItem(position)
|
val account = adapter.getItem(position)
|
||||||
IntentUtils.openUserProfile(context, account.user, preferences[newDocumentApiKey],
|
IntentUtils.openUserProfile(context!!, account.user, preferences[newDocumentApiKey],
|
||||||
null)
|
null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<AccountDetails>> {
|
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<AccountDetails>> {
|
||||||
return AccountDetailsLoader(context)
|
return AccountDetailsLoader(context!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLoaderReset(loader: Loader<List<AccountDetails>>) {
|
override fun onLoaderReset(loader: Loader<List<AccountDetails>>) {
|
||||||
|
@ -201,8 +203,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
showProgressDialog("remove_account") and (task {
|
showProgressDialog("remove_account") and (task {
|
||||||
return@task account.getAccountKey(am)
|
return@task account.getAccountKey(am)
|
||||||
} and am.removeAccount(account).deadline(5, TimeUnit.SECONDS)).then { (key, _) ->
|
} and am.removeAccount(account).deadline(5, TimeUnit.SECONDS)).then { (key, _) ->
|
||||||
val f = weakThis ?: throw InterruptedException()
|
val context = weakThis?.context ?: throw InterruptedException()
|
||||||
val context = f.context
|
|
||||||
val resolver = context.contentResolver
|
val resolver = context.contentResolver
|
||||||
resolver.deleteAccountData(key)
|
resolver.deleteAccountData(key)
|
||||||
AccountPreferences.getSharedPreferencesForAccount(context, key).edit().clear().apply()
|
AccountPreferences.getSharedPreferencesForAccount(context, key).edit().clear().apply()
|
||||||
|
@ -232,7 +233,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
class AccountDeletionDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
class AccountDeletionDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
val account: Account = arguments.getParcelable(EXTRA_ACCOUNT)
|
val account: Account = arguments!!.getParcelable(EXTRA_ACCOUNT)
|
||||||
when (which) {
|
when (which) {
|
||||||
DialogInterface.BUTTON_POSITIVE -> {
|
DialogInterface.BUTTON_POSITIVE -> {
|
||||||
(parentFragment as AccountsManagerFragment).performRemoveAccount(account)
|
(parentFragment as AccountsManagerFragment).performRemoveAccount(account)
|
||||||
|
@ -242,7 +243,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val context = context
|
val context = context!!
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
builder.setNegativeButton(android.R.string.cancel, null)
|
builder.setNegativeButton(android.R.string.cancel, null)
|
||||||
builder.setPositiveButton(android.R.string.ok, this)
|
builder.setPositiveButton(android.R.string.ok, this)
|
||||||
|
|
Loading…
Reference in New Issue