Goooler 2023-03-02 04:06:55 +08:00 committed by GitHub
parent ed188783de
commit ca29ee2b0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 17 additions and 17 deletions

View File

@ -114,7 +114,7 @@ class AccountsInListFragment : DialogFragment(), Injectable {
binding.searchView.isSubmitButtonEnabled = true
binding.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
viewModel.search(query ?: "")
viewModel.search(query.orEmpty())
return true
}

View File

@ -136,7 +136,7 @@ class EditProfileActivity : BaseActivity(), Injectable {
binding.noteEditText.setText(me.source?.note)
binding.lockedCheckBox.isChecked = me.locked
accountFieldEditAdapter.setFields(me.source?.fields ?: emptyList())
accountFieldEditAdapter.setFields(me.source?.fields.orEmpty())
binding.addFieldButton.isVisible =
(me.source?.fields?.size ?: 0) < maxAccountFields

View File

@ -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)

View File

@ -145,7 +145,7 @@ fun TimelineAccount.toEntity() =
username = username,
displayName = name,
avatar = avatar,
emojis = emojis ?: emptyList()
emojis = emojis.orEmpty()
)
fun Status.toEntity(

View File

@ -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 {

View File

@ -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

View File

@ -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)
}
}

View File

@ -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,

View File

@ -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

View File

@ -153,9 +153,9 @@ class AccountManager @Inject constructor(db: AppDatabase) {
it.displayName = account.name
it.profilePictureUrl = account.avatar
it.defaultPostPrivacy = account.source?.privacy ?: Status.Visibility.PUBLIC
it.defaultPostLanguage = account.source?.language ?: ""
it.defaultPostLanguage = account.source?.language.orEmpty()
it.defaultMediaSensitivity = account.source?.sensitive ?: false
it.emojis = account.emojis ?: emptyList()
it.emojis = account.emojis.orEmpty()
Log.d(TAG, "updateActiveAccount: saving account with id " + it.id)
accountDao.insertOrReplace(it)

View File

@ -49,8 +49,8 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
val senderFullName = intent.getStringExtra(NotificationHelper.KEY_SENDER_ACCOUNT_FULL_NAME)
val citedStatusId = intent.getStringExtra(NotificationHelper.KEY_CITED_STATUS_ID)
val visibility = intent.getSerializableExtra(NotificationHelper.KEY_VISIBILITY) as Status.Visibility
val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER) ?: ""
val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS) ?: emptyArray()
val spoiler = intent.getStringExtra(NotificationHelper.KEY_SPOILER).orEmpty()
val mentions = intent.getStringArrayExtra(NotificationHelper.KEY_MENTIONS).orEmpty()
val account = accountManager.getAccountById(senderId)

View File

@ -86,7 +86,7 @@ fun markupHiddenUrls(context: Context, content: CharSequence): SpannableStringBu
false
} else {
val text = spannableContent.subSequence(start, spannableContent.getSpanEnd(it)).toString()
.split(' ').lastOrNull() ?: ""
.split(' ').lastOrNull().orEmpty()
var textDomain = getDomain(text)
if (textDomain.isBlank()) {
textDomain = getDomain("https://$text")

View File

@ -73,7 +73,7 @@ class LocaleUtilsTest {
clientId = null,
clientSecret = null,
isActive = true,
defaultPostLanguage = configuredLanguages[1] ?: "",
defaultPostLanguage = configuredLanguages[1].orEmpty(),
)
)
}