Skip to content

Commit b6cf620

Browse files
committed
修复了 vip 为 5 时会崩溃的问题
1 parent 0b91256 commit b6cf620

File tree

4 files changed

+10
-49
lines changed

4 files changed

+10
-49
lines changed

app/src/main/java/net/coding/program/common/widget/MemberIcon.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ public MemberIcon(Context context, AttributeSet attrs, int defStyle) {
3636
super(context, attrs, defStyle);
3737
}
3838

39-
@Override
40-
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
41-
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
42-
43-
44-
}
45-
4639
@Override
4740
public void setTag(Object tag) {
4841
super.setTag(tag);
@@ -52,7 +45,7 @@ public void setTag(Object tag) {
5245
public void setFlagIcon(Object tag) {
5346
if (tag instanceof UserObject) {
5447
VIP vip = ((UserObject) tag).vip;
55-
if (vip.getIcon() == 0) {
48+
if (vip == null || vip.getIcon() == 0) {
5649
flagIcon = null;
5750
} else {
5851
flagIcon = getResources().getDrawable(vip.getIcon());

app/src/main/java/net/coding/program/setting/MainSettingFragment.kt

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,13 @@ open class MainSettingFragment : BaseFragment() {
6767
return
6868
}
6969

70-
vip?.text = me.vip.alias
71-
if (me.vip.isPayed) {
72-
val time = Global.dayFromTime(me.vipExpiredAt)
73-
val color = if (me.vipNearExpired()) CodingColor.fontRed else CodingColor.font3
74-
expire.text = Global.createColorHtml("到期时间:", time, "", color)
75-
76-
} else {
77-
expire.text = ""
78-
}
79-
80-
vipIcon?.setImageResource(me.vip.icon)
81-
8270
topTip?.visibility = View.GONE
8371

84-
if (me.vip.isPayed && me.vipNearExpired()) {
85-
topTip?.visibility = View.VISIBLE
86-
topTipText?.text = "会员过期将自动降级"
87-
topTipText.setOnClickListener { showSingleDialog(R.string.tip_vip_expired) }
88-
}
89-
90-
if (!GlobalData.isEnterprise()) {
91-
itemAccount.text2.visibility = View.VISIBLE
92-
itemAccount.text2.text = "${me.points_left} 码币"
93-
itemAccount.text2.setTextColor(CodingColor.fontBlue)
94-
itemAccount.text2.textSize = 13f
95-
}
72+
globalKey.text = me.global_key
73+
itemAccount.text2.visibility = View.VISIBLE
74+
itemAccount.text2.text = "${me.points_left} 码币"
75+
itemAccount.text2.setTextColor(CodingColor.fontBlue)
76+
itemAccount.text2.textSize = 13f
9677
}
9778

9879
private fun bindData(serviceInfo: ServiceInfo) {

app/src/main/res/layout/fragment_main_setting.xml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,12 @@
9494
android:layout_marginLeft="80dp"
9595
android:orientation="horizontal">
9696

97-
<com.flyco.roundview.RoundTextView
98-
android:id="@+id/vip"
99-
android:layout_width="wrap_content"
100-
android:layout_height="wrap_content"
101-
android:paddingBottom="2dp"
102-
android:paddingLeft="6dp"
103-
android:paddingRight="6dp"
104-
android:paddingTop="2dp"
105-
android:text="普通会员"
106-
android:textColor="@color/font_3"
107-
android:textSize="12sp"
108-
app:rv_backgroundColor="#FFD8DDE4"
109-
app:rv_cornerRadius="2dp" />
110-
11197
<TextView
112-
android:id="@+id/expire"
98+
android:id="@+id/globalKey"
11399
android:layout_width="match_parent"
114100
android:layout_height="wrap_content"
115101
android:layout_alignBottom="@id/userIcon"
116102
android:layout_marginBottom="3dp"
117-
android:layout_marginLeft="8dp"
118103
android:layout_toRightOf="@id/userIcon"
119104
android:textColor="@color/font_3"
120105
android:textSize="13sp"

common-coding/src/main/java/net/coding/program/network/constant/VIP.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ enum class VIP constructor(var id: Int, var alias: String, var icon: Int) : Seri
1818
@SerializedName("3")
1919
gold(3, "黄金会员", R.drawable.member_gold),
2020
@SerializedName("4")
21-
diamond(4, "钻石会员", R.drawable.member_diamond);
21+
diamond(4, "钻石会员", R.drawable.member_diamond),
22+
@SerializedName("5")
23+
tencent(5, "", 0);
2224

2325
val isPayed: Boolean
2426
get() = id >= 3

0 commit comments

Comments
 (0)