diff --git a/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java b/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java index f385d9648..5e28ba8f6 100644 --- a/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/RefreshAdapter.java @@ -95,7 +95,7 @@ public abstract class RefreshAdapter extends RecyclerView.Adapter { return position; } - protected boolean canClick() { + protected static boolean canClick() { return ClickUtil.canClick(); } 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/common/src/main/res/drawable/bg_list_btn.xml b/common/src/main/res/drawable/bg_list_btn.xml index ae28c3e59..d8ce74edd 100644 --- a/common/src/main/res/drawable/bg_list_btn.xml +++ b/common/src/main/res/drawable/bg_list_btn.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/main/build.gradle b/main/build.gradle index 6aefbe7a8..4905a1d0f 100644 --- a/main/build.gradle +++ b/main/build.gradle @@ -84,4 +84,5 @@ dependencies { implementation 'com.google.android.gms:play-services-auth:15.0.0' //引导层 implementation 'com.binioter:guideview:1.0.0' + implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' } 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 32ba1d32a..768978521 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainListActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainListActivity.java @@ -7,20 +7,47 @@ import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.TextView; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.viewpager.widget.ViewPager; +import com.alibaba.fastjson.JSON; +import com.opensource.svgaplayer.SVGADrawable; +import com.opensource.svgaplayer.SVGAImageView; +import com.opensource.svgaplayer.SVGAParser; +import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.ViewPagerAdapter; import com.yunbao.common.bean.NobleRankHideUserListModel; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.custom.MyRadioButton; import com.yunbao.common.event.FollowEvent; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.base.HttpCallback; 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; import com.yunbao.common.utils.WordUtil; +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 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; @@ -36,18 +63,33 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -public class MainListActivity extends AbsActivity { +import pl.droidsonroids.gif.GifImageView; + +public class MainListActivity extends AbsActivity implements OnItemClickListener { private static final int PAGE_COUNT = 2; + public static final String DAY = "day"; + public static final String WEEK = "week"; + public static final String MONTH = "month"; + public static final String TOTAL = "total"; + protected String mType; + private List mViewList; private AbsMainListChildViewHolder[] mViewHolders; - private MainListProfitViewHolder mProfitViewHolder;//收益榜 - private MainListContributeViewHolder mContributeViewHolder;//贡献榜 private MagicIndicator mIndicator; private ViewPager mViewPager; private List outRankHide = new ArrayList<>(); + public MainListAdapter mAdapter; + private RadioButton mDay, mWeek; + private int position; + private ImageView mBack; + private RadioGroup radioGroup; + public static void forward(Context context, int p) { context.startActivity(new Intent(context, MainListActivity.class).putExtra("p", p)); @@ -57,12 +99,7 @@ public class MainListActivity extends AbsActivity { @Override protected void onResume() { super.onResume(); - if (mProfitViewHolder != null && mProfitViewHolder.mAdapter != null) { - mProfitViewHolder.mAdapter.notifyDataSetChanged(); - } - if (mContributeViewHolder != null && mContributeViewHolder.mAdapter != null) { - mContributeViewHolder.mAdapter.notifyDataSetChanged(); - } + } @Override @@ -72,6 +109,7 @@ public class MainListActivity extends AbsActivity { @Override protected void main() { + mViewList = new ArrayList<>(); for (int i = 0; i < PAGE_COUNT; i++) { FrameLayout frameLayout = new FrameLayout(mContext); @@ -79,25 +117,7 @@ public class MainListActivity extends AbsActivity { mViewList.add(frameLayout); } mViewHolders = new AbsMainListChildViewHolder[PAGE_COUNT]; - mViewPager = (ViewPager) findViewById(R.id.viewPager); - mViewPager.setOffscreenPageLimit(PAGE_COUNT - 1); - mViewPager.setAdapter(new ViewPagerAdapter(mViewList)); - mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - } - - @Override - public void onPageSelected(int position) { - loadPageData(position); - } - - @Override - public void onPageScrollStateChanged(int state) { - - } - }); mIndicator = (MagicIndicator) findViewById(R.id.indicator); final String[] titles = new String[]{ (WordUtil.getString(R.string.glamour_list)), @@ -114,13 +134,14 @@ public class MainListActivity extends AbsActivity { @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); } }); @@ -131,22 +152,16 @@ public class MainListActivity extends AbsActivity { @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); - ViewPagerHelper.bind(mIndicator, mViewPager); + //默认选择第几个 mIndicator.onPageSelected(getIntent().getIntExtra("p", 0)); - mViewPager.setCurrentItem(getIntent().getIntExtra("p", 0)); //加载数据 loadData(); EventBus.getDefault().register(MainListActivity.this); @@ -156,9 +171,7 @@ public class MainListActivity extends AbsActivity { @Override public void onSuccess(NobleRankHideUserListModel data) { outRankHide = data.getOutRankHide(); - if (mContributeViewHolder != null) { - mContributeViewHolder.setHide(outRankHide); - } + } @Override @@ -166,9 +179,58 @@ public class MainListActivity extends AbsActivity { Log.e("MainListActivity", error); } }); + initView(); } - private void loadPageData(int position) { + private void initView() { + mType = DAY; + mViewPager = (ViewPager) findViewById(R.id.viewPager); + mBack = findViewById(R.id.btn_back); + mDay = findViewById(R.id.btn_day); + mWeek = findViewById(R.id.btn_week); + radioGroup = findViewById(R.id.radioGroup); + + mViewPager.setOffscreenPageLimit(PAGE_COUNT - 1); + mViewPager.setAdapter(new ViewPagerAdapter(mViewList)); + mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + MainListActivity.this.position = position; + mDay.setChecked(true); + mDay.setTextColor(Color.parseColor("#FF82C1")); + mWeek.setTextColor(Color.parseColor("#FFFFFF")); + loadPageData(position, DAY); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + mDay.setOnClickListener(v -> { + loadPageData(position, DAY); + mDay.setTextColor(Color.parseColor("#FF82C1")); + mWeek.setTextColor(Color.parseColor("#FFFFFF")); + }); + mWeek.setOnClickListener(v -> { + loadPageData(position, WEEK); + 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); + } + + private void loadPageData(int position, String rank) { if (mViewHolders == null) { return; } @@ -180,32 +242,38 @@ public class MainListActivity extends AbsActivity { return; } if (position == 0) { - mProfitViewHolder = new MainListProfitViewHolder(mContext, parent); - vh = mProfitViewHolder; + vh = new MainListProfitViewHolder(mContext, parent); + vh.setAppbarColor(Color.parseColor("#FF73C3")); } else if (position == 1) { - mContributeViewHolder = new MainListContributeViewHolder(mContext, parent); + MainListContributeViewHolder mContributeViewHolder = new MainListContributeViewHolder(mContext, parent); mContributeViewHolder.setHide(outRankHide); vh = mContributeViewHolder; + vh.setAppbarColor(Color.parseColor("#73B2FF")); } if (vh == null) { return; } + vh.setAppbarListener(isShow -> { + if (isShow) { + radioGroup.setVisibility(View.VISIBLE); + } else { + radioGroup.setVisibility(View.INVISIBLE); + } + }); mViewHolders[position] = vh; vh.addToParent(); vh.subscribeActivityLifeCycle(); } + } if (vh != null) { - vh.loadData(); + vh.setType(position, rank); } } - // @Override public void loadData() { - if (mViewPager != null) { - loadPageData(mViewPager.getCurrentItem()); - } + } @@ -217,12 +285,13 @@ public class MainListActivity extends AbsActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onFollowEvent(FollowEvent e) { - if (mViewHolders != null) { - for (AbsMainListChildViewHolder vh : mViewHolders) { - if (vh != null) { - vh.onFollowEvent(e.getToUid(), e.getIsAttention()); - } - } - } + } + + @Override + public void onItemClick(ListBean bean, int position) { + + } + + } \ 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 6f8584617..f951bfd33 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainListAdapter.java @@ -22,6 +22,7 @@ import com.yunbao.common.bean.LevelBean; import com.yunbao.common.custom.MyRadioButton; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.utils.CommonIconUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.SVGAViewUtils; @@ -44,16 +45,11 @@ 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; - private HeadVh mHeadVh; private int mType; private List outRankHide = new ArrayList<>(); @@ -61,69 +57,46 @@ 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)); + 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(), null); - } - }); - - } - }; + }); } @Override public int getItemCount() { if (mList != null && mTopList.size() > 0) { - return mList.size() + 1; + return mList.size(); } return 0; } @@ -180,14 +153,7 @@ public class MainListAdapter extends RefreshAdapter { @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - if (viewType == HEAD) { - if (mHeadVh == null) { - mHeadVh = new HeadVh(mInflater.inflate(R.layout.item_main_list_head, parent, false)); - } - return mHeadVh; - } else { - return new Vh(mInflater.inflate(R.layout.item_main_list, parent, false)); - } + return new Vh(mInflater.inflate(R.layout.item_main_list, parent, false)); } @Override @@ -198,313 +164,8 @@ public class MainListAdapter extends RefreshAdapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position, @NonNull List payloads) { Object payload = payloads.size() > 0 ? payloads.get(0) : null; - if (vh instanceof Vh) { - ((Vh) vh).setData(mList.get(position - 1), position - 1, payload); - } else { - ((HeadVh) vh).setData(payload); - } + ((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; @@ -544,7 +205,7 @@ public class MainListAdapter extends RefreshAdapter { public void onComplete(SVGAVideoEntity videoItem) { SVGADrawable drawable = new SVGADrawable(videoItem); svga.setImageDrawable(drawable); - SVGAViewUtils.playEndClear(svga,false); + SVGAViewUtils.playEndClear(svga, false); } @Override @@ -598,11 +259,12 @@ public class MainListAdapter extends RefreshAdapter { mBtnFollow.setText(mFollowing); mBtnFollow.setBackgroundResource(R.drawable.background_dbdbdb); mBtnFollow.setTextColor(Color.parseColor("#FFFFFF")); + mBtnFollow.setVisibility(View.INVISIBLE); } else { mBtnFollow.doChecked(false); mBtnFollow.setText(mFollow); - mBtnFollow.setBackgroundResource(R.drawable.background_yellow); - mBtnFollow.setTextColor(Color.parseColor("#FFFFFF")); + mBtnFollow.setBackgroundResource(R.drawable.background_ff7bbaff); + mBtnFollow.setTextColor(Color.parseColor("#7BBAFF")); } } } diff --git a/main/src/main/java/com/yunbao/main/bean/ListBean.java b/main/src/main/java/com/yunbao/main/bean/ListBean.java index 9434a52a0..6e4882719 100644 --- a/main/src/main/java/com/yunbao/main/bean/ListBean.java +++ b/main/src/main/java/com/yunbao/main/bean/ListBean.java @@ -128,4 +128,21 @@ public class ListBean { public void setSex(int sex) { this.sex = sex; } + + @Override + public String toString() { + return "ListBean{" + + "totalCoin=" + totalCoin + + ", uid='" + uid + '\'' + + ", userNiceName='" + userNiceName + '\'' + + ", avatarThumb='" + avatarThumb + '\'' + + ", sex=" + sex + + ", levelAnchor=" + levelAnchor + + ", level=" + level + + ", attention=" + attention + + ", islive=" + islive + + ", dress_head='" + dress_head + '\'' + + ", isHide=" + isHide + + '}'; + } } diff --git a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java index f4967cee7..ac91b309d 100644 --- a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java +++ b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java @@ -180,7 +180,7 @@ public class MainHttpUtil { } - //排行榜 收益榜 + //排行榜 魅力榜 public static void profitList(String type, int p, HttpCallback callback) { HttpClient.getInstance().get("Home.profitList", MainHttpConsts.PROFIT_LIST) .params("type", type) @@ -188,7 +188,7 @@ public class MainHttpUtil { .execute(callback); } - //排行榜 贡献榜 + //排行榜 豪气榜 public static void consumeList(String type, int p, HttpCallback callback) { HttpClient.getInstance().get("Home.consumeList", MainHttpConsts.CONSUME_LIST) .params("type", type) 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 f567b6b9f..0a68cdfd9 100644 --- a/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java @@ -1,21 +1,48 @@ package com.yunbao.main.views; import android.content.Context; + import androidx.recyclerview.widget.LinearLayoutManager; + +import android.graphics.Color; +import android.graphics.drawable.Drawable; 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.google.android.material.appbar.AppBarLayout; +import com.google.android.material.appbar.CollapsingToolbarLayout; +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. */ @@ -29,6 +56,13 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple protected String mType; protected CommonRefreshView mRefreshView; public MainListAdapter mAdapter; + protected OnLoadData loadData; + protected List list; + private HeadView hv; + private View mBackgroundLayout; + private OnAppbarListener appbarListener; + private AppBarLayout rootView; + private CollapsingToolbarLayout toolbarLayout; public AbsMainListChildViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -37,18 +71,39 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple @Override protected int getLayoutId() { - return R.layout.view_main_list_page; + return R.layout.activity_main_list; } @Override public void init() { mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView); + mBackgroundLayout = findViewById(R.id.bg_layout); + rootView = (AppBarLayout) findViewById(R.id.rootView); + toolbarLayout= (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout); + hv = new HeadView(rootView); mRefreshView.setEmptyLayoutId(R.layout.view_no_data_list); mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); - findViewById(R.id.btn_day).setOnClickListener(this); - findViewById(R.id.btn_week).setOnClickListener(this); - findViewById(R.id.btn_month).setOnClickListener(this); - findViewById(R.id.btn_total).setOnClickListener(this); + 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); + }; + rootView.addOnOffsetChangedListener(new AppBarLayout.BaseOnOffsetChangedListener() { + @Override + public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { + if (appbarListener != null) { + if (verticalOffset == 0) { + appbarListener.onShow(true); + } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) { + appbarListener.onShow(false); + } + } + } + }); + } + public void setAppbarColor(int color){ + toolbarLayout.setContentScrimColor(color); } @Override @@ -75,7 +130,11 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple @Override public void onItemClick(ListBean bean, int position) { - RouteUtil.forwardUserHome(mContext, bean.getUid(),0); + RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); + } + + public void setAppbarListener(OnAppbarListener appbarListener) { + this.appbarListener = appbarListener; } @Override @@ -86,10 +145,6 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple type = DAY; } else if (i == R.id.btn_week) { type = WEEK; - } else if (i == R.id.btn_month) { - type = MONTH; - } else if (i == R.id.btn_total) { - type = TOTAL; } if (!TextUtils.isEmpty(type) && !type.equals(mType)) { mType = type; @@ -99,4 +154,184 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple } } + + 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); + } + + public interface OnAppbarListener { + void onShow(boolean isShow); + } + + 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/MainListContributeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java index 9d163a9ac..0f6354734 100644 --- a/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainListContributeViewHolder.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.adapter.MainListAdapter; import com.yunbao.main.bean.ListBean; import com.yunbao.main.http.MainHttpConsts; @@ -51,7 +52,13 @@ public class MainListContributeViewHolder extends AbsMainListChildViewHolder { @Override public List processData(String[] info) { - return JSON.parseArray(Arrays.toString(info), ListBean.class); + list=JSON.parseArray(Arrays.toString(info), ListBean.class); + if(mRefreshView.getPageCount()==1){ + if (loadData != null) { + loadData.onData(list); + } + } + return list; } @Override 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 67cf3b5c3..342c06e12 100644 --- a/main/src/main/java/com/yunbao/main/views/MainListProfitViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainListProfitViewHolder.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.adapter.MainListAdapter; import com.yunbao.main.bean.ListBean; import com.yunbao.main.http.MainHttpConsts; @@ -41,14 +42,20 @@ public class MainListProfitViewHolder extends AbsMainListChildViewHolder { @Override public void loadData(int p, HttpCallback callback) { - if(!mType.isEmpty()){ + if (!mType.isEmpty()) { MainHttpUtil.profitList(mType, p, callback); } } @Override public List processData(String[] info) { - return JSON.parseArray(Arrays.toString(info), ListBean.class); + list = JSON.parseArray(Arrays.toString(info), ListBean.class); + if(mRefreshView.getPageCount()==1){ + if (loadData != null) { + loadData.onData(list); + } + } + return list; } @Override 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/drawable/background_33ffffff.xml b/main/src/main/res/drawable/background_33ffffff.xml new file mode 100644 index 000000000..d5c56f065 --- /dev/null +++ b/main/src/main/res/drawable/background_33ffffff.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/drawable/background_ff7bbaff.xml b/main/src/main/res/drawable/background_ff7bbaff.xml new file mode 100644 index 000000000..4867b5728 --- /dev/null +++ b/main/src/main/res/drawable/background_ff7bbaff.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/drawable/background_ffff79c2.xml b/main/src/main/res/drawable/background_ffff79c2.xml new file mode 100644 index 000000000..54b547107 --- /dev/null +++ b/main/src/main/res/drawable/background_ffff79c2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ 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 new file mode 100644 index 000000000..fed041be3 --- /dev/null +++ b/main/src/main/res/layout/activity_main_list.xml @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/view_main_list.xml b/main/src/main/res/layout/view_main_list.xml index 64f3d4c7f..50267d721 100644 --- a/main/src/main/res/layout/view_main_list.xml +++ b/main/src/main/res/layout/view_main_list.xml @@ -1,73 +1,97 @@ - - - - - - - - - - - - + android:layout_height="0dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + + + + + + + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:layout_gravity="center" + android:layout_marginTop="59dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - + - - /> + - + + + + - - - \ No newline at end of file + \ 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 497a0c524..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,89 +1,418 @@ - + android:background="#00FFFFFF" + android:orientation="vertical"> - + android:layout_height="421dp" + android:background="@mipmap/bg_glamour_top" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + android:layout_marginEnd="16dp" + android:layout_marginBottom="40dp" + android:gravity="center" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="@+id/item_2" + app:layout_constraintEnd_toStartOf="@+id/item_3" + app:layout_constraintStart_toEndOf="@+id/item_2"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:orientation="horizontal"> - + + + + + + + android:text="@string/shield_gift_effect" + android:textColor="@color/white" + android:textSize="11sp" /> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:text="已关注" + android:textColor="@color/white" + android:textSize="11sp" /> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:text="已关注" + android:textColor="@color/white" + android:textSize="11sp" /> - - - + + + 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/bg_glamour2_top.png b/main/src/main/res/mipmap-xxhdpi/bg_glamour2_top.png new file mode 100644 index 000000000..798242589 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/bg_glamour2_top.png differ diff --git a/main/src/main/res/mipmap-xxhdpi/bg_glamour_top.png b/main/src/main/res/mipmap-xxhdpi/bg_glamour_top.png new file mode 100644 index 000000000..fb1ae73f1 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/bg_glamour_top.png differ 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 000000000..46b4034d8 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/icon_back_white.png differ