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>> { override fun onCreateLoader(id: Int, args: Bundle?): Loader<List<ParcelableUser>> {
val accountKey = args?.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)!! val accountKey = args?.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)!!
val query = args?.getString(EXTRA_QUERY).orEmpty() val query = args.getString(EXTRA_QUERY).orEmpty()
val fromCache = args?.getBoolean(EXTRA_FROM_CACHE) val fromCache = args.getBoolean(EXTRA_FROM_CACHE)
if (!fromCache) { if (!fromCache) {
showProgress() showProgress()
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -111,7 +111,7 @@ class ExtensionsListLoader(
constructor(info: ApplicationInfo, pm: PackageManager) : this( constructor(info: ApplicationInfo, pm: PackageManager) : this(
info.packageName, info.packageName,
info.loadLabel(pm) ?: info.packageName, info.loadLabel(pm),
info.loadDescription(pm), info.loadDescription(pm),
info.loadIcon(pm), info.loadIcon(pm),
info.metaData?.getString(METADATA_KEY_EXTENSION_PERMISSIONS)?.split('|')?.filterNot(String::isEmpty)?.toTypedArray(), 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 preference = preference as ColorPickerPreference
val alertDialog = dialog as AlertDialog val alertDialog = dialog as AlertDialog
alertDialog.applyTheme() alertDialog.applyTheme()
val windowView = alertDialog.window!!.decorView ?: return val windowView = alertDialog.window!!.decorView
controller = ColorPickerDialog.Controller(context, windowView) controller = ColorPickerDialog.Controller(context, windowView)
controller.setAlphaEnabled(preference.isAlphaSliderEnabled) controller.setAlphaEnabled(preference.isAlphaSliderEnabled)
for (presetColor in PRESET_COLORS) { for (presetColor in PRESET_COLORS) {

View File

@ -103,9 +103,9 @@ object HttpClientFactory {
"[HOST]" -> url.host() "[HOST]" -> url.host()
"[PORT]" -> url.port() "[PORT]" -> url.port()
"[AUTHORITY]" -> url.authority() "[AUTHORITY]" -> url.authority()
"[PATH]" -> url.encodedPath()?.removePrefix("/").orEmpty() "[PATH]" -> url.encodedPath().removePrefix("/")
"[/PATH]" -> url.encodedPath().orEmpty() "[/PATH]" -> url.encodedPath().orEmpty()
"[PATH_ENCODED]" -> url.encodedPath()?.removePrefix("/")?.urlEncoded() "[PATH_ENCODED]" -> url.encodedPath().removePrefix("/").urlEncoded()
"[QUERY]" -> url.encodedQuery().orEmpty() "[QUERY]" -> url.encodedQuery().orEmpty()
"[?QUERY]" -> url.encodedQuery()?.prefix("?").orEmpty() "[?QUERY]" -> url.encodedQuery()?.prefix("?").orEmpty()
"[QUERY_ENCODED]" -> url.encodedQuery()?.urlEncoded() "[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) { 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) scrollHandler.handleScroll(dy, scrollState, oldState, RecyclerView.SCROLL_STATE_IDLE)
oldState = scrollState oldState = scrollState
} }

View File

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