From b48ceea5717d56b26fec16a6830fe8225cbe1cc4 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 2 Nov 2022 14:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8E=92=E8=A1=8C=E6=A6=9C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/weight/ViewClicksAntiShake.java | 8 +- .../main/activity/MainListActivity.java | 212 +-------- .../yunbao/main/adapter/MainListAdapter.java | 387 ++-------------- .../views/AbsMainListChildViewHolder.java | 201 ++++++++- .../main/views/MyClipPagerTitleView.java | 25 ++ main/src/main/res/layout/view_main_list.xml | 424 +----------------- .../main/res/layout/view_main_list_page.xml | 417 ++++++++++++++++- .../res/mipmap-xxhdpi/icon_back_white.png | Bin 0 -> 378 bytes 8 files changed, 703 insertions(+), 971 deletions(-) create mode 100644 main/src/main/java/com/yunbao/main/views/MyClipPagerTitleView.java create mode 100644 main/src/main/res/mipmap-xxhdpi/icon_back_white.png diff --git a/common/src/main/java/com/yunbao/common/views/weight/ViewClicksAntiShake.java b/common/src/main/java/com/yunbao/common/views/weight/ViewClicksAntiShake.java index 540a395dd..b2474695e 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/ViewClicksAntiShake.java +++ b/common/src/main/java/com/yunbao/common/views/weight/ViewClicksAntiShake.java @@ -22,9 +22,9 @@ public class ViewClicksAntiShake { /** * 防抖 */ - public static void clicksAntiShake(View view, ViewClicksCallBack callBack) { + public static void clicksAntiShake(int duration, View view, ViewClicksCallBack callBack) { RxView.clicks(view) - .throttleFirst(800, TimeUnit.MILLISECONDS) + .throttleFirst(duration, TimeUnit.MILLISECONDS) .subscribe(new Observer() { @Override public void onSubscribe(Disposable d) { @@ -48,4 +48,8 @@ public class ViewClicksAntiShake { } }); } + + public static void clicksAntiShake(View view, ViewClicksCallBack callBack) { + clicksAntiShake(800, view, callBack); + } } 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 0a3a1d0ce..47ebc14a0 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainListActivity.java @@ -33,6 +33,7 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.CommonIconUtil; +import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.SVGAViewUtils; import com.yunbao.common.utils.ToastUtil; @@ -45,6 +46,7 @@ import com.yunbao.main.http.MainHttpUtil; import com.yunbao.main.views.AbsMainListChildViewHolder; import com.yunbao.main.views.MainListContributeViewHolder; import com.yunbao.main.views.MainListProfitViewHolder; +import com.yunbao.main.views.MyClipPagerTitleView; import net.lucode.hackware.magicindicator.MagicIndicator; import net.lucode.hackware.magicindicator.ViewPagerHelper; @@ -82,11 +84,10 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener private ViewPager mViewPager; private List outRankHide = new ArrayList<>(); public MainListAdapter mAdapter; - private View mBackgroundLayout; private RadioButton mDay, mWeek; private int position; + private ImageView mBack; - private HeadView hv; public static void forward(Context context, int p) { context.startActivity(new Intent(context, MainListActivity.class).putExtra("p", p)); @@ -131,14 +132,15 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener @Override public IPagerTitleView getTitleView(Context context, final int index) { - ClipPagerTitleView clipPagerTitleView = new ClipPagerTitleView(context); + MyClipPagerTitleView clipPagerTitleView = new MyClipPagerTitleView(context); clipPagerTitleView.setText(titles[index]); - clipPagerTitleView.setTextColor(Color.parseColor("#B6B6B6")); - clipPagerTitleView.setClipColor(Color.parseColor("#F8F8F8")); + clipPagerTitleView.setTextColor(Color.parseColor("#FFFFFF")); + clipPagerTitleView.setClipColor(Color.parseColor("#FFFFFF")); clipPagerTitleView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - + mIndicator.onPageSelected(index); + mViewPager.setCurrentItem(index); } }); @@ -148,18 +150,14 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener @Override public IPagerIndicator getIndicator(Context context) { LinePagerIndicator indicator = new LinePagerIndicator(context); - float navigatorHeight = context.getResources().getDimension(R.dimen.common_navigator_height); - float borderWidth = UIUtil.dip2px(context, 1); - float lineHeight = navigatorHeight - 2 * borderWidth; - indicator.setLineHeight(lineHeight); - indicator.setRoundRadius(lineHeight / 2); - indicator.setYOffset(borderWidth); - //选中的背景颜色 - indicator.setColors(Color.parseColor("#FFBE41")); + indicator.setLineWidth(DpUtil.dp2px(14)); + indicator.setMode(LinePagerIndicator.MODE_EXACTLY); + indicator.setColors(Color.parseColor("#FFFFFF")); return indicator; } }); mIndicator.setNavigator(commonNavigator); + //默认选择第几个 mIndicator.onPageSelected(getIntent().getIntExtra("p", 0)); //加载数据 @@ -185,10 +183,10 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener private void initView() { mType = DAY; mViewPager = (ViewPager) findViewById(R.id.viewPager); - mBackgroundLayout = findViewById(R.id.bg_layout); + mBack = findViewById(R.id.btn_back); mDay = findViewById(R.id.btn_day); mWeek = findViewById(R.id.btn_week); - hv = new HeadView(findViewById(R.id.rootView)); + mViewPager.setOffscreenPageLimit(PAGE_COUNT - 1); mViewPager.setAdapter(new ViewPagerAdapter(mViewList)); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @@ -204,11 +202,6 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener mDay.setTextColor(Color.parseColor("#FF82C1")); mWeek.setTextColor(Color.parseColor("#FFFFFF")); loadPageData(position, DAY); - if (position == 0) { - mBackgroundLayout.setBackgroundResource(R.mipmap.bg_glamour_top); - } else { - mBackgroundLayout.setBackgroundResource(R.mipmap.bg_glamour2_top); - } } @Override @@ -226,6 +219,9 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener mWeek.setTextColor(Color.parseColor("#FF82C1")); mDay.setTextColor(Color.parseColor("#FFFFFF")); }); + mBack.setOnClickListener(v -> { + finish(); + }); ViewPagerHelper.bind(mIndicator, mViewPager); mViewPager.setCurrentItem(getIntent().getIntExtra("p", 0)); loadPageData(0, DAY); @@ -243,8 +239,7 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener return; } if (position == 0) { - MainListProfitViewHolder mProfitViewHolder = new MainListProfitViewHolder(mContext, parent); - vh = mProfitViewHolder; + vh = new MainListProfitViewHolder(mContext, parent); } else if (position == 1) { MainListContributeViewHolder mContributeViewHolder = new MainListContributeViewHolder(mContext, parent); mContributeViewHolder.setHide(outRankHide); @@ -260,15 +255,7 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener } } if (vh != null) { - vh.setType(rank); - vh.setOnLoadDataListener(new AbsMainListChildViewHolder.OnLoadData() { - @Override - public void onData(List list) { - hv.setData(list.get(0), 0); - hv.setData(list.get(1), 1); - hv.setData(list.get(2), 2); - } - }); + vh.setType(position, rank); } } @@ -294,166 +281,5 @@ public class MainListActivity extends AbsActivity implements OnItemClickListener } - class HeadView { - View mItem1; - View mItem2; - View mItem3; - GifImageView liveing1; - GifImageView liveing2; - GifImageView liveing3; - ImageView mAvatar1; - ImageView mAvatar2; - ImageView mAvatar3; - TextView mName1; - TextView mName2; - TextView mName3; - TextView mVotes1; - TextView mVotes2; - TextView mVotes3; - ImageView mSex1; - ImageView mSex2; - ImageView mSex3; - ImageView mLevel1; - ImageView mLevel2; - ImageView mLevel3; - MyRadioButton mBtnFollow1; - MyRadioButton mBtnFollow2; - MyRadioButton mBtnFollow3; - SVGAImageView svga1; - SVGAImageView svga2; - SVGAImageView svga3; - public HeadView(View itemView) { - mItem1 = itemView.findViewById(R.id.item_1); - mItem2 = itemView.findViewById(R.id.item_2); - mItem3 = itemView.findViewById(R.id.item_3); - liveing1 = itemView.findViewById(R.id.liveing1); - liveing2 = itemView.findViewById(R.id.liveing2); - liveing3 = itemView.findViewById(R.id.liveing3); - mAvatar1 = (ImageView) itemView.findViewById(R.id.avatar_1); - mAvatar2 = (ImageView) itemView.findViewById(R.id.avatar_2); - mAvatar3 = (ImageView) itemView.findViewById(R.id.avatar_3); - mName1 = (TextView) itemView.findViewById(R.id.name_1); - mName2 = (TextView) itemView.findViewById(R.id.name_2); - mName3 = (TextView) itemView.findViewById(R.id.name_3); - mVotes1 = (TextView) itemView.findViewById(R.id.votes_1); - mVotes2 = (TextView) itemView.findViewById(R.id.votes_2); - mVotes3 = (TextView) itemView.findViewById(R.id.votes_3); - mSex1 = (ImageView) itemView.findViewById(R.id.sex_1); - mSex2 = (ImageView) itemView.findViewById(R.id.sex_2); - mSex3 = (ImageView) itemView.findViewById(R.id.sex_3); - mLevel1 = (ImageView) itemView.findViewById(R.id.level_1); - mLevel2 = (ImageView) itemView.findViewById(R.id.level_2); - mLevel3 = (ImageView) itemView.findViewById(R.id.level_3); - mBtnFollow1 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_1); - mBtnFollow2 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_2); - mBtnFollow3 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_3); - svga1 = (SVGAImageView) itemView.findViewById(R.id.svga1); - svga2 = (SVGAImageView) itemView.findViewById(R.id.svga2); - svga3 = (SVGAImageView) itemView.findViewById(R.id.svga3); - - - } - - public void setData(ListBean bean, int position) { - if (bean == null) { - return; - } - Log.i("排行榜", bean.toString() + " | position = " + position); - setVisibility(View.GONE, -1, svga1, svga2, svga3); - if (bean.getDress_head() != null) { - if (bean.getDress_head().contains("svga")) { - setVisibility(View.VISIBLE, position, svga1, svga2, svga3); - try { - new SVGAParser(mContext).parse(new URL(bean.getDress_head()), new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - getItem(position, svga1, svga2, svga3).setImageDrawable(drawable); - SVGAViewUtils.playEndClear(getItem(position, svga1, svga2, svga3), false); - } - - @Override - public void onError() { - } - }); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } else { - Log.e("eee", bean.getDress_head()); - ImgLoader.display(mContext, bean.getDress_head(), getItem(position, svga1, svga2, svga3)); - } - } - - getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setTag(bean); - setVisibility(View.INVISIBLE, position, liveing1, liveing2, liveing3); - if (bean.getIslive() == 1) { - setVisibility(View.VISIBLE, position, liveing1, liveing2, liveing3); - } - setVisibility(bean.isHide() ? View.GONE : View.VISIBLE, position, mBtnFollow1, mBtnFollow2, mBtnFollow3); - 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")); - } else { - getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.INVISIBLE); - } - getItem(position, mVotes1, mVotes2, mVotes3).setText(bean.getTotalCoinFormat()); - if (bean.isHide()) { - getItem(position, mName1, mName2, mName3).setText(R.string.mystery_man); - ImgLoader.display(mContext, R.mipmap.hide, getItem(position, mAvatar1, mAvatar2, mAvatar3)); - getItem(position, mSex1, mSex2, mSex3).setVisibility(View.GONE); - getItem(position, mVotes1, mVotes2, mVotes3).setVisibility(View.GONE); - } else { - ImgLoader.display(mContext, bean.getAvatarThumb(), getItem(position, mAvatar1, mAvatar2, mAvatar3)); - getItem(position, mName1, mName2, mName3).setText(bean.getUserNiceName()); - getItem(position, mSex1, mSex2, mSex3).setVisibility(View.VISIBLE); - getItem(position, svga1, svga2, svga3).setVisibility(View.VISIBLE); - } - getItem(position, mSex1, mSex2, mSex3).setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); - - getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setOnClickListener(v -> { - ViewClicksAntiShake.clicksAntiShake(v, () -> { - if (!canClick()) { - return; - } - CommonHttpUtil.setAttention(bean.getUid(), new CommonCallback() { - @Override - public void callback(Integer bean) { - if(bean!=null&&bean==1){ - getItem(position,mBtnFollow1,mBtnFollow2,mBtnFollow3).setVisibility(View.INVISIBLE); - } - Log.i("测试", "callback: "+bean); - } - }); - }); - }); - getItem(position, mItem1, mItem2, mItem3).setOnClickListener(v -> { - ViewClicksAntiShake.clicksAntiShake(v, () -> { - if (bean.isHide()) { - ToastUtil.show(R.string.can_not_go); - } else { - RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); - } - }); - }); - } - - private T getItem(int position, T... views) { - return views[position]; - } - - private void setVisibility(int type, int position, View... views) { - if (position == -1) { - for (View view : views) { - view.setVisibility(type); - } - } else { - views[position].setVisibility(type); - } - } - - } } \ No newline at end of file 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 c31e87380..f951bfd33 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java @@ -45,12 +45,8 @@ import pl.droidsonroids.gif.GifImageView; public class MainListAdapter extends RefreshAdapter { public static final int TYPE_PROFIT = 1;//收益榜 public static final int TYPE_CONTRIBUTE = 0;//贡献榜 - private static final int HEAD = 0; - private static final int NORMAL = 1; - private String mCoinName; private String mFollow; private String mFollowing; - private View.OnClickListener mFollowClickListener1; private View.OnClickListener mFollowClickListener2; private View.OnClickListener mItemClickListener; private List mTopList; @@ -61,69 +57,39 @@ public class MainListAdapter extends RefreshAdapter { public MainListAdapter(Context context, int type) { super(context); mType = type; - CommonAppConfig appConfig = CommonAppConfig.getInstance(); - mCoinName = type == TYPE_PROFIT ? appConfig.getVotesName() : appConfig.getCoinName(); mTopList = new ArrayList<>(); mFollow = (WordUtil.getString(R.string.follow)); mFollowing = WordUtil.getString(R.string.following); - mItemClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - ViewClicksAntiShake.clicksAntiShake(v, () -> { - Object tag = v.getTag(); - if (tag != null && mOnItemClickListener != null) { - ListBean model = (ListBean) tag; - if (model.isHide()) { - ToastUtil.show(R.string.can_not_go); - } else { - mOnItemClickListener.onItemClick(model, 0); + mItemClickListener = v -> ViewClicksAntiShake.clicksAntiShake(v, () -> { + Object tag = v.getTag(); + if (tag != null && mOnItemClickListener != null) { + ListBean model = (ListBean) tag; + if (model.isHide()) { + ToastUtil.show(R.string.can_not_go); + } else { + mOnItemClickListener.onItemClick(model, 0); + } + + } + }); + mFollowClickListener2 = v -> ViewClicksAntiShake.clicksAntiShake(v, () -> { + if (!canClick()) { + return; + } + Object tag = v.getTag(); + if (tag != null) { + final int position = (int) tag; + final ListBean bean = mList.get(position); + CommonHttpUtil.setAttention(bean.getUid(), new CommonCallback() { + @Override + public void callback(Integer bean) { + if (bean != null && bean == 1) { + v.setVisibility(View.INVISIBLE); } - } }); - } - }; - mFollowClickListener1 = new View.OnClickListener() { - @Override - public void onClick(View v) { - ViewClicksAntiShake.clicksAntiShake(v, () -> { - if (!canClick()) { - return; - } - Object tag = v.getTag(); - if (tag != null) { - final ListBean bean = (ListBean) tag; - CommonHttpUtil.setAttention(bean.getUid(), null); - } - }); - - } - }; - mFollowClickListener2 = new View.OnClickListener() { - @Override - public void onClick(View v) { - ViewClicksAntiShake.clicksAntiShake(v, () -> { - if (!canClick()) { - return; - } - Object tag = v.getTag(); - if (tag != null) { - final int position = (int) tag; - final ListBean bean = mList.get(position); - CommonHttpUtil.setAttention(bean.getUid(), new CommonCallback() { - @Override - public void callback(Integer bean) { - if (bean != null && bean == 1) { - v.setVisibility(View.INVISIBLE); - } - } - }); - } - }); - - } - }; + }); } @@ -200,307 +166,6 @@ public class MainListAdapter extends RefreshAdapter { Object payload = payloads.size() > 0 ? payloads.get(0) : null; ((Vh) vh).setData(mList.get(position), position, payload); } - - class HeadVh extends RecyclerView.ViewHolder { - - View mItem1; - View mItem2; - View mItem3; - GifImageView liveing1; - GifImageView liveing2; - GifImageView liveing3; - ImageView mAvatar1; - ImageView mAvatar2; - ImageView mAvatar3; - TextView mName1; - TextView mName2; - TextView mName3; - TextView mVotes1; - TextView mVotes2; - TextView mVotes3; - ImageView mSex1; - ImageView mSex2; - ImageView mSex3; - ImageView mLevel1; - ImageView mLevel2; - ImageView mLevel3; - MyRadioButton mBtnFollow1; - MyRadioButton mBtnFollow2; - MyRadioButton mBtnFollow3; - SVGAImageView svga1; - SVGAImageView svga2; - SVGAImageView svga3; - - public HeadVh(View itemView) { - super(itemView); - mItem1 = itemView.findViewById(R.id.item_1); - mItem2 = itemView.findViewById(R.id.item_2); - mItem3 = itemView.findViewById(R.id.item_3); - liveing1 = itemView.findViewById(R.id.liveing1); - liveing2 = itemView.findViewById(R.id.liveing2); - liveing3 = itemView.findViewById(R.id.liveing3); - mItem1.setOnClickListener(mItemClickListener); - mItem2.setOnClickListener(mItemClickListener); - mItem3.setOnClickListener(mItemClickListener); - mAvatar1 = (ImageView) itemView.findViewById(R.id.avatar_1); - mAvatar2 = (ImageView) itemView.findViewById(R.id.avatar_2); - mAvatar3 = (ImageView) itemView.findViewById(R.id.avatar_3); - mName1 = (TextView) itemView.findViewById(R.id.name_1); - mName2 = (TextView) itemView.findViewById(R.id.name_2); - mName3 = (TextView) itemView.findViewById(R.id.name_3); - mVotes1 = (TextView) itemView.findViewById(R.id.votes_1); - mVotes2 = (TextView) itemView.findViewById(R.id.votes_2); - mVotes3 = (TextView) itemView.findViewById(R.id.votes_3); - mSex1 = (ImageView) itemView.findViewById(R.id.sex_1); - mSex2 = (ImageView) itemView.findViewById(R.id.sex_2); - mSex3 = (ImageView) itemView.findViewById(R.id.sex_3); - mLevel1 = (ImageView) itemView.findViewById(R.id.level_1); - mLevel2 = (ImageView) itemView.findViewById(R.id.level_2); - mLevel3 = (ImageView) itemView.findViewById(R.id.level_3); - mBtnFollow1 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_1); - mBtnFollow2 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_2); - mBtnFollow3 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_3); - mBtnFollow1.setOnClickListener(mFollowClickListener1); - mBtnFollow2.setOnClickListener(mFollowClickListener1); - mBtnFollow3.setOnClickListener(mFollowClickListener1); - svga1 = (SVGAImageView) itemView.findViewById(R.id.svga1); - svga2 = (SVGAImageView) itemView.findViewById(R.id.svga2); - svga3 = (SVGAImageView) itemView.findViewById(R.id.svga3); - } - - void setData(Object payload) { - int topSize = mTopList.size(); - if (topSize > 0) { - ListBean bean = mTopList.get(0); - svga1.setVisibility(View.GONE); - - if (bean.getDress_head() != null) { - if (bean.getDress_head().contains("svga")) { - svga1.setVisibility(View.VISIBLE); - - try { - new SVGAParser(mContext).parse(new URL(bean.getDress_head()), new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - svga1.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(svga1, false); - } - - @Override - public void onError() { - } - }); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } else { - Log.e("eee", bean.getDress_head()); - ImgLoader.display(mContext, bean.getDress_head(), svga1); - } - } - mItem1.setVisibility(View.GONE); - if (payload == null) { - mItem1.setTag(bean); - mItem1.setVisibility(View.VISIBLE); - if (bean.isHide()) { - mName1.setText(R.string.mystery_man); - ImgLoader.display(mContext, R.mipmap.hide, mAvatar1); - mSex1.setVisibility(View.GONE); - svga1.setVisibility(View.GONE); - } else { - ImgLoader.display(mContext, bean.getAvatarThumb(), mAvatar1); - mName1.setText(bean.getUserNiceName()); - mSex1.setVisibility(View.VISIBLE); - svga1.setVisibility(View.VISIBLE); - } - - mVotes1.setText(bean.getTotalCoinFormat()); - mSex1.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); - LevelBean levelBean = null; - if (mType == TYPE_PROFIT) { - levelBean = CommonAppConfig.getInstance().getAnchorLevel(bean.getLevelAnchor()); - } else { - levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); - } - if (levelBean != null) { - ImgLoader.display(mContext, levelBean.getThumb(), mLevel1); - } - } - mBtnFollow1.setTag(bean); - liveing1.setVisibility(View.INVISIBLE); - if (bean.getIslive() == 1) { - liveing1.setVisibility(View.VISIBLE); - } else { - liveing1.setVisibility(View.INVISIBLE); - } - mBtnFollow1.setVisibility(bean.isHide() ? View.GONE : View.VISIBLE); - if (bean.getAttention() == 1) { - mBtnFollow1.doChecked(true); - mBtnFollow1.setText(mFollowing); - mBtnFollow1.setBackgroundResource(R.drawable.background_dbdbdb); - mBtnFollow1.setTextColor(Color.parseColor("#FFFFFF")); - } else { - mBtnFollow1.doChecked(false); - mBtnFollow1.setText(mFollow); - mBtnFollow1.setBackgroundResource(R.drawable.background_yellow); - mBtnFollow1.setTextColor(Color.parseColor("#FFFFFF")); - } - } - if (topSize > 1) { - ListBean bean = mTopList.get(1); - svga2.setVisibility(View.GONE); - - if (bean.getDress_head() != null) { - if (bean.getDress_head().contains("svga")) { - svga2.setVisibility(View.VISIBLE); - - try { - new SVGAParser(mContext).parse(new URL(bean.getDress_head()), new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - svga2.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(svga2, false); - } - - @Override - public void onError() { - } - }); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } else { - Log.e("eee", bean.getDress_head()); - ImgLoader.display(mContext, bean.getDress_head(), svga2); - } - } - mItem2.setVisibility(View.GONE); - if (payload == null) { - mItem2.setVisibility(View.VISIBLE); - mItem2.setTag(bean); - if (bean.isHide()) { - mName2.setText(R.string.mystery_man); - ImgLoader.display(mContext, R.mipmap.hide, mAvatar2); - mSex2.setVisibility(View.GONE); - } else { - ImgLoader.display(mContext, bean.getAvatarThumb(), mAvatar2); - mName2.setText(bean.getUserNiceName()); - mSex2.setVisibility(View.VISIBLE); - } - mVotes2.setText(bean.getTotalCoinFormat() + " "); - mSex2.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); - LevelBean levelBean = null; - if (mType == TYPE_PROFIT) { - levelBean = CommonAppConfig.getInstance().getAnchorLevel(bean.getLevelAnchor()); - } else { - levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); - } - if (levelBean != null) { - ImgLoader.display(mContext, levelBean.getThumb(), mLevel2); - } - } - mBtnFollow2.setTag(bean); - liveing2.setVisibility(View.INVISIBLE); - if (bean.getIslive() == 1) { - liveing2.setVisibility(View.VISIBLE); - } else { - liveing2.setVisibility(View.INVISIBLE); - } - mBtnFollow2.setVisibility(bean.isHide() ? View.GONE : View.VISIBLE); - svga2.setVisibility(bean.isHide() ? View.GONE : View.VISIBLE); - if (bean.getAttention() == 1) { - mBtnFollow2.doChecked(true); - mBtnFollow2.setText(mFollowing); - mBtnFollow2.setBackgroundResource(R.drawable.background_dbdbdb); - mBtnFollow2.setTextColor(Color.parseColor("#FFFFFF")); - } else { - mBtnFollow2.doChecked(false); - mBtnFollow2.setText(mFollow); - mBtnFollow2.setBackgroundResource(R.drawable.background_yellow); - mBtnFollow2.setTextColor(Color.parseColor("#FFFFFF")); - } - - } - if (topSize > 2) { - ListBean bean = mTopList.get(2); - - if (bean.getDress_head() != null) { - svga3.setVisibility(View.GONE); - if (bean.getDress_head().contains("svga")) { - svga3.setVisibility(View.VISIBLE); - - try { - new SVGAParser(mContext).parse(new URL(bean.getDress_head()), new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - svga3.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(svga3, false); - } - - @Override - public void onError() { - } - }); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } else { - Log.e("eee", bean.getDress_head()); - ImgLoader.display(mContext, bean.getDress_head(), svga3); - } - } - mItem3.setVisibility(View.GONE); - if (payload == null) { - mItem3.setVisibility(View.VISIBLE); - mItem3.setTag(bean); - if (bean.isHide()) { - mName3.setText(R.string.mystery_man); - ImgLoader.display(mContext, R.mipmap.hide, mAvatar3); - mSex3.setVisibility(View.GONE); - } else { - ImgLoader.display(mContext, bean.getAvatarThumb(), mAvatar3); - mName3.setText(bean.getUserNiceName()); - mSex3.setVisibility(View.VISIBLE); - } - mVotes3.setText(bean.getTotalCoinFormat() + " "); - mSex3.setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); - LevelBean levelBean = null; - if (mType == TYPE_PROFIT) { - levelBean = CommonAppConfig.getInstance().getAnchorLevel(bean.getLevelAnchor()); - } else { - levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel()); - } - if (levelBean != null) { - ImgLoader.display(mContext, levelBean.getThumb(), mLevel3); - } - } - mBtnFollow3.setTag(bean); - liveing3.setVisibility(View.INVISIBLE); - if (bean.getIslive() == 1) { - liveing3.setVisibility(View.VISIBLE); - } else { - liveing3.setVisibility(View.INVISIBLE); - } - mBtnFollow3.setVisibility(bean.isHide() ? View.GONE : View.VISIBLE); - svga3.setVisibility(bean.isHide() ? View.GONE : View.VISIBLE); - if (bean.getAttention() == 1) { - mBtnFollow3.doChecked(true); - mBtnFollow3.setText(mFollowing); - mBtnFollow3.setBackgroundResource(R.drawable.background_dbdbdb); - mBtnFollow3.setTextColor(Color.parseColor("#FFFFFF")); - } else { - mBtnFollow3.doChecked(false); - mBtnFollow3.setText(mFollow); - mBtnFollow3.setBackgroundResource(R.drawable.background_yellow); - mBtnFollow3.setTextColor(Color.parseColor("#FFFFFF")); - } - } - } - } - class Vh extends RecyclerView.ViewHolder { TextView mOrder; 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 f65a6d10f..260cae0e7 100644 --- a/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java @@ -4,22 +4,42 @@ import android.content.Context; import androidx.recyclerview.widget.LinearLayoutManager; +import android.graphics.Color; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import com.opensource.svgaplayer.SVGADrawable; +import com.opensource.svgaplayer.SVGAImageView; +import com.opensource.svgaplayer.SVGAParser; +import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.custom.MyRadioButton; +import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SVGAViewUtils; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsMainViewHolder; +import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; import com.yunbao.main.adapter.MainListAdapter; import com.yunbao.main.bean.ListBean; +import java.net.MalformedURLException; +import java.net.URL; import java.util.List; +import pl.droidsonroids.gif.GifImageView; + /** * Created by cxf on 2019/2/23. */ @@ -35,6 +55,8 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple public MainListAdapter mAdapter; protected OnLoadData loadData; protected List list; + private HeadView hv; + private View mBackgroundLayout; public AbsMainListChildViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -49,8 +71,16 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple @Override public void init() { mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView); + mBackgroundLayout = findViewById(R.id.bg_layout); + hv = new HeadView(findViewById(R.id.rootView)); mRefreshView.setEmptyLayoutId(R.layout.view_no_data_list); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + loadData = list -> { + Log.i("测试", "onData: " + list.size()); + hv.setData(list.get(0), 0); + hv.setData(list.get(1), 1); + hv.setData(list.get(2), 2); + }; } @Override @@ -97,23 +127,180 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple } } - public void setOnLoadDataListener(OnLoadData loadData) { - this.loadData = loadData; - if (list != null && !list.isEmpty()) { - loadData.onData(list); - } - } - public void setType(String type) { + public void setType(int position, String type) { if (type != null) { this.mType = type; } if (mRefreshView != null) { mRefreshView.initData(); } + if (position == 0) { + mBackgroundLayout.setBackgroundResource(R.mipmap.bg_glamour_top); + } else { + mBackgroundLayout.setBackgroundResource(R.mipmap.bg_glamour2_top); + } } public interface OnLoadData { void onData(List list); } + + class HeadView { + View mItem1; + View mItem2; + View mItem3; + GifImageView liveing1; + GifImageView liveing2; + GifImageView liveing3; + ImageView mAvatar1; + ImageView mAvatar2; + ImageView mAvatar3; + TextView mName1; + TextView mName2; + TextView mName3; + TextView mVotes1; + TextView mVotes2; + TextView mVotes3; + ImageView mSex1; + ImageView mSex2; + ImageView mSex3; + ImageView mLevel1; + ImageView mLevel2; + ImageView mLevel3; + MyRadioButton mBtnFollow1; + MyRadioButton mBtnFollow2; + MyRadioButton mBtnFollow3; + SVGAImageView svga1; + SVGAImageView svga2; + SVGAImageView svga3; + + public HeadView(View itemView) { + mItem1 = itemView.findViewById(R.id.item_1); + mItem2 = itemView.findViewById(R.id.item_2); + mItem3 = itemView.findViewById(R.id.item_3); + liveing1 = itemView.findViewById(R.id.liveing1); + liveing2 = itemView.findViewById(R.id.liveing2); + liveing3 = itemView.findViewById(R.id.liveing3); + mAvatar1 = (ImageView) itemView.findViewById(R.id.avatar_1); + mAvatar2 = (ImageView) itemView.findViewById(R.id.avatar_2); + mAvatar3 = (ImageView) itemView.findViewById(R.id.avatar_3); + mName1 = (TextView) itemView.findViewById(R.id.name_1); + mName2 = (TextView) itemView.findViewById(R.id.name_2); + mName3 = (TextView) itemView.findViewById(R.id.name_3); + mVotes1 = (TextView) itemView.findViewById(R.id.votes_1); + mVotes2 = (TextView) itemView.findViewById(R.id.votes_2); + mVotes3 = (TextView) itemView.findViewById(R.id.votes_3); + mSex1 = (ImageView) itemView.findViewById(R.id.sex_1); + mSex2 = (ImageView) itemView.findViewById(R.id.sex_2); + mSex3 = (ImageView) itemView.findViewById(R.id.sex_3); + mLevel1 = (ImageView) itemView.findViewById(R.id.level_1); + mLevel2 = (ImageView) itemView.findViewById(R.id.level_2); + mLevel3 = (ImageView) itemView.findViewById(R.id.level_3); + mBtnFollow1 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_1); + mBtnFollow2 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_2); + mBtnFollow3 = (MyRadioButton) itemView.findViewById(R.id.btn_follow_3); + svga1 = (SVGAImageView) itemView.findViewById(R.id.svga1); + svga2 = (SVGAImageView) itemView.findViewById(R.id.svga2); + svga3 = (SVGAImageView) itemView.findViewById(R.id.svga3); + + + } + + public void setData(ListBean bean, int position) { + if (bean == null) { + return; + } + Log.i("排行榜", bean.toString() + " | position = " + position); + setVisibility(View.GONE, -1, svga1, svga2, svga3); + if (bean.getDress_head() != null) { + if (bean.getDress_head().contains("svga")) { + setVisibility(View.VISIBLE, position, svga1, svga2, svga3); + try { + new SVGAParser(mContext).parse(new URL(bean.getDress_head()), new SVGAParser.ParseCompletion() { + @Override + public void onComplete(SVGAVideoEntity videoItem) { + SVGADrawable drawable = new SVGADrawable(videoItem); + getItem(position, svga1, svga2, svga3).setImageDrawable(drawable); + SVGAViewUtils.playEndClear(getItem(position, svga1, svga2, svga3), false); + } + + @Override + public void onError() { + } + }); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } else { + Log.e("eee", bean.getDress_head()); + ImgLoader.display(mContext, bean.getDress_head(), getItem(position, svga1, svga2, svga3)); + } + } + + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setTag(bean); + setVisibility(View.INVISIBLE, position, liveing1, liveing2, liveing3); + if (bean.getIslive() == 1) { + setVisibility(View.VISIBLE, position, liveing1, liveing2, liveing3); + } + setVisibility(bean.isHide() ? View.GONE : View.VISIBLE, position, mBtnFollow1, mBtnFollow2, mBtnFollow3); + 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")); + } else { + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.INVISIBLE); + } + getItem(position, mVotes1, mVotes2, mVotes3).setText(bean.getTotalCoinFormat()); + if (bean.isHide()) { + getItem(position, mName1, mName2, mName3).setText(R.string.mystery_man); + ImgLoader.display(mContext, R.mipmap.hide, getItem(position, mAvatar1, mAvatar2, mAvatar3)); + getItem(position, mSex1, mSex2, mSex3).setVisibility(View.GONE); + getItem(position, mVotes1, mVotes2, mVotes3).setVisibility(View.GONE); + } else { + ImgLoader.display(mContext, bean.getAvatarThumb(), getItem(position, mAvatar1, mAvatar2, mAvatar3)); + getItem(position, mName1, mName2, mName3).setText(bean.getUserNiceName()); + getItem(position, mSex1, mSex2, mSex3).setVisibility(View.VISIBLE); + getItem(position, svga1, svga2, svga3).setVisibility(View.VISIBLE); + } + getItem(position, mSex1, mSex2, mSex3).setImageResource(CommonIconUtil.getSexIcon(bean.getSex())); + + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setOnClickListener(v -> { + CommonHttpUtil.setAttention(bean.getUid(), new CommonCallback() { + @Override + public void callback(Integer bean) { + if (bean != null && bean == 1) { + getItem(position, mBtnFollow1, mBtnFollow2, mBtnFollow3).setVisibility(View.INVISIBLE); + } + Log.i("测试", "callback: " + bean); + } + }); + }); + getItem(position, mItem1, mItem2, mItem3).setOnClickListener(v -> { + ViewClicksAntiShake.clicksAntiShake(v, () -> { + if (bean.isHide()) { + ToastUtil.show(R.string.can_not_go); + } else { + RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); + } + }); + }); + } + + private T getItem(int position, T... views) { + return views[position]; + } + + private void setVisibility(int type, int position, View... views) { + if (position == -1) { + for (View view : views) { + view.setVisibility(type); + } + } else { + views[position].setVisibility(type); + } + } + + } } diff --git a/main/src/main/java/com/yunbao/main/views/MyClipPagerTitleView.java b/main/src/main/java/com/yunbao/main/views/MyClipPagerTitleView.java new file mode 100644 index 000000000..db97406ab --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MyClipPagerTitleView.java @@ -0,0 +1,25 @@ +package com.yunbao.main.views; + +import android.content.Context; + +import com.yunbao.common.utils.DpUtil; + +import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ClipPagerTitleView; + +public class MyClipPagerTitleView extends ClipPagerTitleView { + public MyClipPagerTitleView(Context context) { + super(context); + } + + @Override + public void onSelected(int index, int totalCount) { + super.onSelected(index, totalCount); + setTextSize(DpUtil.dp2px(20)); + } + + @Override + public void onDeselected(int index, int totalCount) { + super.onDeselected(index, totalCount); + setTextSize(DpUtil.dp2px(16)); + } +} diff --git a/main/src/main/res/layout/view_main_list.xml b/main/src/main/res/layout/view_main_list.xml index 6e97619d8..50267d721 100644 --- a/main/src/main/res/layout/view_main_list.xml +++ b/main/src/main/res/layout/view_main_list.xml @@ -6,16 +6,37 @@ android:layout_height="match_parent" android:orientation="vertical"> + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/main/src/main/res/layout/view_main_list_page.xml b/main/src/main/res/layout/view_main_list_page.xml index b856bca95..ce4b0116a 100644 --- a/main/src/main/res/layout/view_main_list_page.xml +++ b/main/src/main/res/layout/view_main_list_page.xml @@ -1,17 +1,418 @@ - + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_height="0dp" + android:layout_marginTop="-15dp" + android:background="@drawable/background_white_up" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/bg_layout" /> - + diff --git a/main/src/main/res/mipmap-xxhdpi/icon_back_white.png b/main/src/main/res/mipmap-xxhdpi/icon_back_white.png new file mode 100644 index 0000000000000000000000000000000000000000..46b4034d8befd7833fe90598104aca7edb7a3b86 GIT binary patch literal 378 zcmeAS@N?(olHy`uVBq!ia0vp^W+2SL3?z5Yp7kC`F%}28J29*~C-V}>Ne=J{aRt)< zX$)q$@-6^cqfip$7tFxKEGQx_DW$04>>U!3k=fibVfw5&JC2>XaOK|p51;=%WvjRg zR6Ent#WBR=_}go~LQMud4i80Iul--t5q4$Y@A;Qnzc8Hinv?cl?Y@@q#G`%IHlI_M zo>MxoVl5lPi;zI!jVVi|be)2-1^o^x`5aXF5*pFUEo?QrAYbUzT}7PuQ!#>+P!)mcks>YFLrIxfA#I>C0@7mHRoRaaejXCg~;sU#czcUME`wQYJMX6 hu=`HyZJ&%kGd}M%IOcTE@Db3F44$rjF6*2UngC<@*i!%i literal 0 HcmV?d00001