Migrate some older Kotlin

This commit is contained in:
TacoTheDank 2020-05-31 02:44:38 -04:00
parent 4534946314
commit 20fad6b917
13 changed files with 14 additions and 15 deletions

View File

@ -109,8 +109,8 @@ class UserSelectorActivity : BaseActivity(), OnItemClickListener, LoaderManager.
override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUser>> {
val accountKey = args?.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)!!
val query = args?.getString(EXTRA_QUERY).orEmpty()
val fromCache = args?.getBoolean(EXTRA_FROM_CACHE)
val query = args.getString(EXTRA_QUERY).orEmpty()
val fromCache = args.getBoolean(EXTRA_FROM_CACHE)
if (!fromCache) {
showProgress()
}

View File

@ -117,7 +117,7 @@ class StatusDetailsAdapter(
inflater = LayoutInflater.from(context)
cardBackgroundColor = ThemeUtils.getCardBackgroundColor(context!!,
preferences[themeBackgroundOptionKey], preferences[themeBackgroundAlphaKey])
val listener = StatusAdapterLinkClickHandler<List<ParcelableStatus>>(context!!, preferences)
val listener = StatusAdapterLinkClickHandler<List<ParcelableStatus>>(context, preferences)
listener.setAdapter(this)
twidereLinkify = TwidereLinkify(listener)
}

View File

@ -100,7 +100,7 @@ class ColorPickerDialogFragment : BaseDialogFragment(), DialogInterface.OnClickL
override fun onSaveInstanceState(outState: Bundle) {
if (controller != null) {
outState!!.putInt(EXTRA_COLOR, controller!!.color)
outState.putInt(EXTRA_COLOR, controller!!.color)
}
super.onSaveInstanceState(outState)
}

View File

@ -667,7 +667,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
actionBarShadowColor = 0xA0000000.toInt()
val args = arguments
val accountKey = args?.getParcelable<UserKey?>(EXTRA_ACCOUNT_KEY) ?: run {
activity?.finish()
activity.finish()
return
}
val userKey = args.getParcelable<UserKey?>(EXTRA_USER_KEY)

View File

@ -253,7 +253,7 @@ class AddEditItemFragment : BaseDialogFragment() {
Toast.LENGTH_SHORT).show()
} else {
val idWhere = Expression.equals(Filters._ID, rowId).sql
resolver?.update(uri, values, idWhere, null)
resolver.update(uri, values, idWhere, null)
}
} else {
resolver?.insert(uri, values)

View File

@ -238,7 +238,7 @@ class MessageNewConversationFragment : BaseFragment(), LoaderCallbacks<List<Parc
}
private fun createOrOpenConversation() {
val account = this.account ?: return
val account = this.account
val context = context ?: return
val activity = activity ?: return
val selected = this.selectedRecipients

View File

@ -80,7 +80,7 @@ abstract class AbsStatusDialogFragment : BaseDialogFragment() {
val dialog = builder.create()
dialog.onShow {
val context = it.context ?: return@onShow
val context = it.context
it.applyTheme()
val am = AccountManager.get(context)

View File

@ -241,7 +241,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
})
adapter = StatusDetailsAdapter(this)
layoutManager = StatusListLinearLayoutManager(context, recyclerView)
mItemDecoration = StatusDividerItemDecoration(context, adapter, layoutManager.orientation)?.apply {
mItemDecoration = StatusDividerItemDecoration(context, adapter, layoutManager.orientation).apply {
recyclerView.addItemDecoration(this)
}
layoutManager.recycleChildrenOnDetach = true

View File

@ -111,7 +111,7 @@ class ExtensionsListLoader(
constructor(info: ApplicationInfo, pm: PackageManager) : this(
info.packageName,
info.loadLabel(pm) ?: info.packageName,
info.loadLabel(pm),
info.loadDescription(pm),
info.loadIcon(pm),
info.metaData?.getString(METADATA_KEY_EXTENSION_PERMISSIONS)?.split('|')?.filterNot(String::isEmpty)?.toTypedArray(),

View File

@ -122,7 +122,7 @@ class ColorPickerPreference(context: Context, attrs: AttributeSet? = null) :
val preference = preference as ColorPickerPreference
val alertDialog = dialog as AlertDialog
alertDialog.applyTheme()
val windowView = alertDialog.window!!.decorView ?: return
val windowView = alertDialog.window!!.decorView
controller = ColorPickerDialog.Controller(context, windowView)
controller.setAlphaEnabled(preference.isAlphaSliderEnabled)
for (presetColor in PRESET_COLORS) {

View File

@ -103,9 +103,9 @@ object HttpClientFactory {
"[HOST]" -> url.host()
"[PORT]" -> url.port()
"[AUTHORITY]" -> url.authority()
"[PATH]" -> url.encodedPath()?.removePrefix("/").orEmpty()
"[PATH]" -> url.encodedPath().removePrefix("/")
"[/PATH]" -> url.encodedPath().orEmpty()
"[PATH_ENCODED]" -> url.encodedPath()?.removePrefix("/")?.urlEncoded()
"[PATH_ENCODED]" -> url.encodedPath().removePrefix("/").urlEncoded()
"[QUERY]" -> url.encodedQuery().orEmpty()
"[?QUERY]" -> url.encodedQuery()?.prefix("?").orEmpty()
"[QUERY_ENCODED]" -> url.encodedQuery()?.urlEncoded()

View File

@ -34,7 +34,7 @@ class RecyclerViewScrollHandler<A>(contentListSupport: ContentListSupport<A>, vi
}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
val scrollState = recyclerView!!.scrollState
val scrollState = recyclerView.scrollState
scrollHandler.handleScroll(dy, scrollState, oldState, RecyclerView.SCROLL_STATE_IDLE)
oldState = scrollState
}

View File

@ -46,7 +46,6 @@ class RoundedRectTransformation(
val height = source.height
val bitmap = bitmapPool.get(width, height, Bitmap.Config.ARGB_8888)
?: Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
val paint = Paint()