perf: 优化收藏更新状态的展示

This commit is contained in:
HuanChengFly 2020-08-20 21:28:31 +08:00
parent 92f11c1a88
commit a34cd9d8d4
3 changed files with 76 additions and 78 deletions

View File

@ -5,12 +5,16 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.widget.TextView;
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
import com.huanchengfly.tieba.post.api.models.ThreadStoreBean;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.api.models.ThreadStoreBean;
import com.huanchengfly.tieba.post.components.spans.RoundBackgroundColorSpan;
import com.huanchengfly.tieba.post.interfaces.OnDeleteListener;
import com.huanchengfly.tieba.post.utils.*;
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
import com.huanchengfly.tieba.post.utils.DisplayUtil;
import com.huanchengfly.tieba.post.utils.ImageUtil;
import com.huanchengfly.tieba.post.utils.StringUtil;
import com.huanchengfly.tieba.post.utils.ThemeUtil;
import com.othershe.baseadapter.ViewHolder;
import com.othershe.baseadapter.base.CommonBaseAdapter;
@ -31,16 +35,20 @@ public class ThreadStoreAdapter extends CommonBaseAdapter<ThreadStoreBean.Thread
protected void convert(ViewHolder viewHolder, ThreadStoreBean.ThreadStoreInfo threadStoreInfo, int position) {
TextView textView = viewHolder.getView(R.id.collect_item_title);
if ("1".equals(threadStoreInfo.isDeleted())) {
textView.setTextColor(ThemeUtil.getSecondaryTextColor(mContext));
textView.setTextColor(ThemeUtils.getColorByAttr(mContext, R.attr.color_text_disabled));
viewHolder.setText(R.id.collect_item_header_title, R.string.tip_store_deleted);
} else {
textView.setTextColor(ThemeUtil.getTextColor(mContext));
viewHolder.setText(R.id.collect_item_header_title, threadStoreInfo.getAuthor().getNameShow() + "的贴子");
}
ImageUtil.load(viewHolder.getView(R.id.collect_item_avatar), ImageUtil.LOAD_TYPE_AVATAR, StringUtil.getAvatarUrl(threadStoreInfo.getAuthor().getUserPortrait()));
ImageUtil.load(
viewHolder.getView(R.id.collect_item_avatar),
ImageUtil.LOAD_TYPE_AVATAR,
StringUtil.getAvatarUrl(threadStoreInfo.getAuthor().getUserPortrait())
);
SpannableStringBuilder builder = new SpannableStringBuilder();
if (!TextUtils.equals(threadStoreInfo.getMarkPid(), threadStoreInfo.getMaxPid())) {
builder.append(Util.getTime(threadStoreInfo.getLastTime()) + "更新",
if (!TextUtils.equals(threadStoreInfo.getCount(), "0")) {
builder.append(mContext.getString(R.string.tip_thread_store_update, threadStoreInfo.getPostNo()),
new RoundBackgroundColorSpan(mContext, alphaColor(ThemeUtils.getColorByAttr(mContext, R.attr.colorAccent), 30),
ThemeUtils.getColorByAttr(mContext, R.attr.colorAccent),
DisplayUtil.dp2px(mContext, 12)), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

View File

@ -3,78 +3,67 @@ package com.huanchengfly.tieba.post.api.models
import com.google.gson.annotations.SerializedName
import com.huanchengfly.tieba.post.models.BaseBean
class ThreadStoreBean : BaseBean() {
@SerializedName("error_code")
val errorCode: String? = null
val error: ErrorInfo? = null
data class ThreadStoreBean(
@SerializedName("error_code")
val errorCode: String? = null,
val error: ErrorInfo? = null,
@SerializedName("store_thread")
val storeThread: List<ThreadStoreInfo>? = null
) : BaseBean() {
data class ThreadStoreInfo(
@SerializedName("thread_id")
val threadId: String,
val title: String,
@SerializedName("forum_name")
val forumName: String,
val author: AuthorInfo,
val media: List<MediaInfo>,
@SerializedName("is_deleted")
val isDeleted: String,
@SerializedName("last_time")
val lastTime: String,
val type: String,
val status: String,
@SerializedName("max_pid")
val maxPid: String,
@SerializedName("min_pid")
val minPid: String,
@SerializedName("mark_pid")
val markPid: String,
@SerializedName("mark_status")
val markStatus: String,
@SerializedName("post_no")
val postNo: String,
@SerializedName("post_no_msg")
val postNoMsg: String,
val count: String
) : BaseBean()
@SerializedName("store_thread")
val storeThread: List<ThreadStoreInfo>? = null
data class MediaInfo(
val type: String? = null,
@SerializedName("small_Pic")
val smallPic: String? = null,
@SerializedName("big_pic")
val bigPic: String? = null,
val width: String? = null,
val height: String? = null
) : BaseBean()
inner class ThreadStoreInfo : BaseBean() {
@SerializedName("thread_id")
val threadId: String? = null
val title: String? = null
data class AuthorInfo(
@SerializedName("lz_uid")
val lzUid: String? = null,
val name: String? = null,
@SerializedName("name_show")
val nameShow: String? = null,
@SerializedName("user_portrait")
val userPortrait: String? = null
@SerializedName("forum_name")
val forumName: String? = null
val author: AuthorInfo? = null
val media: List<MediaInfo>? = null
) : BaseBean()
@SerializedName("is_deleted")
val isDeleted: String? = null
@SerializedName("last_time")
val lastTime: String? = null
val type: String? = null
val status: String? = null
@SerializedName("max_pid")
val maxPid: String? = null
@SerializedName("min_pid")
val minPid: String? = null
@SerializedName("mark_pid")
val markPid: String? = null
@SerializedName("mark_status")
val markStatus: String? = null
}
inner class MediaInfo : BaseBean() {
val type: String? = null
@SerializedName("small_Pic")
val smallPic: String? = null
@SerializedName("big_pic")
val bigPic: String? = null
val width: String? = null
val height: String? = null
}
inner class AuthorInfo : BaseBean() {
@SerializedName("lz_uid")
val lzUid: String? = null
val name: String? = null
@SerializedName("name_show")
val nameShow: String? = null
@SerializedName("user_portrait")
val userPortrait: String? = null
}
inner class ErrorInfo : BaseBean() {
@SerializedName("errno")
val errorCode: String? = null
@SerializedName("errmsg")
val errorMsg: String? = null
}
}
data class ErrorInfo(
@SerializedName("errno")
val errorCode: String? = null,
@SerializedName("errmsg")
val errorMsg: String? = null
) : BaseBean()
}

View File

@ -359,4 +359,5 @@
<string name="title_emotion_classic">经典</string>
<string name="title_emotion_emoji">符号</string>
<string name="message_update_store_floor">是否更新收藏楼层</string>
<string name="tip_thread_store_update">更新到 %1$s 楼</string>
</resources>