feat: 吧务标记
This commit is contained in:
parent
7e4babed2a
commit
7807cddca8
|
|
@ -2,6 +2,8 @@ package com.huanchengfly.tieba.post.adapters
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.text.TextUtils
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
|
@ -18,9 +20,11 @@ import com.huanchengfly.tieba.post.activities.ForumActivity.Companion.launch
|
|||
import com.huanchengfly.tieba.post.activities.ReplyActivity
|
||||
import com.huanchengfly.tieba.post.api.models.ThreadContentBean
|
||||
import com.huanchengfly.tieba.post.components.MyViewHolder
|
||||
import com.huanchengfly.tieba.post.components.spans.RoundBackgroundColorSpan
|
||||
import com.huanchengfly.tieba.post.fragments.MenuDialogFragment
|
||||
import com.huanchengfly.tieba.post.models.ReplyInfoBean
|
||||
import com.huanchengfly.tieba.post.plugins.PluginManager
|
||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils
|
||||
import com.huanchengfly.tieba.post.utils.*
|
||||
import com.huanchengfly.tieba.post.utils.TiebaUtil.reportPost
|
||||
import com.huanchengfly.tieba.post.widgets.MyLinearLayout
|
||||
|
|
@ -154,10 +158,26 @@ class ThreadMainPostAdapter(
|
|||
true
|
||||
}
|
||||
holder.setVisibility(R.id.thread_list_item_user_lz_tip, true)
|
||||
var username: CharSequence = StringUtil.getUsernameString(context, user.name, user.nameShow)
|
||||
if (user.isBawu == "1") {
|
||||
val bawuType = if (user.bawuType == "manager") "吧主" else "小吧主"
|
||||
username = SpannableStringBuilder(username).apply {
|
||||
append(" ")
|
||||
append(
|
||||
bawuType, RoundBackgroundColorSpan(
|
||||
context,
|
||||
Util.alphaColor(ThemeUtils.getColorByAttr(context, R.attr.colorAccent), 30),
|
||||
ThemeUtils.getColorByAttr(context, R.attr.colorAccent),
|
||||
DisplayUtil.dp2px(context, 10f).toFloat()
|
||||
), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
}
|
||||
}
|
||||
holder.setText(
|
||||
R.id.thread_list_item_user_name,
|
||||
StringUtil.getUsernameString(context, user.name, user.nameShow)
|
||||
username
|
||||
)
|
||||
|
||||
val levelId =
|
||||
if (user.levelId == null || TextUtils.isEmpty(user.levelId)) "?" else user.levelId
|
||||
ThemeUtil.setChipThemeByLevel(
|
||||
|
|
|
|||
|
|
@ -560,13 +560,30 @@ class ThreadReplyAdapter(context: Context) :
|
|||
showMenu(item, position)
|
||||
true
|
||||
}
|
||||
viewHolder.setText(
|
||||
R.id.thread_list_item_user_name,
|
||||
if (userInfoBean == null) item.authorId else StringUtil.getUsernameString(
|
||||
|
||||
var username: CharSequence =
|
||||
if (userInfoBean == null) item.authorId ?: "" else StringUtil.getUsernameString(
|
||||
context,
|
||||
userInfoBean.name,
|
||||
userInfoBean.nameShow
|
||||
)
|
||||
if (userInfoBean != null && userInfoBean.isBawu == "1") {
|
||||
val bawuType = if (userInfoBean.bawuType == "manager") "吧主" else "小吧主"
|
||||
username = SpannableStringBuilder(username).apply {
|
||||
append(" ")
|
||||
append(
|
||||
bawuType, RoundBackgroundColorSpan(
|
||||
context,
|
||||
Util.alphaColor(ThemeUtils.getColorByAttr(context, R.attr.colorAccent), 30),
|
||||
ThemeUtils.getColorByAttr(context, R.attr.colorAccent),
|
||||
DisplayUtil.dp2px(context, 10f).toFloat()
|
||||
), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
}
|
||||
}
|
||||
viewHolder.setText(
|
||||
R.id.thread_list_item_user_name,
|
||||
username
|
||||
)
|
||||
if (userInfoBean != null) {
|
||||
val levelId =
|
||||
|
|
|
|||
|
|
@ -4,12 +4,16 @@ import android.content.Context;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.huanchengfly.tieba.post.R;
|
||||
import com.huanchengfly.tieba.post.components.spans.EmotionSpanV2;
|
||||
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -54,12 +58,14 @@ public class StringUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getUsernameString(Context context, String username, String nickname) {
|
||||
public static CharSequence getUsernameString(Context context, String username, String nickname) {
|
||||
boolean showBoth = SharedPreferencesUtil.get(context, SharedPreferencesUtil.SP_SETTINGS).getBoolean("show_both_username_and_nickname", false);
|
||||
if (TextUtils.isEmpty(nickname)) {
|
||||
return TextUtils.isEmpty(username) ? "" : username;
|
||||
} else if (showBoth && !TextUtils.isEmpty(username) && !TextUtils.equals(username, nickname)) {
|
||||
return context.getString(R.string.username_both, nickname, username);
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(nickname);
|
||||
builder.append("(" + username + ")", new ForegroundColorSpan(ThemeUtils.getColorByAttr(context, R.attr.color_text_disabled)), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return builder;
|
||||
}
|
||||
return nickname;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue