クラッシュレポート対応。リファクタ。
This commit is contained in:
parent
4ab6f78121
commit
ecb7b1bc75
|
@ -332,7 +332,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
|
|||
// 画像のURL
|
||||
val uri : Uri? = data?.data ?: uriCameraImage
|
||||
if(uri != null) {
|
||||
val type = contentResolver.getType(uri)
|
||||
val type :String? = contentResolver.getType(uri)
|
||||
addAttachment(uri, type)
|
||||
}
|
||||
}
|
||||
|
@ -1254,7 +1254,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak") private fun addAttachment(uri : Uri, mime_type : String) {
|
||||
@SuppressLint("StaticFieldLeak") private fun addAttachment(uri : Uri, mime_type : String?) {
|
||||
|
||||
if(attachment_list.size >= 4) {
|
||||
Utils.showToast(this, false, R.string.attachment_too_many)
|
||||
|
@ -1268,7 +1268,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
|
|||
}
|
||||
|
||||
|
||||
if(mime_type.isEmpty()) {
|
||||
if(mime_type?.isEmpty() != false) {
|
||||
Utils.showToast(this, false, R.string.mime_type_missing)
|
||||
return
|
||||
} else if(! acceptable_mime_types.contains(mime_type)) {
|
||||
|
|
|
@ -633,44 +633,34 @@ class Column(
|
|||
return getIconAttrId(access_info.acct, type)
|
||||
}
|
||||
|
||||
interface StatusEntryCallback {
|
||||
fun onIterate(account : SavedAccount, status : TootStatus) : Boolean
|
||||
}
|
||||
|
||||
// ブーストやお気に入りの更新に使う。ステータスを列挙する。
|
||||
fun findStatus(
|
||||
target_instance : String,
|
||||
target_status_id : Long,
|
||||
callback : StatusEntryCallback
|
||||
callback : (account : SavedAccount, status : TootStatus) -> Boolean
|
||||
// callback return true if rebind view required
|
||||
) {
|
||||
if(access_info.host.equals(target_instance, ignoreCase = true)) {
|
||||
if(! access_info.host.equals(target_instance, ignoreCase = true)) return
|
||||
|
||||
var bChanged = false
|
||||
|
||||
val status_proc = { status : TootStatus ->
|
||||
fun procStatus(status : TootStatus?) {
|
||||
if(status != null) {
|
||||
if(target_status_id == status.id) {
|
||||
if(callback.onIterate(access_info, status)) {
|
||||
bChanged = true
|
||||
}
|
||||
}
|
||||
val reblog = status.reblog
|
||||
if(reblog != null && target_status_id == reblog.id) {
|
||||
if(callback.onIterate(access_info, reblog)) {
|
||||
bChanged = true
|
||||
if(callback(access_info, status)) bChanged = true
|
||||
}
|
||||
procStatus(status.reblog)
|
||||
}
|
||||
}
|
||||
|
||||
for(data in list_data) {
|
||||
when(data) {
|
||||
is TootNotification -> data.status?.let(status_proc)
|
||||
is TootStatus -> status_proc(data)
|
||||
}
|
||||
}
|
||||
if(bChanged) {
|
||||
fireShowContent(reason="findStatus",reset=true)
|
||||
is TootNotification -> procStatus(data.status)
|
||||
is TootStatus -> procStatus(data)
|
||||
}
|
||||
}
|
||||
|
||||
if(bChanged) fireRebindAdapterItems()
|
||||
}
|
||||
|
||||
// ミュート、ブロックが成功した時に呼ばれる
|
||||
|
@ -758,7 +748,7 @@ class Column(
|
|||
}
|
||||
} else {
|
||||
// 他のカラムでもフォロー状態の表示更新が必要
|
||||
fireShowContent(reason="removeFollowRequest 2",reset=true)
|
||||
fireRebindAdapterItems()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -983,7 +973,6 @@ class Column(
|
|||
viewHolder?.rebindAdapterItems()
|
||||
}
|
||||
|
||||
|
||||
private fun cancelLastTask() {
|
||||
if(last_task != null) {
|
||||
last_task?.cancel(true)
|
||||
|
@ -2616,7 +2605,10 @@ class Column(
|
|||
|
||||
val list_new = duplicate_map.filterDuplicate(list_tmp)
|
||||
if(list_new.isEmpty()) {
|
||||
fireShowContent(reason="refresh list_new is empty",changeList = ArrayList())
|
||||
fireShowContent(
|
||||
reason = "refresh list_new is empty",
|
||||
changeList = ArrayList()
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2630,7 +2622,13 @@ class Column(
|
|||
val added = list_new.size
|
||||
|
||||
if(bBottom) {
|
||||
val changeList = listOf(AdapterChange(AdapterChangeType.RangeInsert,list_data.size,added))
|
||||
val changeList = listOf(
|
||||
AdapterChange(
|
||||
AdapterChangeType.RangeInsert,
|
||||
list_data.size,
|
||||
added
|
||||
)
|
||||
)
|
||||
list_data.addAll(list_new)
|
||||
fireShowContent(reason = "refresh updated bottom", changeList = changeList)
|
||||
|
||||
|
@ -2660,7 +2658,8 @@ class Column(
|
|||
}
|
||||
}
|
||||
|
||||
val changeList = listOf(AdapterChange(AdapterChangeType.RangeInsert,0,added))
|
||||
val changeList =
|
||||
listOf(AdapterChange(AdapterChangeType.RangeInsert, 0, added))
|
||||
list_data.addAll(0, list_new)
|
||||
fireShowContent(reason = "refresh updated head", changeList = changeList)
|
||||
|
||||
|
@ -3063,7 +3062,6 @@ class Column(
|
|||
|
||||
// 0個でもギャップを消すために以下の処理を続ける
|
||||
|
||||
|
||||
val list_new = duplicate_map.filterDuplicate(list_tmp)
|
||||
|
||||
// idx番目の要素がListViewのtopから何ピクセル下にあるか
|
||||
|
@ -3475,7 +3473,6 @@ class Column(
|
|||
log.d("mergeStreamingMessage: has VH. missing scroll position.")
|
||||
viewHolder?.scrollToTop()
|
||||
|
||||
|
||||
} else if(holder_sp.adapterIndex == 0 && holder_sp.offset == 0) {
|
||||
// スクロール位置が先頭なら先頭にする
|
||||
log.d(
|
||||
|
@ -3504,5 +3501,4 @@ class Column(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ internal class ItemListAdapter(
|
|||
new_list.addAll(column.list_data)
|
||||
|
||||
when {
|
||||
// 変更リストが指定された場合はヘッダ部分とリスト要素を通知する
|
||||
// 変更リストが指定された場合はヘッダ部分と変更部分を通知する
|
||||
changeList != null -> {
|
||||
|
||||
log.d("notifyChange: changeList=${changeList.size},reason=$reason")
|
||||
|
|
|
@ -152,15 +152,18 @@ object Action_Toot {
|
|||
|
||||
|
||||
for(column in App1.getAppState(activity).column_list) {
|
||||
column.findStatus(access_info.host, new_status.id, object : Column.StatusEntryCallback {
|
||||
override fun onIterate(account : SavedAccount, status : TootStatus) : Boolean {
|
||||
column.findStatus(access_info.host, new_status.id){ account,status ->
|
||||
|
||||
// 同タンス別アカウントでもカウントは変化する
|
||||
status.favourites_count = new_status.favourites_count
|
||||
if(access_info.acct.equals(account.acct, ignoreCase = true)) {
|
||||
|
||||
if(access_info.acct == account.acct ) {
|
||||
// 同アカウントならfav状態を変化させる
|
||||
status.favourited = new_status.favourited
|
||||
}
|
||||
return true
|
||||
|
||||
true
|
||||
}
|
||||
})
|
||||
}
|
||||
if(callback != null) callback()
|
||||
|
||||
|
@ -328,15 +331,17 @@ object Action_Toot {
|
|||
}
|
||||
|
||||
for(column in App1.getAppState(activity).column_list) {
|
||||
column.findStatus(access_info.host, new_status.id, object : Column.StatusEntryCallback {
|
||||
override fun onIterate(account : SavedAccount, status : TootStatus) : Boolean {
|
||||
column.findStatus(access_info.host, new_status.id){ account, status ->
|
||||
|
||||
// 同タンス別アカウントでもカウントは変化する
|
||||
status.reblogs_count = new_status.reblogs_count
|
||||
if(access_info.acct.equals(account.acct, ignoreCase = true)) {
|
||||
|
||||
if(access_info.acct == account.acct ) {
|
||||
// 同アカウントならreblog状態を変化させる
|
||||
status.reblogged = new_status.reblogged
|
||||
}
|
||||
return true
|
||||
true
|
||||
}
|
||||
})
|
||||
}
|
||||
if(callback != null) callback()
|
||||
}
|
||||
|
@ -621,13 +626,15 @@ object Action_Toot {
|
|||
// cancelled.
|
||||
}
|
||||
|
||||
new_status != null -> for(column in App1.getAppState(activity).column_list) {
|
||||
column.findStatus(access_info.host, new_status.id, object : Column.StatusEntryCallback {
|
||||
override fun onIterate(account : SavedAccount, status : TootStatus) : Boolean {
|
||||
new_status != null ->{
|
||||
for(column in App1.getAppState(activity).column_list) {
|
||||
if( access_info.acct == column.access_info.acct){
|
||||
column.findStatus(access_info.host, new_status.id){_,status->
|
||||
status.pinned = bSet
|
||||
return true
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
else -> Utils.showToast(activity, true, result.error)
|
||||
}
|
||||
|
@ -745,14 +752,12 @@ object Action_Toot {
|
|||
val ls = local_status
|
||||
if(ls != null) {
|
||||
for(column in App1.getAppState(activity).column_list) {
|
||||
column.findStatus(access_info.host, ls.id, object : Column.StatusEntryCallback {
|
||||
override fun onIterate(account : SavedAccount, status : TootStatus) : Boolean {
|
||||
if(access_info.acct.equals(account.acct, ignoreCase = true)) {
|
||||
if(access_info.acct == column.access_info.acct ) {
|
||||
column.findStatus(access_info.host, ls.id) { _, status ->
|
||||
status.muted = bMute
|
||||
true
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
Utils.showToast(activity, true, if(bMute) R.string.mute_succeeded else R.string.unmute_succeeded)
|
||||
} else {
|
||||
|
|
|
@ -12,10 +12,12 @@ import java.util.ArrayList
|
|||
|
||||
import jp.juggler.subwaytooter.App1
|
||||
import jp.juggler.subwaytooter.Pref
|
||||
import jp.juggler.subwaytooter.R
|
||||
import jp.juggler.subwaytooter.span.EmojiImageSpan
|
||||
import jp.juggler.subwaytooter.span.HighlightSpan
|
||||
import jp.juggler.subwaytooter.span.NetworkEmojiSpan
|
||||
import jp.juggler.subwaytooter.table.HighlightWord
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object EmojiDecoder {
|
||||
|
||||
|
@ -228,6 +230,9 @@ object EmojiDecoder {
|
|||
}
|
||||
}
|
||||
|
||||
private val reNicoru = Pattern.compile("\\Anicoru\\d*\\z", Pattern.CASE_INSENSITIVE)
|
||||
private val reHohoemi = Pattern.compile("\\Ahohoemi\\d*\\z", Pattern.CASE_INSENSITIVE)
|
||||
|
||||
fun decodeEmoji(
|
||||
context : Context, s : String, options : DecodeOptions
|
||||
) : Spannable {
|
||||
|
@ -271,7 +276,12 @@ object EmojiDecoder {
|
|||
}
|
||||
}
|
||||
|
||||
builder.addUnicodeString(part)
|
||||
when {
|
||||
reHohoemi.matcher(name).find() -> builder.addImageSpan(part, R.drawable.emoji_hohoemi)
|
||||
reNicoru.matcher(name).find() -> builder.addImageSpan(part, R.drawable.emoji_nicoru)
|
||||
else -> builder.addUnicodeString(part)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue