From 8b3b0ce2ea67153159b72f7d7fc9e29480f54a42 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 2 Nov 2022 17:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8E=92=E8=A1=8C=E6=A6=9C?= =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/activity/MainListActivity.java | 19 +++++++++++++------ .../yunbao/main/adapter/MainListAdapter.java | 14 ++++++++++++-- .../views/AbsMainListChildViewHolder.java | 11 +++++++++-- .../views/MainListContributeViewHolder.java | 14 ++++++++------ .../main/views/MainListProfitViewHolder.java | 7 ++++--- .../main/res/drawable/background_7bbaff.xml | 10 ++++++++++ .../main/res/drawable/background_ff82c1.xml | 9 +++++++++ .../main/res/layout/activity_main_list.xml | 18 ++++++++++++------ 8 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 main/src/main/res/drawable/background_7bbaff.xml create mode 100644 main/src/main/res/drawable/background_ff82c1.xml diff --git a/main/src/main/java/com/yunbao/main/activity/MainListActivity.java b/main/src/main/java/com/yunbao/main/activity/MainListActivity.java index 768978521..afd5638cc 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainListActivity.java @@ -202,8 +202,7 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener public void onPageSelected(int position) { MainListActivity.this.position = position; mDay.setChecked(true); - mDay.setTextColor(Color.parseColor("#FF82C1")); - mWeek.setTextColor(Color.parseColor("#FFFFFF")); + setRadioColor(position, mDay, mWeek); loadPageData(position, DAY); } @@ -214,13 +213,11 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener }); mDay.setOnClickListener(v -> { loadPageData(position, DAY); - mDay.setTextColor(Color.parseColor("#FF82C1")); - mWeek.setTextColor(Color.parseColor("#FFFFFF")); + setRadioColor(mViewPager.getCurrentItem(),mDay,mWeek); }); mWeek.setOnClickListener(v -> { loadPageData(position, WEEK); - mWeek.setTextColor(Color.parseColor("#FF82C1")); - mDay.setTextColor(Color.parseColor("#FFFFFF")); + setRadioColor(mViewPager.getCurrentItem(),mWeek,mDay); }); mBack.setOnClickListener(v -> { finish(); @@ -230,6 +227,16 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener loadPageData(0, DAY); } + private void setRadioColor(int position, RadioButton select, RadioButton unSelect) { + if (position == 0) { + select.setTextColor(Color.parseColor("#FF82C1")); + unSelect.setTextColor(Color.parseColor("#FFFFFF")); + } else { + select.setTextColor(Color.parseColor("#7BBAFF")); + unSelect.setTextColor(Color.parseColor("#FFFFFF")); + } + } + private void loadPageData(int position, String rank) { if (mViewHolders == null) { return; diff --git a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java index f951bfd33..27c9fec66 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java @@ -52,6 +52,7 @@ public class MainListAdapter extends RefreshAdapter { private List mTopList; private int mType; private List outRankHide = new ArrayList<>(); + protected boolean isRankOne;//是否为魅力榜 (第一个tab) public MainListAdapter(Context context, int type) { @@ -93,6 +94,10 @@ public class MainListAdapter extends RefreshAdapter { } + public void setRankOne(boolean rankOne) { + isRankOne = rankOne; + } + @Override public int getItemCount() { if (mList != null && mTopList.size() > 0) { @@ -263,8 +268,13 @@ public class MainListAdapter extends RefreshAdapter { } else { mBtnFollow.doChecked(false); mBtnFollow.setText(mFollow); - mBtnFollow.setBackgroundResource(R.drawable.background_ff7bbaff); - mBtnFollow.setTextColor(Color.parseColor("#7BBAFF")); + if(isRankOne){ + mBtnFollow.setBackgroundResource(R.drawable.background_ff82c1); + mBtnFollow.setTextColor(Color.parseColor("#FF82C1")); + }else { + mBtnFollow.setBackgroundResource(R.drawable.background_ff7bbaff); + mBtnFollow.setTextColor(Color.parseColor("#7BBAFF")); + } } } } diff --git a/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java b/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java index 0a68cdfd9..d5052d116 100644 --- a/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java @@ -54,6 +54,7 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple public static final String MONTH = "month"; public static final String TOTAL = "total"; protected String mType; + protected boolean isRankOne;//是否为魅力榜 (第一个tab) protected CommonRefreshView mRefreshView; public MainListAdapter mAdapter; protected OnLoadData loadData; @@ -278,8 +279,14 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple if (bean.getAttention() != 1) { getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).doChecked(true); getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setText("+" + WordUtil.getString(R.string.follow)); - getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setBackgroundResource(R.drawable.background_ffff79c2); - getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setTextColor(Color.parseColor("#FFFFFF")); + if(isRankOne) { + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setBackgroundResource(R.drawable.background_ffff79c2); + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setTextColor(Color.parseColor("#FFFFFF")); + }else{ + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setBackgroundResource(R.drawable.background_7bbaff); + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setTextColor(Color.parseColor("#FFFFFF")); + } + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.VISIBLE); } else { getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.INVISIBLE); } diff --git a/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java index 0f6354734..5b9564b23 100644 --- a/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java @@ -27,6 +27,7 @@ public class MainListContributeViewHolder extends AbsMainListChildViewHolder { public MainListContributeViewHolder(Context context, ViewGroup parentView) { super(context, parentView); + isRankOne = false; } @Override @@ -37,6 +38,7 @@ public class MainListContributeViewHolder extends AbsMainListChildViewHolder { public RefreshAdapter getAdapter() { if (mAdapter == null) { mAdapter = new MainListAdapter(mContext, MainListAdapter.TYPE_CONTRIBUTE); + mAdapter.setRankOne(isRankOne); mAdapter.setOnItemClickListener(MainListContributeViewHolder.this); } mAdapter.setHide(outRankHide); @@ -52,12 +54,12 @@ public class MainListContributeViewHolder extends AbsMainListChildViewHolder { @Override public List processData(String[] info) { - list=JSON.parseArray(Arrays.toString(info), ListBean.class); - if(mRefreshView.getPageCount()==1){ - if (loadData != null) { - loadData.onData(list); - } - } + list = JSON.parseArray(Arrays.toString(info), ListBean.class); + if (mRefreshView.getPageCount() == 1) { + if (loadData != null) { + loadData.onData(list); + } + } return list; } diff --git a/main/src/main/java/com/yunbao/main/views/MainListProfitViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainListProfitViewHolder.java index 342c06e12..3e0419f45 100644 --- a/main/src/main/java/com/yunbao/main/views/MainListProfitViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainListProfitViewHolder.java @@ -25,6 +25,7 @@ public class MainListProfitViewHolder extends AbsMainListChildViewHolder { public MainListProfitViewHolder(Context context, ViewGroup parentView) { super(context, parentView); + isRankOne = true; } @Override @@ -35,6 +36,7 @@ public class MainListProfitViewHolder extends AbsMainListChildViewHolder { public RefreshAdapter getAdapter() { if (mAdapter == null) { mAdapter = new MainListAdapter(mContext, MainListAdapter.TYPE_PROFIT); + mAdapter.setRankOne(isRankOne); mAdapter.setOnItemClickListener(MainListProfitViewHolder.this); } return mAdapter; @@ -49,8 +51,8 @@ public class MainListProfitViewHolder extends AbsMainListChildViewHolder { @Override public List processData(String[] info) { - list = JSON.parseArray(Arrays.toString(info), ListBean.class); - if(mRefreshView.getPageCount()==1){ + list = JSON.parseArray(Arrays.toString(info), ListBean.class); + if (mRefreshView.getPageCount() == 1) { if (loadData != null) { loadData.onData(list); } @@ -87,5 +89,4 @@ public class MainListProfitViewHolder extends AbsMainListChildViewHolder { } - } diff --git a/main/src/main/res/drawable/background_7bbaff.xml b/main/src/main/res/drawable/background_7bbaff.xml new file mode 100644 index 000000000..ea68fe2d1 --- /dev/null +++ b/main/src/main/res/drawable/background_7bbaff.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/drawable/background_ff82c1.xml b/main/src/main/res/drawable/background_ff82c1.xml new file mode 100644 index 000000000..32f5e50d9 --- /dev/null +++ b/main/src/main/res/drawable/background_ff82c1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/activity_main_list.xml b/main/src/main/res/layout/activity_main_list.xml index fed041be3..2aa278255 100644 --- a/main/src/main/res/layout/activity_main_list.xml +++ b/main/src/main/res/layout/activity_main_list.xml @@ -86,6 +86,7 @@ android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginTop="50dp" + android:visibility="invisible" android:src="@mipmap/icon_user_home_living" /> @@ -107,7 +108,7 @@ android:lines="1" android:maxEms="4" android:singleLine="true" - android:text="名字" + android:text="" android:textColor="#FFFFFF" android:textSize="15sp" /> @@ -135,7 +136,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" - android:text="11111" + android:text="" android:textColor="#FFFFFF" android:textSize="12sp" /> @@ -151,6 +152,7 @@ android:button="@null" android:gravity="center" android:text="@string/shield_gift_effect" + android:visibility="invisible" android:textColor="@color/white" android:textSize="11sp" /> @@ -215,6 +217,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" + android:visibility="invisible" android:layout_marginTop="50dp" android:src="@mipmap/icon_user_home_living" /> @@ -237,7 +240,7 @@ android:lines="1" android:maxEms="4" android:singleLine="true" - android:text="名字" + android:text="" android:textColor="#FFFFFF" android:textSize="15sp" /> @@ -265,7 +268,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" - android:text="11111" + android:text="" android:textColor="#FFFFFF" android:textSize="12sp" /> @@ -280,6 +283,7 @@ android:background="@drawable/background_dbdbdb" android:button="@null" android:gravity="center" + android:visibility="invisible" android:text="已关注" android:textColor="@color/white" android:textSize="11sp" /> @@ -345,6 +349,7 @@ android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginTop="50dp" + android:visibility="invisible" android:src="@mipmap/icon_user_home_living" /> @@ -366,7 +371,7 @@ android:lines="1" android:maxEms="4" android:singleLine="true" - android:text="名字" + android:text="" android:textColor="#FFFFFF" android:textSize="15sp" /> @@ -394,7 +399,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" - android:text="11111" + android:text="" android:textColor="#FFFFFF" android:textSize="12sp" /> @@ -410,6 +415,7 @@ android:button="@null" android:gravity="center" android:text="已关注" + android:visibility="invisible" android:textColor="@color/white" android:textSize="11sp" />