From dd25cd3c21dcf12e97f70542b5fa947c752d4de3 Mon Sep 17 00:00:00 2001
From: HuanChengFly <609486518@qq.com>
Date: Wed, 17 Feb 2021 21:52:51 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E7=94=A8=E6=88=B7=E7=95=8C=E9=9D=A2?=
=?UTF-8?q?=E6=80=A7=E5=88=AB=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tieba/post/activities/UserActivity.kt | 4 ++
.../post/widgets/theme/TintFrameLayout.java | 71 -------------------
.../post/widgets/theme/TintFrameLayout.kt | 59 +++++++++++++++
app/src/main/res/layout/activity_user.xml | 34 +++++++--
app/src/main/res/values/strings.xml | 4 ++
5 files changed, 96 insertions(+), 76 deletions(-)
delete mode 100644 app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.java
create mode 100644 app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.kt
diff --git a/app/src/main/java/com/huanchengfly/tieba/post/activities/UserActivity.kt b/app/src/main/java/com/huanchengfly/tieba/post/activities/UserActivity.kt
index 4392eb54..5bd61b34 100644
--- a/app/src/main/java/com/huanchengfly/tieba/post/activities/UserActivity.kt
+++ b/app/src/main/java/com/huanchengfly/tieba/post/activities/UserActivity.kt
@@ -62,6 +62,9 @@ class UserActivity : BaseActivity() {
@BindView(R.id.user_center_stat_fans)
lateinit var fansStatTv: TextView
+ @BindView(R.id.user_sex)
+ lateinit var sexTv: TextView
+
@BindView(R.id.user_center_action_btn)
lateinit var actionBtn: TintMaterialButton
@@ -169,6 +172,7 @@ class UserActivity : BaseActivity() {
actionBtn.setText(R.string.button_follow)
}
}
+ sexTv.text = if (profileBean!!.user!!.sex == "1") "♂" else if (profileBean!!.user!!.sex == "2") "♀" else "?"
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
diff --git a/app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.java b/app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.java
deleted file mode 100644
index 342ff8ee..00000000
--- a/app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.huanchengfly.tieba.post.widgets.theme;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.huanchengfly.tieba.post.R;
-import com.huanchengfly.tieba.post.interfaces.BackgroundTintable;
-import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable;
-import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
-
-@SuppressLint("CustomViewStyleable")
-public class TintFrameLayout extends FrameLayout implements Tintable, BackgroundTintable {
- private int mBackgroundTintResId;
-
- public TintFrameLayout(@NonNull Context context) {
- this(context, null);
- }
-
- public TintFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public TintFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- if (isInEditMode()) {
- return;
- }
- if (attrs == null) {
- mBackgroundTintResId = 0;
- applyTintColor();
- return;
- }
- TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.TintView, defStyleAttr, 0);
- mBackgroundTintResId = array.getResourceId(R.styleable.TintView_backgroundTint, 0);
- array.recycle();
- applyTintColor();
- }
-
- @Override
- public void tint() {
- applyTintColor();
- }
-
- private void applyTintColor() {
- if (mBackgroundTintResId != 0) {
- if (getBackground() == null) {
- setBackgroundColor(ThemeUtils.getColorById(getContext(), mBackgroundTintResId));
- } else {
- setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.getColorById(getContext(), mBackgroundTintResId)));
- }
- }
- }
-
- @Override
- public void setBackgroundTintResId(int resId) {
- mBackgroundTintResId = resId;
- tint();
- }
-
- @Override
- public int getBackgroundTintResId() {
- return mBackgroundTintResId;
- }
-}
diff --git a/app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.kt b/app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.kt
new file mode 100644
index 00000000..0a17502a
--- /dev/null
+++ b/app/src/main/java/com/huanchengfly/tieba/post/widgets/theme/TintFrameLayout.kt
@@ -0,0 +1,59 @@
+package com.huanchengfly.tieba.post.widgets.theme
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.graphics.Color
+import android.graphics.drawable.ColorDrawable
+import android.graphics.drawable.Drawable
+import android.util.AttributeSet
+import android.widget.FrameLayout
+import com.huanchengfly.tieba.post.R
+import com.huanchengfly.tieba.post.getColorStateListCompat
+import com.huanchengfly.tieba.post.interfaces.BackgroundTintable
+import com.huanchengfly.tieba.post.ui.theme.interfaces.Tintable
+import com.huanchengfly.tieba.post.ui.theme.utils.ColorStateListUtils
+
+@SuppressLint("CustomViewStyleable")
+class TintFrameLayout @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : FrameLayout(context, attrs, defStyleAttr), Tintable, BackgroundTintable {
+ var backgroundTintRes: Int = 0
+
+ override fun tint() {
+ applyTintColor()
+ }
+
+ private fun applyTintColor() {
+ if (backgroundTintRes != 0) {
+ if (background == null) {
+ background = ColorDrawable(Color.WHITE)
+ }
+ backgroundTintList = if (isInEditMode) {
+ context.getColorStateListCompat(backgroundTintRes)
+ } else {
+ ColorStateListUtils.createColorStateList(context, backgroundTintRes)
+ }
+ }
+ }
+
+ override fun setBackground(background: Drawable) {
+ super.setBackground(background)
+ applyTintColor()
+ }
+
+ override fun setBackgroundTintResId(resId: Int) {
+ backgroundTintRes = resId
+ tint()
+ }
+
+ override fun getBackgroundTintResId(): Int {
+ return backgroundTintRes
+ }
+
+ init {
+ if (attrs != null) {
+ val array = getContext().obtainStyledAttributes(attrs, R.styleable.TintView, defStyleAttr, 0)
+ backgroundTintRes = array.getResourceId(R.styleable.TintView_backgroundTint, 0)
+ array.recycle()
+ }
+ applyTintColor()
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_user.xml b/app/src/main/res/layout/activity_user.xml
index 3b5404a5..21e2ddec 100644
--- a/app/src/main/res/layout/activity_user.xml
+++ b/app/src/main/res/layout/activity_user.xml
@@ -85,14 +85,38 @@
tools:ignore="RelativeOverlap" />
-
+ android:orientation="horizontal">
+
+
+
+
+
已收藏
关注
粉丝
+ 标题样式
+ Title
+ 字体大小
+ 永a