Use more orEmpty extensions (#3399)
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/or-empty.html https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/or-empty.html
This commit is contained in:
parent
ed188783de
commit
ca29ee2b0b
13 changed files with 17 additions and 17 deletions
|
|
@ -463,8 +463,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
val emojifiedNote = account.note.parseAsMastodonHtml().emojify(account.emojis, binding.accountNoteTextView, animateEmojis)
|
||||
setClickableText(binding.accountNoteTextView, emojifiedNote, emptyList(), null, this)
|
||||
|
||||
accountFieldAdapter.fields = account.fields ?: emptyList()
|
||||
accountFieldAdapter.emojis = account.emojis ?: emptyList()
|
||||
accountFieldAdapter.fields = account.fields.orEmpty()
|
||||
accountFieldAdapter.emojis = account.emojis.orEmpty()
|
||||
accountFieldAdapter.notifyDataSetChanged()
|
||||
|
||||
binding.accountLockedImageView.visible(account.locked)
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ fun TimelineAccount.toEntity() =
|
|||
username = username,
|
||||
displayName = name,
|
||||
avatar = avatar,
|
||||
emojis = emojis ?: emptyList()
|
||||
emojis = emojis.orEmpty()
|
||||
)
|
||||
|
||||
fun Status.toEntity(
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
|||
entryValues = (listOf("") + locales.map { it.language }).toTypedArray()
|
||||
key = PrefKeys.DEFAULT_POST_LANGUAGE
|
||||
icon = makeIcon(requireContext(), GoogleMaterial.Icon.gmd_translate, iconSize)
|
||||
value = accountManager.activeAccount?.defaultPostLanguage ?: ""
|
||||
value = accountManager.activeAccount?.defaultPostLanguage.orEmpty()
|
||||
isPersistent = false // This will be entirely server-driven
|
||||
setSummaryProvider { entry }
|
||||
|
||||
|
|
@ -339,7 +339,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
|||
it.defaultPostPrivacy = account.source?.privacy
|
||||
?: Status.Visibility.PUBLIC
|
||||
it.defaultMediaSensitivity = account.source?.sensitive ?: false
|
||||
it.defaultPostLanguage = language ?: ""
|
||||
it.defaultPostLanguage = language.orEmpty()
|
||||
accountManager.saveAccount(it)
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ReportNoteFragment : Fragment(R.layout.fragment_report_note), Injectable {
|
|||
|
||||
private fun handleChanges() {
|
||||
binding.editNote.doAfterTextChanged {
|
||||
viewModel.reportNote = it?.toString() ?: ""
|
||||
viewModel.reportNote = it?.toString().orEmpty()
|
||||
}
|
||||
binding.checkIsNotifyRemote.setOnCheckedChangeListener { _, isChecked ->
|
||||
viewModel.isRemoteNotify = isChecked
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class SearchActivity : BottomSheetActivity(), HasAndroidInjector, MenuProvider {
|
|||
|
||||
private fun handleIntent(intent: Intent) {
|
||||
if (Intent.ACTION_SEARCH == intent.action) {
|
||||
viewModel.currentQuery = intent.getStringExtra(SearchManager.QUERY) ?: ""
|
||||
viewModel.currentQuery = intent.getStringExtra(SearchManager.QUERY).orEmpty()
|
||||
viewModel.search(viewModel.currentQuery)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
|
|||
val intent = ComposeActivity.startIntent(
|
||||
requireContext(),
|
||||
ComposeOptions(
|
||||
content = redraftStatus.text ?: "",
|
||||
content = redraftStatus.text.orEmpty(),
|
||||
inReplyToId = redraftStatus.inReplyToId,
|
||||
visibility = redraftStatus.visibility,
|
||||
contentWarning = redraftStatus.spoilerText,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class TrendingAdapter(
|
|||
is TrendingViewData.Tag -> {
|
||||
val maxTrendingValue = currentList
|
||||
.flatMap { trendingViewData ->
|
||||
trendingViewData.asTagOrNull()?.tag?.history ?: emptyList()
|
||||
trendingViewData.asTagOrNull()?.tag?.history.orEmpty()
|
||||
}
|
||||
.mapNotNull { it.uses.toLongOrNull() }
|
||||
.maxOrNull() ?: 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue