perf: 优化收藏更新状态的展示
This commit is contained in:
parent
92f11c1a88
commit
a34cd9d8d4
|
|
@ -5,12 +5,16 @@ import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.widget.TextView;
|
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.R;
|
||||||
|
import com.huanchengfly.tieba.post.api.models.ThreadStoreBean;
|
||||||
import com.huanchengfly.tieba.post.components.spans.RoundBackgroundColorSpan;
|
import com.huanchengfly.tieba.post.components.spans.RoundBackgroundColorSpan;
|
||||||
import com.huanchengfly.tieba.post.interfaces.OnDeleteListener;
|
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.ViewHolder;
|
||||||
import com.othershe.baseadapter.base.CommonBaseAdapter;
|
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) {
|
protected void convert(ViewHolder viewHolder, ThreadStoreBean.ThreadStoreInfo threadStoreInfo, int position) {
|
||||||
TextView textView = viewHolder.getView(R.id.collect_item_title);
|
TextView textView = viewHolder.getView(R.id.collect_item_title);
|
||||||
if ("1".equals(threadStoreInfo.isDeleted())) {
|
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);
|
viewHolder.setText(R.id.collect_item_header_title, R.string.tip_store_deleted);
|
||||||
} else {
|
} else {
|
||||||
textView.setTextColor(ThemeUtil.getTextColor(mContext));
|
textView.setTextColor(ThemeUtil.getTextColor(mContext));
|
||||||
viewHolder.setText(R.id.collect_item_header_title, threadStoreInfo.getAuthor().getNameShow() + "的贴子");
|
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();
|
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||||
if (!TextUtils.equals(threadStoreInfo.getMarkPid(), threadStoreInfo.getMaxPid())) {
|
if (!TextUtils.equals(threadStoreInfo.getCount(), "0")) {
|
||||||
builder.append(Util.getTime(threadStoreInfo.getLastTime()) + "更新",
|
builder.append(mContext.getString(R.string.tip_thread_store_update, threadStoreInfo.getPostNo()),
|
||||||
new RoundBackgroundColorSpan(mContext, alphaColor(ThemeUtils.getColorByAttr(mContext, R.attr.colorAccent), 30),
|
new RoundBackgroundColorSpan(mContext, alphaColor(ThemeUtils.getColorByAttr(mContext, R.attr.colorAccent), 30),
|
||||||
ThemeUtils.getColorByAttr(mContext, R.attr.colorAccent),
|
ThemeUtils.getColorByAttr(mContext, R.attr.colorAccent),
|
||||||
DisplayUtil.dp2px(mContext, 12)), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
DisplayUtil.dp2px(mContext, 12)), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
|
|
||||||
|
|
@ -3,78 +3,67 @@ package com.huanchengfly.tieba.post.api.models
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
import com.huanchengfly.tieba.post.models.BaseBean
|
import com.huanchengfly.tieba.post.models.BaseBean
|
||||||
|
|
||||||
class ThreadStoreBean : BaseBean() {
|
data class ThreadStoreBean(
|
||||||
@SerializedName("error_code")
|
@SerializedName("error_code")
|
||||||
val errorCode: String? = null
|
val errorCode: String? = null,
|
||||||
val error: ErrorInfo? = null
|
val error: ErrorInfo? = null,
|
||||||
|
|
||||||
@SerializedName("store_thread")
|
@SerializedName("store_thread")
|
||||||
val storeThread: List<ThreadStoreInfo>? = null
|
val storeThread: List<ThreadStoreInfo>? = null
|
||||||
|
) : BaseBean() {
|
||||||
inner class ThreadStoreInfo : BaseBean() {
|
data class ThreadStoreInfo(
|
||||||
@SerializedName("thread_id")
|
@SerializedName("thread_id")
|
||||||
val threadId: String? = null
|
val threadId: String,
|
||||||
val title: String? = null
|
val title: String,
|
||||||
|
|
||||||
@SerializedName("forum_name")
|
@SerializedName("forum_name")
|
||||||
val forumName: String? = null
|
val forumName: String,
|
||||||
val author: AuthorInfo? = null
|
val author: AuthorInfo,
|
||||||
val media: List<MediaInfo>? = null
|
val media: List<MediaInfo>,
|
||||||
|
|
||||||
@SerializedName("is_deleted")
|
@SerializedName("is_deleted")
|
||||||
val isDeleted: String? = null
|
val isDeleted: String,
|
||||||
|
|
||||||
@SerializedName("last_time")
|
@SerializedName("last_time")
|
||||||
val lastTime: String? = null
|
val lastTime: String,
|
||||||
val type: String? = null
|
val type: String,
|
||||||
val status: String? = null
|
val status: String,
|
||||||
|
|
||||||
@SerializedName("max_pid")
|
@SerializedName("max_pid")
|
||||||
val maxPid: String? = null
|
val maxPid: String,
|
||||||
|
|
||||||
@SerializedName("min_pid")
|
@SerializedName("min_pid")
|
||||||
val minPid: String? = null
|
val minPid: String,
|
||||||
|
|
||||||
@SerializedName("mark_pid")
|
@SerializedName("mark_pid")
|
||||||
val markPid: String? = null
|
val markPid: String,
|
||||||
|
|
||||||
@SerializedName("mark_status")
|
@SerializedName("mark_status")
|
||||||
val markStatus: String? = null
|
val markStatus: String,
|
||||||
|
@SerializedName("post_no")
|
||||||
}
|
val postNo: String,
|
||||||
|
@SerializedName("post_no_msg")
|
||||||
inner class MediaInfo : BaseBean() {
|
val postNoMsg: String,
|
||||||
val type: String? = null
|
val count: String
|
||||||
|
) : BaseBean()
|
||||||
|
|
||||||
|
data class MediaInfo(
|
||||||
|
val type: String? = null,
|
||||||
@SerializedName("small_Pic")
|
@SerializedName("small_Pic")
|
||||||
val smallPic: String? = null
|
val smallPic: String? = null,
|
||||||
|
|
||||||
@SerializedName("big_pic")
|
@SerializedName("big_pic")
|
||||||
val bigPic: String? = null
|
val bigPic: String? = null,
|
||||||
val width: String? = null
|
val width: String? = null,
|
||||||
val height: String? = null
|
val height: String? = null
|
||||||
|
) : BaseBean()
|
||||||
|
|
||||||
}
|
data class AuthorInfo(
|
||||||
|
|
||||||
inner class AuthorInfo : BaseBean() {
|
|
||||||
@SerializedName("lz_uid")
|
@SerializedName("lz_uid")
|
||||||
val lzUid: String? = null
|
val lzUid: String? = null,
|
||||||
val name: String? = null
|
val name: String? = null,
|
||||||
|
|
||||||
@SerializedName("name_show")
|
@SerializedName("name_show")
|
||||||
val nameShow: String? = null
|
val nameShow: String? = null,
|
||||||
|
|
||||||
@SerializedName("user_portrait")
|
@SerializedName("user_portrait")
|
||||||
val userPortrait: String? = null
|
val userPortrait: String? = null
|
||||||
|
|
||||||
}
|
) : BaseBean()
|
||||||
|
|
||||||
inner class ErrorInfo : BaseBean() {
|
data class ErrorInfo(
|
||||||
@SerializedName("errno")
|
@SerializedName("errno")
|
||||||
val errorCode: String? = null
|
val errorCode: String? = null,
|
||||||
|
|
||||||
@SerializedName("errmsg")
|
@SerializedName("errmsg")
|
||||||
val errorMsg: String? = null
|
val errorMsg: String? = null
|
||||||
|
) : BaseBean()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -359,4 +359,5 @@
|
||||||
<string name="title_emotion_classic">经典</string>
|
<string name="title_emotion_classic">经典</string>
|
||||||
<string name="title_emotion_emoji">符号</string>
|
<string name="title_emotion_emoji">符号</string>
|
||||||
<string name="message_update_store_floor">是否更新收藏楼层</string>
|
<string name="message_update_store_floor">是否更新收藏楼层</string>
|
||||||
|
<string name="tip_thread_store_update">更新到 %1$s 楼</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue