【光环助手V4.5.0】论坛搜索功能及部分优化 UI测试 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/1049
This commit is contained in:
@ -279,13 +279,19 @@ object ImageUtils {
|
||||
})
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun display(view: SimpleDraweeView?, url: String?) {
|
||||
display(view, url, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则 width>0 Wifi/4G:x2 traffic:x1
|
||||
* 第一种方案:通过LayoutParams获取 可以快速(无延迟)获取宽高,但是无法获取wrap_content和match_parent的View
|
||||
* 第二种方案(备用方案):有延迟,View的宽高需要在Measure过程后才能确定,能够在这里获取到正确的宽高
|
||||
* @param isAutoPlayGif 是否禁止播放动图
|
||||
*/
|
||||
@JvmStatic
|
||||
fun display(view: SimpleDraweeView?, url: String?) {
|
||||
fun display(view: SimpleDraweeView?, url: String?, isAutoPlayGif: Boolean = true) {
|
||||
if (url.isNullOrEmpty()) return
|
||||
|
||||
val width = view?.layoutParams?.width
|
||||
@ -319,7 +325,7 @@ object ImageUtils {
|
||||
view?.setTag(R.string.highResImageTag, highResUrl)
|
||||
}
|
||||
|
||||
val shouldLoadAsGif = url.endsWith(".gif") && view?.getTag(R.id.tag_show_gif) != false
|
||||
val shouldLoadAsGif = url.endsWith(".gif") && isAutoPlayGif && view?.getTag(R.id.tag_show_gif) != false
|
||||
|
||||
if (shouldLoadAsGif && view?.tag == url) return
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import android.text.TextUtils
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.facebook.drawee.generic.RoundingParams
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.gh.common.util.DisplayUtils
|
||||
@ -18,6 +19,7 @@ class GameIconView : ConstraintLayout {
|
||||
|
||||
private var mCornerRadius = 10
|
||||
private var mBorderColor = 0
|
||||
private var mGameIconOverlayColor = 0
|
||||
private var mBorderWidth = 1
|
||||
private var mFadeDuration = -1
|
||||
|
||||
@ -36,11 +38,15 @@ class GameIconView : ConstraintLayout {
|
||||
val ta = context.obtainStyledAttributes(attrs, R.styleable.GameIconView)
|
||||
mCornerRadius = ta.getDimensionPixelSize(R.styleable.GameIconView_gameIconCornerRadius, DisplayUtils.dip2px(10F))
|
||||
mBorderColor = ta.getColor(R.styleable.GameIconView_gameIconBorderColor, 0)
|
||||
mGameIconOverlayColor = ta.getColor(R.styleable.GameIconView_gameIconOverlayColor, 0)
|
||||
mBorderWidth = ta.getDimensionPixelSize(R.styleable.GameIconView_gameIconBorderWidth, 1)
|
||||
mFadeDuration = ta.getInt(R.styleable.GameIconView_gameIconFadeDuration, -1)
|
||||
ta.recycle()
|
||||
|
||||
val roundingParams = RoundingParams.fromCornersRadius(mCornerRadius.toFloat())
|
||||
if (mGameIconOverlayColor != 0) {
|
||||
roundingParams.overlayColor = mGameIconOverlayColor
|
||||
}
|
||||
|
||||
if (mBorderColor != 0) {
|
||||
roundingParams.setBorder(mBorderColor, mBorderWidth.toFloat())
|
||||
|
||||
@ -43,7 +43,7 @@ class ForumFollowAdapter(context: Context) : BaseRecyclerAdapter<RecyclerView.Vi
|
||||
} else {
|
||||
val view = View(mContext).apply {
|
||||
val params = RecyclerView.LayoutParams(1f.dip2px(), 22f.dip2px())
|
||||
params.topMargin = 13f.dip2px()
|
||||
params.topMargin = 17f.dip2px()
|
||||
layoutParams = params
|
||||
setBackgroundColor(ContextCompat.getColor(mContext, R.color.text_eeeeee))
|
||||
}
|
||||
|
||||
@ -7,14 +7,13 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.getSpans
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.base.BaseActivity
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.common.syncpage.ISyncAdapterHandler
|
||||
import com.gh.common.util.ImageUtils
|
||||
import com.gh.common.util.MtaHelper
|
||||
import com.gh.common.util.SpanBuilder
|
||||
import com.gh.common.util.dip2px
|
||||
import com.gh.common.util.fromHtml
|
||||
import com.gh.common.view.CenterImageSpan
|
||||
@ -69,7 +68,17 @@ class ForumContentSearchListAdapter(context: Context, val mEntrance: String) : L
|
||||
if (mEntrance == "论坛首页+(搜索)") {
|
||||
val answerViewHolder = holder as ForumArticleAskItemViewHolder
|
||||
answerViewHolder.bindForumAnswerItem(answer, mEntrance, "")
|
||||
answerViewHolder.binding.title.text = answer.questions.title?.fromHtml()
|
||||
if (answer.type == "question") {
|
||||
answerViewHolder.binding.content.visibility = View.GONE
|
||||
val title = answer.questions.title ?: ""
|
||||
val spannableStringBuilder = SpannableStringBuilder(" ")
|
||||
spannableStringBuilder.setSpan(CenterImageSpan(mContext, R.drawable.ic_ask_label), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
spannableStringBuilder.append(title.fromHtml())
|
||||
answerViewHolder.binding.title.text = spannableStringBuilder
|
||||
} else {
|
||||
answerViewHolder.binding.content.visibility = View.VISIBLE
|
||||
answerViewHolder.binding.title.text = answer.questions.title?.fromHtml()
|
||||
}
|
||||
answerViewHolder.binding.content.text = answer.brief?.fromHtml()
|
||||
answerViewHolder.itemView.setOnClickListener {
|
||||
val entrance = BaseActivity.mergeEntranceAndPath(mEntrance, "")
|
||||
@ -81,6 +90,14 @@ class ForumContentSearchListAdapter(context: Context, val mEntrance: String) : L
|
||||
mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, answer.id, mEntrance, ""))
|
||||
}
|
||||
}
|
||||
if (answer.type != "community_article") {
|
||||
answerViewHolder.commentCount.text = "回答"
|
||||
answerViewHolder.voteCountContainer.visibility = View.GONE
|
||||
val params = answerViewHolder.binding.includeVoteAndComment.root.layoutParams as LinearLayout.LayoutParams
|
||||
params.width = 80f.dip2px()
|
||||
answerViewHolder.binding.includeVoteAndComment.root.layoutParams = params
|
||||
}
|
||||
|
||||
} else {
|
||||
val forumSearchHolder = holder as ForumSearchContentListViewHolder
|
||||
forumSearchHolder.binding.entity = answer
|
||||
@ -95,6 +112,21 @@ class ForumContentSearchListAdapter(context: Context, val mEntrance: String) : L
|
||||
forumSearchHolder.binding.content.visibility = View.VISIBLE
|
||||
forumSearchHolder.binding.title.text = answer.questions.title?.fromHtml()
|
||||
}
|
||||
when {
|
||||
answer.getPassVideos().isNotEmpty() -> {
|
||||
val poster = answer.getPassVideos()[0].poster
|
||||
ImageUtils.display(forumSearchHolder.binding.image, poster,false)
|
||||
forumSearchHolder.binding.image.visibility = View.VISIBLE
|
||||
}
|
||||
answer.images.isNotEmpty() -> {
|
||||
forumSearchHolder.binding.image.visibility = View.VISIBLE
|
||||
ImageUtils.display(forumSearchHolder.binding.image, answer.images[0],false)
|
||||
}
|
||||
else -> {
|
||||
forumSearchHolder.binding.image.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
forumSearchHolder.binding.content.text = answer.brief?.fromHtml()
|
||||
forumSearchHolder.itemView.setOnClickListener {
|
||||
if ("community_article" == answer.type) {
|
||||
|
||||
@ -6,8 +6,11 @@ import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.util.DisplayUtils
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.common.util.viewModelProvider
|
||||
import com.gh.common.view.divider.HorizontalDividerItemDecoration
|
||||
import com.gh.common.view.divider.VerticalDividerItemDecoration
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.baselist.ListFragment
|
||||
@ -53,7 +56,12 @@ class ForumContentSearchListFragment : ListFragment<AnswerEntity, ForumContentSe
|
||||
mListViewModel?.updateSearchKey(mSearchKey)
|
||||
}
|
||||
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration? = null
|
||||
override fun getItemDecoration(): RecyclerView.ItemDecoration? {
|
||||
return HorizontalDividerItemDecoration.Builder(requireContext())
|
||||
.size(DisplayUtils.dip2px(0.5f))
|
||||
.margin(DisplayUtils.dip2px(20f))
|
||||
.color(ContextCompat.getColor(requireContext(), R.color.text_f5f5f5)).build()
|
||||
}
|
||||
|
||||
override fun addSyncPageObserver(): Boolean = true
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import android.app.Activity
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.webkit.JavascriptInterface
|
||||
import android.widget.TextView
|
||||
@ -267,26 +266,28 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
|
||||
private fun addTag(tag: String, isCommunityName: Boolean = false) {
|
||||
binding.run {
|
||||
val view = LayoutInflater.from(root.context).inflate(R.layout.questionsdedit_tag_item, null)
|
||||
val tagTv = view as TextView
|
||||
val params = FlexboxLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
params.setMargins(0, 5F.dip2px(), 8F.dip2px(), 5F.dip2px())
|
||||
|
||||
tagTv.text = tag
|
||||
tagTv.setTextColor(if (!isCommunityName) R.color.theme_font.toColor() else R.color.text_666666.toColor())
|
||||
if (isCommunityName) {
|
||||
tagTv.setPadding(8F.dip2px(), 8F.dip2px(), 8F.dip2px(), 8F.dip2px())
|
||||
tagTv.setRoundedColorBackground(R.color.text_F5F5F5, 5F)
|
||||
tagTv.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(root.context, R.drawable.ic_article_detail_forum_tag), null,
|
||||
ContextCompat.getDrawable(root.context,R.drawable.ic_article_tag_arrow_right), null)
|
||||
tagTv.compoundDrawablePadding = 5F.dip2px()
|
||||
tagTv.setOnClickListener {
|
||||
val view = LayoutInflater.from(root.context).inflate(R.layout.article_detail_fourm_tag_item, null)
|
||||
val tagTv = view.findViewById<TextView>(R.id.tagTv)
|
||||
tagTv.text = tag
|
||||
|
||||
view.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", tag)
|
||||
DirectUtils.directForumDetail(tagTv.context, viewModel.detailEntity?.communityId, "帖子详情")
|
||||
LogUtils.uploadAccessToBbs(viewModel.detailEntity?.communityId, "文章内所属论坛")
|
||||
}
|
||||
tagsFlexbox.addView(view)
|
||||
|
||||
val params = view.layoutParams as FlexboxLayout.LayoutParams
|
||||
params.setMargins(0, 5F.dip2px(), 8F.dip2px(), 5F.dip2px())
|
||||
view.layoutParams = params
|
||||
} else {
|
||||
tagTv.setPadding(14F.dip2px(), 8F.dip2px(), 14F.dip2px(), 8F.dip2px())
|
||||
val view = LayoutInflater.from(root.context).inflate(R.layout.questionsdedit_tag_item, null)
|
||||
val tagTv = view as TextView
|
||||
|
||||
tagTv.text = tag
|
||||
tagTv.setTextColor(R.color.theme_font.toColor())
|
||||
tagTv.setPadding(14F.dip2px(), 0, 14F.dip2px(), 0)
|
||||
tagTv.setRoundedColorBackground(R.color.text_EEF5FB, 5F)
|
||||
tagTv.setOnClickListener {
|
||||
MtaHelper.onEvent("帖子详情", "内容区域", tag)
|
||||
@ -294,9 +295,13 @@ class ArticleDetailContentViewHolder(var binding: ItemArticleDetailContentBindin
|
||||
root.context.startActivity(AskColumnDetailActivity.getIntentByTag(root.context, tag,
|
||||
CommunityEntity(viewModel.detailEntity!!.communityId), mEntrance, "帖子详情"))
|
||||
}
|
||||
tagsFlexbox.addView(view)
|
||||
|
||||
val params = view.layoutParams as FlexboxLayout.LayoutParams
|
||||
params.setMargins(0, 5F.dip2px(), 8F.dip2px(), 5F.dip2px())
|
||||
tagTv.layoutParams = params
|
||||
}
|
||||
tagTv.layoutParams = params
|
||||
tagsFlexbox.addView(view)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user