1
0
mirror of https://github.com/TwidereProject/Twidere-Android synced 2025-01-20 20:18:35 +01:00

normalizes composing text

fixed NPE
This commit is contained in:
Mariotaku Lee 2017-04-19 00:15:34 +08:00
parent 4a36a4b857
commit 121950dc92
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
3 changed files with 10 additions and 4 deletions

View File

@ -107,6 +107,7 @@ import org.mariotaku.twidere.view.helper.SimpleItemTouchHelperCallback
import org.mariotaku.twidere.view.holder.compose.MediaPreviewViewHolder
import java.io.IOException
import java.lang.ref.WeakReference
import java.text.Normalizer
import java.util.*
import javax.inject.Inject
import kotlin.collections.ArrayList
@ -1405,7 +1406,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
if (accountKeys.isEmpty()) throw NoAccountException()
val update = ParcelableStatusUpdate()
val media = this.media
val text = editText.text?.toString().orEmpty()
val text = editText.string?.let { Normalizer.normalize(it, Normalizer.Form.NFC) }.orEmpty()
val accounts = AccountUtils.getAllAccountDetails(AccountManager.get(this), accountKeys, true)
val maxLength = statusTextCount.maxLength
val inReplyTo = inReplyToStatus

View File

@ -66,6 +66,7 @@ import org.mariotaku.microblog.library.twitter.model.User
import org.mariotaku.restfu.http.Endpoint
import org.mariotaku.restfu.oauth.OAuthToken
import org.mariotaku.restfu.oauth2.OAuth2Authorization
import org.mariotaku.twidere.BuildConfig
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.annotation.AccountType
@ -664,8 +665,12 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
val dialog = dialog ?: return
val listView = dialog.findViewById(R.id.expandableList) as ExpandableListView
val configGroup = data.groupBy { it.type ?: AccountType.TWITTER }
(listView.expandableListAdapter as LoginTypeAdapter).data = arrayOf(AccountType.TWITTER,
AccountType.FANFOU, AccountType.MASTODON, AccountType.STATUSNET).mapNotNull { type ->
val supportedAccountTypes = if (BuildConfig.DEBUG) {
arrayOf(AccountType.TWITTER, AccountType.FANFOU, AccountType.MASTODON, AccountType.STATUSNET)
} else {
arrayOf(AccountType.TWITTER, AccountType.FANFOU, AccountType.STATUSNET)
}
(listView.expandableListAdapter as LoginTypeAdapter).data = supportedAccountTypes.mapNotNull { type ->
if (type == AccountType.MASTODON) return@mapNotNull LoginType(type,
listOf(CustomAPIConfig.mastodon(context)))
return@mapNotNull configGroup[type]?.let { list -> LoginType(type, list) }

View File

@ -295,7 +295,7 @@ class ParcelableActivitiesAdapter(
if (mentionsOnly) return ITEM_VIEW_TYPE_EMPTY
filteredUserKeys?.let {
ParcelableActivityUtils.initAfterFilteredSourceIds(activity, it, followingOnly)
if (activity.after_filtered_source_ids.isEmpty()) {
if (activity.after_filtered_source_ids.isNullOrEmpty()) {
return ITEM_VIEW_TYPE_EMPTY
}
}