クラッシュレポート対応。リファクタ。

This commit is contained in:
tateisu 2018-01-21 21:51:10 +09:00
parent cb34c6c458
commit fc48fd07a1
8 changed files with 17 additions and 18 deletions

View File

@ -1598,7 +1598,7 @@ class ActMain : AppCompatActivity()
val obj = result?.jsonObject
if(obj != null) {
// ダミーのLinkClickContext
val lcc = object : LinkClickContext {}
val lcc = object : LinkHelper {}
this.ta = TootAccount.parse(this@ActMain, lcc, obj)
}
return result
@ -1734,7 +1734,7 @@ class ActMain : AppCompatActivity()
val obj = result?.jsonObject
if(obj != null) {
// taは使い捨てなので、生成に使うLinkClickContextはダミーで問題ない
val lcc = object : LinkClickContext {}
val lcc = object : LinkHelper {}
this.ta = TootAccount.parse(this@ActMain, lcc, obj)
}
return result

View File

@ -2062,7 +2062,7 @@ class ActPost : AppCompatActivity(), View.OnClickListener, PostAttachment.Callba
val viewRoot = layoutInflater.inflate(R.layout.dlg_plugin_missing, null, false)
val tvText = viewRoot.findViewById<TextView>(R.id.tvText)
val lcc = object : LinkClickContext {}
val lcc = object : LinkHelper {}
val sv = DecodeOptions().decodeHTML(this@ActPost, lcc, text)
tvText.text = sv
tvText.movementMethod = LinkMovementMethod.getInstance()

View File

@ -13,7 +13,7 @@ import java.util.regex.Pattern
open class TootAccount(
context : Context,
accessInfo : LinkClickContext,
accessInfo : LinkHelper,
src : JSONObject,
serviceType : ServiceType
) : TimelineItem() {
@ -226,7 +226,7 @@ open class TootAccount(
fun parse(
context : Context,
account : LinkClickContext,
account : LinkHelper,
src : JSONObject?,
serviceType : ServiceType = ServiceType.MASTODON
) : TootAccount? {
@ -253,7 +253,7 @@ open class TootAccount(
fun parseList(
context : Context,
account : LinkClickContext,
account : LinkHelper,
array : JSONArray?
) : ArrayList<TootAccount> {
val result = ArrayList<TootAccount>()

View File

@ -7,12 +7,11 @@ import android.view.View
import java.lang.ref.WeakReference
import jp.juggler.subwaytooter.table.AcctColor
import jp.juggler.subwaytooter.util.LinkClickContext
typealias MyClickableSpanClickCallback = (widget : View, span : MyClickableSpan)->Unit
class MyClickableSpan(
// val lcc : LinkClickContext,
// val lcc : LinkHelper,
val text : String,
val url : String,
ac : AcctColor?,

View File

@ -17,7 +17,7 @@ import java.util.regex.Pattern
import jp.juggler.subwaytooter.App1
import jp.juggler.subwaytooter.api.entity.TootAccount
import jp.juggler.subwaytooter.api.entity.TootInstance
import jp.juggler.subwaytooter.util.LinkClickContext
import jp.juggler.subwaytooter.util.LinkHelper
import jp.juggler.subwaytooter.util.LogCategory
import jp.juggler.subwaytooter.util.parseString
import jp.juggler.subwaytooter.util.toJsonObject
@ -28,7 +28,7 @@ class SavedAccount(
hostArg : String? = null,
var token_info : JSONObject? = null,
var loginAccount : TootAccount? = null // 疑似アカウントではnull
) : LinkClickContext {
) : LinkHelper {
val username : String
@ -97,7 +97,7 @@ class SavedAccount(
val loginAccount = TootAccount.parse(
context,
object : LinkClickContext {
object : LinkHelper {
override val host : String?
get() = this@SavedAccount.host
},
@ -321,7 +321,7 @@ class SavedAccount(
return host_match(strNicoruHost, 0, host, host_start)
}
// implements LinkClickContext
// implements LinkHelper
override fun findAcctColor(url : String?) : AcctColor? {
if(url != null) {
val m = TootAccount.reAccountUrl.matcher(url)

View File

@ -29,7 +29,7 @@ class DecodeOptions(
////////////////////////
// decoder
fun decodeHTML(context : Context?, lcc : LinkClickContext?, html : String?) : SpannableStringBuilder {
fun decodeHTML(context : Context?, lcc : LinkHelper?, html : String?) : SpannableStringBuilder {
return HTMLDecoder.decodeHTML(context, lcc, html, this)
}

View File

@ -273,7 +273,7 @@ object HTMLDecoder {
internal fun encodeSpan(
context : Context?,
account : LinkClickContext?,
account : LinkHelper?,
sb : SpannableStringBuilder,
options : DecodeOptions
) {
@ -333,7 +333,7 @@ object HTMLDecoder {
if(href != null) {
val link_text = sb.subSequence(start, end).toString()
val span = MyClickableSpan(
account,
//account,
link_text,
href,
account.findAcctColor(href),
@ -462,7 +462,7 @@ object HTMLDecoder {
fun decodeHTML(
context : Context?,
account : LinkClickContext?,
account : LinkHelper?,
src : String?,
options : DecodeOptions
)
@ -515,7 +515,7 @@ object HTMLDecoder {
if(end > start) {
val link_text = sb.subSequence(start, end).toString()
val span = MyClickableSpan(
access_info,
//access_info,
link_text,
url,
access_info.findAcctColor(item.url),

View File

@ -3,7 +3,7 @@ package jp.juggler.subwaytooter.util
import jp.juggler.subwaytooter.table.AcctColor
// 派生クラスがあるのでラムダ式に変換してはいけない
interface LinkClickContext {
interface LinkHelper {
fun findAcctColor(url : String?) : AcctColor? = null