fix: 修复由于 API 变更导致的闪退
This commit is contained in:
parent
1c517de556
commit
a9c6d70af5
|
|
@ -26,8 +26,16 @@ import com.huanchengfly.tieba.post.models.ReplyInfoBean
|
|||
import com.huanchengfly.tieba.post.plugins.PluginManager
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.utils.ThemeUtils
|
||||
import com.huanchengfly.tieba.post.ui.widgets.MyLinearLayout
|
||||
import com.huanchengfly.tieba.post.utils.*
|
||||
import com.huanchengfly.tieba.post.utils.DateTimeUtils
|
||||
import com.huanchengfly.tieba.post.utils.DisplayUtil
|
||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||
import com.huanchengfly.tieba.post.utils.NavigationHelper
|
||||
import com.huanchengfly.tieba.post.utils.PostListAdapterHelper
|
||||
import com.huanchengfly.tieba.post.utils.StringUtil
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||
import com.huanchengfly.tieba.post.utils.TiebaUtil.reportPost
|
||||
import com.huanchengfly.tieba.post.utils.Util
|
||||
import com.huanchengfly.tieba.post.utils.appPreferences
|
||||
|
||||
|
||||
class ThreadMainPostAdapter(
|
||||
|
|
@ -123,7 +131,7 @@ class ThreadMainPostAdapter(
|
|||
}
|
||||
R.id.menu_copy -> {
|
||||
val stringBuilder = StringBuilder()
|
||||
for (contentBean in threadPostBean!!.content!!) {
|
||||
for (contentBean in threadPostBean!!.content ?: emptyList()) {
|
||||
when (contentBean.type) {
|
||||
"2" -> contentBean.setText("#(" + contentBean.c + ")")
|
||||
"3", "20" -> contentBean.setText("[图片]\n")
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
builder.append(":")
|
||||
}
|
||||
if (subPostListItemBean.content!!.isNotEmpty() && "10" == subPostListItemBean.content[0].type) {
|
||||
if (!subPostListItemBean.content.isNullOrEmpty() && "10" == subPostListItemBean.content[0].type) {
|
||||
val voiceUrl =
|
||||
"http://c.tieba.baidu.com/c/p/voice?voice_md5=" + subPostListItemBean.content[0].voiceMD5 + "&play_from=pb_voice_play"
|
||||
val container = RelativeLayout(context)
|
||||
|
|
@ -184,7 +184,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
val textView = createTextView()
|
||||
textView.layoutParams = defaultLayoutParamsWithNoMargins
|
||||
for (contentBean in subPostListItemBean.content) {
|
||||
for (contentBean in subPostListItemBean.content ?: emptyList()) {
|
||||
when (contentBean.type) {
|
||||
"0" -> {
|
||||
if (BlockUtil.needBlock(contentBean.text) || BlockUtil.needBlock(userInfoBean)) {
|
||||
|
|
@ -192,6 +192,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
builder.append(contentBean.text)
|
||||
}
|
||||
|
||||
"1" -> builder.append(
|
||||
contentBean.text,
|
||||
MyURLSpan(context, contentBean.link),
|
||||
|
|
@ -336,7 +337,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
R.id.menu_copy -> {
|
||||
val stringBuilder = StringBuilder()
|
||||
for (contentBean in subPostListItemBean.content!!) {
|
||||
for (contentBean in subPostListItemBean.content ?: emptyList()) {
|
||||
when (contentBean.type) {
|
||||
"2" -> contentBean.setText("#(" + contentBean.c + ")")
|
||||
"3", "20" -> contentBean.setText("[图片]\n")
|
||||
|
|
@ -456,7 +457,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
R.id.menu_copy -> {
|
||||
val stringBuilder = StringBuilder()
|
||||
for (contentBean in postListItemBean.content!!) {
|
||||
for (contentBean in postListItemBean.content ?: emptyList()) {
|
||||
when (contentBean.type) {
|
||||
"2" -> contentBean.setText("#(" + contentBean.c + ")")
|
||||
"3", "20" -> contentBean.setText("[图片]\n")
|
||||
|
|
@ -694,7 +695,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
blockCacheMap[postListItemBean.floor] = true
|
||||
return true
|
||||
}
|
||||
for (contentBean in postListItemBean.content!!) {
|
||||
for (contentBean in postListItemBean.content ?: emptyList()) {
|
||||
if ("0" == contentBean.type) {
|
||||
if (BlockUtil.needBlock(contentBean.text)) {
|
||||
blockCacheMap[postListItemBean.floor] = true
|
||||
|
|
@ -714,7 +715,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
|
||||
companion object {
|
||||
val TAG = ThreadReplyAdapter::class.java.simpleName
|
||||
const val TAG = "ThreadReplyAdapter"
|
||||
const val TYPE_REPLY = 1000
|
||||
const val TYPE_THREAD = 1001
|
||||
const val MAX_SUB_POST_SHOW = 3
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ class ForumPageBean : ErrorBean() {
|
|||
return this
|
||||
}
|
||||
|
||||
fun setAbstractBeans(abstractBeans: List<AbstractBean>?): ThreadBean {
|
||||
fun setAbstractBeans(abstractBeans: List<AbstractBean?>?): ThreadBean {
|
||||
this.abstractBeans = abstractBeans
|
||||
return this
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class PersonalizedFeedFragment : BaseFragment(), PersonalizedFeedAdapter.OnRefre
|
|||
}
|
||||
val newThreadBeans: List<PersonalizedBean.ThreadBean> =
|
||||
bean.threadList?.filterNot {
|
||||
(it.abstractBeans?.size!! > 0 && BlockUtil.needBlock(it.abstractBeans[0].text)) || BlockUtil.needBlock(
|
||||
(!it.abstractBeans.isNullOrEmpty() && BlockUtil.needBlock(it.abstractBeans[0].text)) || BlockUtil.needBlock(
|
||||
it.author?.nameShow,
|
||||
it.author?.id
|
||||
)
|
||||
|
|
@ -232,7 +232,9 @@ class PersonalizedFeedFragment : BaseFragment(), PersonalizedFeedAdapter.OnRefre
|
|||
}
|
||||
val newThreadBeans: List<PersonalizedBean.ThreadBean> =
|
||||
it.threadList?.filterNot { threadBean ->
|
||||
(threadBean.abstractBeans?.size!! > 0 && BlockUtil.needBlock(threadBean.abstractBeans[0].text)) || BlockUtil.needBlock(
|
||||
(!threadBean.abstractBeans.isNullOrEmpty() && BlockUtil.needBlock(
|
||||
threadBean.abstractBeans[0].text
|
||||
)) || BlockUtil.needBlock(
|
||||
threadBean.author?.nameShow,
|
||||
threadBean.author?.id
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import java.text.NumberFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class PluginAsoulCnki(app: IApp, manifest: PluginManifest) : IPlugin(app, manifest) {
|
||||
override fun onEnable() {
|
||||
|
|
@ -153,7 +154,7 @@ class PluginAsoulCnki(app: IApp, manifest: PluginManifest) : IPlugin(app, manife
|
|||
|
||||
fun getPostTextContent(item: ThreadContentBean.PostListItemBean): String {
|
||||
val stringBuilder = StringBuilder()
|
||||
for (contentBean in item.content!!) {
|
||||
for (contentBean in item.content ?: emptyList()) {
|
||||
when (contentBean.type) {
|
||||
"2" -> contentBean.setText("#(" + contentBean.c + ")")
|
||||
"3", "20" -> contentBean.setText("[图片]\n")
|
||||
|
|
|
|||
Loading…
Reference in New Issue