fix: 修复一些导致闪退的问题

This commit is contained in:
HuanChengFly 2021-02-05 15:16:58 +08:00
parent db88f97b55
commit f1fae2f4cc
4 changed files with 34 additions and 18 deletions

View File

@ -401,7 +401,7 @@ class ForumActivity : BaseActivity(), View.OnClickListener, OnRefreshedListener,
private fun refreshHeaderView() { private fun refreshHeaderView() {
if (mDataBean != null && mDataBean!!.forum != null) { if (mDataBean != null && mDataBean!!.forum != null) {
headerView.visibility = View.VISIBLE headerView.visibility = View.VISIBLE
val color = getDarkerColor(greifyColor(Color.parseColor("#${mDataBean!!.forum!!.themeColor.day.commonColor}"), 0.15f), 0.1f) val color = getDarkerColor(greifyColor(Color.parseColor("#${mDataBean?.forum?.themeColor?.day?.commonColor ?: ThemeUtils.getColorById(this, R.color.default_color_primary)}"), 0.15f), 0.1f)
toolbarColor = color toolbarColor = color
appbar.backgroundTintList = ColorStateList.valueOf(color) appbar.backgroundTintList = ColorStateList.valueOf(color)
setCustomStatusColor(color) setCustomStatusColor(color)

View File

@ -90,7 +90,7 @@ class ForumPageBean : ErrorBean() {
var threadNum: String? = null var threadNum: String? = null
@SerializedName("theme_color") @SerializedName("theme_color")
lateinit var themeColor: ThemeColors var themeColor: ThemeColors? = null
@SerializedName("post_num") @SerializedName("post_num")
var postNum: String? = null var postNum: String? = null

View File

@ -32,10 +32,18 @@ class SearchForumFragment : BaseFragment(), ISearchFragment, OnItemClickListener
lateinit var recyclerView: RecyclerView lateinit var recyclerView: RecyclerView
private var keyword: String? = null private var keyword: String? = null
private lateinit var layoutManager: VirtualLayoutManager private val layoutManager: VirtualLayoutManager by lazy { VirtualLayoutManager(attachContext) }
private lateinit var delegateAdapter: DelegateAdapter private val delegateAdapter: DelegateAdapter by lazy { DelegateAdapter(layoutManager) }
private lateinit var exactMatchAdapter: SearchForumAdapter private val exactMatchAdapter: SearchForumAdapter by lazy {
private lateinit var fuzzyMatchAdapter: SearchForumAdapter SearchForumAdapter(attachContext).apply {
setOnItemClickListener(this@SearchForumFragment)
}
}
private val fuzzyMatchAdapter: SearchForumAdapter by lazy {
SearchForumAdapter(attachContext).apply {
setOnItemClickListener(this@SearchForumFragment)
}
}
private var mData: SearchForumBean.DataBean? = null private var mData: SearchForumBean.DataBean? = null
override fun setKeyword( override fun setKeyword(
@ -62,14 +70,6 @@ class SearchForumFragment : BaseFragment(), ISearchFragment, OnItemClickListener
if (arguments != null) { if (arguments != null) {
keyword = requireArguments().getString(ARG_KEYWORD) keyword = requireArguments().getString(ARG_KEYWORD)
} }
layoutManager = VirtualLayoutManager(attachContext)
delegateAdapter = DelegateAdapter(layoutManager)
exactMatchAdapter = SearchForumAdapter(attachContext).apply {
setOnItemClickListener(this@SearchForumFragment)
}
fuzzyMatchAdapter = SearchForumAdapter(attachContext).apply {
setOnItemClickListener(this@SearchForumFragment)
}
} }
public override fun getLayoutId(): Int { public override fun getLayoutId(): Int {

View File

@ -65,12 +65,18 @@ class PostListAdapterHelper(
if (postListItemBeans != null) { if (postListItemBeans != null) {
for (postListItemBean in postListItemBeans) { for (postListItemBean in postListItemBeans) {
val photoViewBeans: MutableList<PhotoViewBean> = ArrayList() val photoViewBeans: MutableList<PhotoViewBean> = ArrayList()
for (contentBean in postListItemBean.content!!) { if (postListItemBean.content.isNullOrEmpty() || postListItemBean.floor == null) {
continue
}
for (contentBean in postListItemBean.content) {
if (contentBean.type == "3") { if (contentBean.type == "3") {
if (contentBean.originSrc == null) {
continue
}
val url = ImageUtil.getUrl( val url = ImageUtil.getUrl(
context, context,
true, true,
contentBean.originSrc!!, contentBean.originSrc,
contentBean.bigCdnSrc, contentBean.bigCdnSrc,
contentBean.cdnSrcActive, contentBean.cdnSrcActive,
contentBean.cdnSrc contentBean.cdnSrc
@ -78,8 +84,18 @@ class PostListAdapterHelper(
if (url.isNullOrEmpty()) { if (url.isNullOrEmpty()) {
continue continue
} }
photoViewBeans.add(PhotoViewBean(url, photoViewBeans.add(
ImageUtil.getNonNullString(contentBean.originSrc, contentBean.bigCdnSrc, contentBean.cdnSrcActive, contentBean.cdnSrc), "1" == contentBean.isLongPic)) PhotoViewBean(
url,
ImageUtil.getNonNullString(
contentBean.originSrc,
contentBean.bigCdnSrc,
contentBean.cdnSrcActive,
contentBean.cdnSrc
),
"1" == contentBean.isLongPic
)
)
} }
} }
photoViewBeansMap[Integer.valueOf(postListItemBean.floor!!)] = photoViewBeans photoViewBeansMap[Integer.valueOf(postListItemBean.floor!!)] = photoViewBeans