From 4fe1b61b85308fb98cf45fbf25f70b093accae16 Mon Sep 17 00:00:00 2001 From: ekibun Date: Mon, 25 Nov 2019 12:45:49 +0800 Subject: [PATCH] fix post floor 1 --- .../ekibun/bangumi/api/bangumi/bean/TopicPost.kt | 2 +- .../java/soko/ekibun/bangumi/util/HtmlTagHandler.kt | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/TopicPost.kt b/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/TopicPost.kt index 8500ce2..fed81d9 100644 --- a/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/TopicPost.kt +++ b/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/TopicPost.kt @@ -68,7 +68,7 @@ data class TopicPost( editable = it.selectFirst(".re_info")?.text()?.contains("/") == true, relate = relate.toString(), model = Regex("'([^']*)'").find(data.getOrNull(0) ?: "")?.groupValues?.get(1) ?: "", - floor = floor?.getOrNull(1)?.toIntOrNull() ?: 0, + floor = floor?.getOrNull(1)?.toIntOrNull() ?: 1, sub_floor = floor?.getOrNull(2)?.trim('-')?.toIntOrNull() ?: 0, badge = badge ) diff --git a/app/src/main/java/soko/ekibun/bangumi/util/HtmlTagHandler.kt b/app/src/main/java/soko/ekibun/bangumi/util/HtmlTagHandler.kt index 4732faa..92000ab 100644 --- a/app/src/main/java/soko/ekibun/bangumi/util/HtmlTagHandler.kt +++ b/app/src/main/java/soko/ekibun/bangumi/util/HtmlTagHandler.kt @@ -5,6 +5,7 @@ import android.text.* import android.text.style.ClickableSpan import android.text.style.ImageSpan import android.text.style.RelativeSizeSpan +import android.util.Log import android.view.View import android.widget.TextView import com.awarmisland.android.richedittext.view.RichEditText @@ -47,11 +48,12 @@ class HtmlTagHandler(view: TextView? = null, private var baseSize: Float = 12f, private fun endSize(tag: String, output: Editable, xmlReader: XMLReader) { endSizeIndex = output.length - var size = attributes["size"]?:"" + var size = attributes["size"] ?: "" size = size.split("px".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0] // 设置字体大小 if (!TextUtils.isEmpty(size)) { - output.setSpan(RelativeSizeSpan((size.toFloatOrNull()?:baseSize)/ baseSize), startSizeIndex, endSizeIndex, + output.setSpan(RelativeSizeSpan((size.toFloatOrNull() + ?: baseSize) / baseSize), startSizeIndex, endSizeIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) } } @@ -76,8 +78,8 @@ class HtmlTagHandler(view: TextView? = null, private var baseSize: Float = 12f, private val edit = textView.get() is RichEditText override fun onClick(widget: View) { if (edit) return - val view = textView.get()?:return - view.tag = if(view.tag == this) null else this + val view = textView.get() ?: return + view.tag = if (view.tag == this) null else this view.text = view.text } @@ -120,7 +122,7 @@ class HtmlTagHandler(view: TextView? = null, private var baseSize: Float = 12f, attributes[data[i * 5 + 1]] = data[i * 5 + 4] } } catch (e: Exception) { - e.printStackTrace() + Log.e("HtmlTag", e.localizedMessage ?: e.message ?: "") } }