From fbb801bf625544c5d04fb46e48999d6d4604b5e1 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 26 Dec 2023 18:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=88=98=E4=BB=A4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E8=B0=83=E6=95=B4=E6=88=98=E4=BB=A4=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E7=AD=89=E7=BA=A7=E6=9C=80=E5=A4=A7=E5=80=BC=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=88=98=E4=BB=A4=E7=BB=9F=E8=AE=A1=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E9=97=B4=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bean/BattlePassUserInfoBean.java | 20 +++++ .../common/dialog/OrderLevelPopupWindow.java | 10 ++- .../com/yunbao/common/http/PDLiveApi.java | 2 + .../common/http/live/LiveNetManager.java | 22 +++++- .../yunbao/live/socket/SocketRyChatUtil.java | 14 ++++ .../main/activity/BattlePassActivity.java | 34 ++++---- .../adapter/BattlePassMissionAdapter.java | 1 + .../main/adapter/BattlePassRewardAdapter.java | 79 +++++++++++-------- .../fragment/BattlePassExchangeFragment.java | 32 ++++---- .../fragment/BattlePassMissionFragment.java | 37 ++++----- .../fragment/BattlePassRewardFragment.java | 40 +++++----- .../BattlePassUserInfoListener.java | 7 ++ 12 files changed, 189 insertions(+), 109 deletions(-) create mode 100644 main/src/main/java/com/yunbao/main/interfaces/BattlePassUserInfoListener.java diff --git a/common/src/main/java/com/yunbao/common/bean/BattlePassUserInfoBean.java b/common/src/main/java/com/yunbao/common/bean/BattlePassUserInfoBean.java index b305ea6e2..f6fb0f17c 100644 --- a/common/src/main/java/com/yunbao/common/bean/BattlePassUserInfoBean.java +++ b/common/src/main/java/com/yunbao/common/bean/BattlePassUserInfoBean.java @@ -29,6 +29,10 @@ public class BattlePassUserInfoBean extends BaseModel{ private String endTime; @SerializedName("battle_pass_status") private boolean battlePassStatus; + @SerializedName("max_level_exp") + private long maxLevelExp; + @SerializedName("max_level") + private int maxLevel; private List live_battle_pass_type; @@ -153,4 +157,20 @@ public class BattlePassUserInfoBean extends BaseModel{ public void setBattlePassStatus(boolean battlePassStatus) { this.battlePassStatus = battlePassStatus; } + + public long getMaxLevelExp() { + return maxLevelExp; + } + + public void setMaxLevelExp(long maxLevelExp) { + this.maxLevelExp = maxLevelExp; + } + + public int getMaxLevel() { + return maxLevel; + } + + public void setMaxLevel(int maxLevel) { + this.maxLevel = maxLevel; + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java index 560227642..f8641471d 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java @@ -12,6 +12,8 @@ import com.yunbao.common.R; import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import java.math.BigDecimal; @@ -25,15 +27,17 @@ public class OrderLevelPopupWindow extends CenterPopupView { private String buyExp = "100", currentLevel, balance; private ProgressBar progressBar; private OrderLevelCallback orderLevelCallback; + private long maxExp; public OrderLevelPopupWindow(@NonNull Context context, int mCurrentExperience, int mTotalExperience, - String mCurrentLevel, String mBalance, OrderLevelCallback mOrderLevelCallback) { + String mCurrentLevel, String mBalance,long maxExp, OrderLevelCallback mOrderLevelCallback) { super(context); currentExperience = mCurrentExperience; totalExperience = mTotalExperience; currentLevel = mCurrentLevel; balance = mBalance; + this.maxExp=maxExp; orderLevelCallback = mOrderLevelCallback; } @@ -72,11 +76,13 @@ public class OrderLevelPopupWindow extends CenterPopupView { @Override public void onClick(View view) { float exp = new BigDecimal(buyExp).floatValue(); - if (exp < 10000) { + if (exp < maxExp && exp < 10000) { BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).add(new BigDecimal("100")); buyExp = String.valueOf(buyExpBigDecimal.intValue()); orderLevelDiamond.setText(String.valueOf(buyExpBigDecimal.floatValue())); orderLevel.setText(buyExp); + }else if(exp>=maxExp){ + ToastUtil.show(WordUtil.isNewZh()?"经验已滿":"Experience full"); } } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 3b09f2fcb..fa2e4a159 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1131,4 +1131,6 @@ public interface PDLiveApi { Observable>> getBattlePassPoints(); @GET("/api/public/?service=Livebattlepass.battlePassRule") Observable> battlePassRule(); + @GET("/api/public/?service=Livebattlepass.addChatCount") + Observable>> addChatCount(); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 5d3cf9a68..d8906c623 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -2757,7 +2757,27 @@ public class LiveNetManager { } }).isDisposed(); } - + public void addChatCount(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .addChatCount() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(responseModel -> { + if (callback != null) { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg())); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } /** * 直播间取消网络请求 */ diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java index 31da3142e..e3e3e2762 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java @@ -6,10 +6,12 @@ import android.util.Log; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; +import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; @@ -128,6 +130,18 @@ public class SocketRyChatUtil { if (SocketRyClient.mSocketHandler != null) { SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + ""); } + LiveNetManager.get(CommonAppContext.sInstance) + .addChatCount(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + + } + }); } @Override diff --git a/main/src/main/java/com/yunbao/main/activity/BattlePassActivity.java b/main/src/main/java/com/yunbao/main/activity/BattlePassActivity.java index 4ec4c489a..23472be43 100644 --- a/main/src/main/java/com/yunbao/main/activity/BattlePassActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/BattlePassActivity.java @@ -41,6 +41,7 @@ import com.yunbao.main.event.BattlePassTypeEvent; import com.yunbao.main.fragment.BattlePassExchangeFragment; import com.yunbao.main.fragment.BattlePassMissionFragment; import com.yunbao.main.fragment.BattlePassRewardFragment; +import com.yunbao.main.interfaces.BattlePassUserInfoListener; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -95,9 +96,9 @@ public class BattlePassActivity extends AbsActivity { tab3 = findViewById(R.id.tab_3); expText = findViewById(R.id.exp_text); viewPager = findViewById(R.id.context_layout); - fragments.add(new BattlePassRewardFragment()); - fragments.add(new BattlePassMissionFragment()); - fragments.add(new BattlePassExchangeFragment()); + fragments.add(new BattlePassRewardFragment(() -> data)); + fragments.add(new BattlePassMissionFragment(() -> data)); + fragments.add(new BattlePassExchangeFragment(() -> data)); viewPager.setAdapter(new FragmentStateAdapter(this) { @NonNull @Override @@ -127,18 +128,18 @@ public class BattlePassActivity extends AbsActivity { .enableDrag(false) .maxWidth(DeviceUtils.getScreenHeight(mContext) - DpUtil.dp2px(34)) .asCustom(new PromotionElitePopupWindow(mContext, - enjoySpendMoney, - quintessenceSpendMoney, - new LiberalBattlePassPopupWindow.LiberalBattlePassCallback() { - @Override - public void onCallback(int code, String msg) { - ToastUtil.show(msg); - fragments.get(viewPager.getCurrentItem()).updateData(); - } - }, - String.valueOf(data.getLive_battle_pass_type().get(1).getId()), - String.valueOf(data.getLive_battle_pass_type().get(2).getId()) - ).setUserData(data) + enjoySpendMoney, + quintessenceSpendMoney, + new LiberalBattlePassPopupWindow.LiberalBattlePassCallback() { + @Override + public void onCallback(int code, String msg) { + ToastUtil.show(msg); + fragments.get(viewPager.getCurrentItem()).updateData(); + } + }, + String.valueOf(data.getLive_battle_pass_type().get(1).getId()), + String.valueOf(data.getLive_battle_pass_type().get(2).getId()) + ).setUserData(data) ) .show(); }); @@ -191,7 +192,8 @@ public class BattlePassActivity extends AbsActivity { data.getEndTime() )); levelView.setText("Lv." + data.getLevel()); - expText.setText(data.getBattlePassExp() + "/" + data.getNextLevelExp()); + expText.setText(data.getBattlePassExp() + "/" + + (data.getNextLevelExp() == 0 ? data.getBattlePassExp() : data.getNextLevelExp())); levelProgressView.setMax(data.getNextLevelExp()); levelProgressView.setMin(data.getLastLevelExp()); levelProgressView.setProgress(data.getBattlePassExp()); diff --git a/main/src/main/java/com/yunbao/main/adapter/BattlePassMissionAdapter.java b/main/src/main/java/com/yunbao/main/adapter/BattlePassMissionAdapter.java index c677a586d..c426b1190 100644 --- a/main/src/main/java/com/yunbao/main/adapter/BattlePassMissionAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/BattlePassMissionAdapter.java @@ -148,6 +148,7 @@ public class BattlePassMissionAdapter extends RecyclerView.Adapter data, int position) { this.data = data; + for (LiveBattlePassRewardsBean.LiveBattlePassReward value : data.values()) { + if (value.getId() > 0) { + level = value.getLiveBattlePassLevel(); + break; + } + } if (position == 0) { ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) lineBg.getLayoutParams(); ConstraintLayout.LayoutParams params1 = (ConstraintLayout.LayoutParams) line.getLayoutParams(); params.topMargin = DpUtil.dp2px(3); params1.topMargin = DpUtil.dp2px(3); + } else { + ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) lineBg.getLayoutParams(); + ConstraintLayout.LayoutParams params1 = (ConstraintLayout.LayoutParams) line.getLayoutParams(); + params.topMargin = DpUtil.dp2px(0); + params1.topMargin = DpUtil.dp2px(0); } - setVisibility(View.VISIBLE, -1, tab1Mask, tab2Mask, tab3Mask); setVisibility(View.GONE, -1, tab1Unlock, tab1Unlock, tab1Unlock); setVisibility(View.GONE, -1, tab1Subscript, tab2Subscript, tab3Subscript); + setVisibility(View.VISIBLE, -1, tab1Layout, tab2Layout, tab3Layout); + setVisibility(View.VISIBLE, -1, tab1, tab2, tab3); + setVisibility(View.VISIBLE, -1, tab1Mask, tab2Mask, tab3Mask); line.setVisibility(View.GONE); point.setVisibility(View.GONE); - if (userLevel > (position + 1) && userLevel < mList.size()) { + if (userLevel > level && userLevel < userType.getMaxLevel()) { setVisibility(View.GONE, -1, tab1Mask, tab2Mask, tab3Mask); point.setVisibility(View.GONE); line.setVisibility(View.VISIBLE); } - if (userLevel == (position + 1) && userLevel < mList.size()) { + if (userLevel == level && userLevel < userType.getMaxLevel()) { setVisibility(View.GONE, -1, tab1Mask, tab2Mask, tab3Mask); ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) line.getLayoutParams(); params.bottomMargin = DpUtil.dp2px(70); line.setVisibility(View.VISIBLE); point.setVisibility(View.VISIBLE); } - if (userLevel >= mList.size()) { + if (userLevel >= userType.getMaxLevel()) { setVisibility(View.GONE, -1, tab1Mask, tab2Mask, tab3Mask); line.setVisibility(View.VISIBLE); point.setVisibility(View.GONE); } - lv.setText("V" + (position + 1)); getAllView((reward, view) -> ImgLoader.display(mContext, reward.getImageUrl(), view), tab1, tab2, tab3); getAllView(((reward, view) -> { - if (userLevel < (position + 1)) { - view.setVisibility(View.GONE); - return; - } - if (reward.getLock() == 1) { - view.setVisibility(View.VISIBLE); - } else { - view.setVisibility(View.GONE); - } + if (userLevel < level) { + view.setVisibility(View.GONE); + return; + } + if (reward.getLock() == 1) { + view.setVisibility(View.VISIBLE); + } else { + view.setVisibility(View.GONE); + } }), tab1Unlock, tab2Unlock, tab3Unlock); getAllView(((reward, view) -> { + lv.setText("V" + reward.getLiveBattlePassLevel()); view.setText(reward.getRewardName()); }), tab1Title, tab2Title, tab3Title); getAllView(((reward, view) -> { @@ -183,37 +198,38 @@ public class BattlePassRewardAdapter extends RecyclerView.Adapter void getView(int type, ViewData viewData, T... views) { if (data.containsKey(type) && data.get(type) != null && Objects.requireNonNull(data.get(type)).getId() != 0) { viewData.onData(data.get(type), views[type - 1]); + setVisibility(View.VISIBLE, type - 1, tab1Layout, tab2Layout, tab3Layout); } else { setVisibility(View.INVISIBLE, type - 1, tab1Layout, tab2Layout, tab3Layout); } diff --git a/main/src/main/java/com/yunbao/main/fragment/BattlePassExchangeFragment.java b/main/src/main/java/com/yunbao/main/fragment/BattlePassExchangeFragment.java index 71131e0ce..1ae645240 100644 --- a/main/src/main/java/com/yunbao/main/fragment/BattlePassExchangeFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/BattlePassExchangeFragment.java @@ -23,12 +23,18 @@ import com.yunbao.main.activity.BattlePassActivity; import com.yunbao.main.adapter.BattlePassExchangeAdapter; import com.yunbao.main.adapter.BattlePassMissionAdapter; import com.yunbao.main.event.BattlePassTypeEvent; +import com.yunbao.main.interfaces.BattlePassUserInfoListener; import java.util.List; public class BattlePassExchangeFragment extends BaseFragment { RecyclerView mRecyclerView; BattlePassExchangeAdapter adapter; + BattlePassUserInfoListener userInfoListener; + + public BattlePassExchangeFragment(BattlePassUserInfoListener userInfoListener) { + this.userInfoListener = userInfoListener; + } @Override public View createView(LayoutInflater inflater, ViewGroup container) { @@ -46,9 +52,8 @@ public class BattlePassExchangeFragment extends BaseFragment { } @Override - public void updateData() { - super.updateData(); - loadData(); + protected void loadData() { + } @Override @@ -65,23 +70,14 @@ public class BattlePassExchangeFragment extends BaseFragment { mRecyclerView.setAdapter(adapter); } private void initData() { - LiveNetManager.get(getContext()) - .getBattlePassUserInfo(new HttpCallback() { - @Override - public void onSuccess(BattlePassUserInfoBean data) { - if(adapter!=null) { - adapter.setPoint(data.getPoints()); - } - } - - @Override - public void onError(String error) { - - } - }); + BattlePassUserInfoBean userInfo = userInfoListener.getBattlePassUserInfo(); + if(adapter!=null && userInfo!=null){ + adapter.setPoint(userInfo.getPoints()); + } } @Override - protected void loadData() { + public void updateData() { + super.updateData(); initData(); LiveNetManager.get(getContext()) .getBattlePassPoints(new HttpCallback>() { diff --git a/main/src/main/java/com/yunbao/main/fragment/BattlePassMissionFragment.java b/main/src/main/java/com/yunbao/main/fragment/BattlePassMissionFragment.java index e032096f8..498416dce 100644 --- a/main/src/main/java/com/yunbao/main/fragment/BattlePassMissionFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/BattlePassMissionFragment.java @@ -26,6 +26,7 @@ import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; import com.yunbao.main.adapter.BattlePassMissionAdapter; import com.yunbao.main.event.BattlePassTypeEvent; +import com.yunbao.main.interfaces.BattlePassUserInfoListener; import java.util.ArrayList; import java.util.List; @@ -33,7 +34,11 @@ import java.util.List; public class BattlePassMissionFragment extends BaseFragment { RecyclerView mRecyclerView; BattlePassMissionAdapter adapter; - BattlePassUserInfoBean userInfoBean; + BattlePassUserInfoListener userInfoListener; + + public BattlePassMissionFragment(BattlePassUserInfoListener userInfoListener) { + this.userInfoListener = userInfoListener; + } @Override public View createView(LayoutInflater inflater, ViewGroup container) { @@ -52,9 +57,8 @@ public class BattlePassMissionFragment extends BaseFragment { } @Override - public void updateData() { - super.updateData(); - loadData(); + protected void loadData() { + } @Override @@ -67,12 +71,15 @@ public class BattlePassMissionFragment extends BaseFragment { adapter.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(BattlePassTask.Task bean, int position) { - Bus.get().post(new BattlePassTypeEvent(0)); if (position == -2) { + BattlePassUserInfoBean userInfoBean = userInfoListener.getBattlePassUserInfo(); if (userInfoBean.getNextLevelExp() == 0) { ToastUtil.show(WordUtil.getNewString(R.string.battlepass_user_level_max)); return; } + long maxExp=userInfoBean.getMaxLevelExp() - userInfoBean.getBattlePassExp(); + ToastUtil.show("max = "+maxExp+"|"+userInfoBean.getNextLevelExp()); + new XPopup.Builder(getContext()) .enableDrag(false) .maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34)) @@ -81,6 +88,7 @@ public class BattlePassMissionFragment extends BaseFragment { userInfoBean.getNextLevelExp() - userInfoBean.getLastLevelExp(), String.valueOf(userInfoBean.getLevel()), String.valueOf(IMLoginManager.get(getContext()).getUserInfo().getCoin()), + maxExp, new OrderLevelPopupWindow.OrderLevelCallback() { @Override public void onCallback(int code, String msg) { @@ -94,15 +102,16 @@ public class BattlePassMissionFragment extends BaseFragment { ) .show(); } else { - loadData(); + updateData(); + Bus.get().post(new BattlePassTypeEvent(0)); } } }); mRecyclerView.setAdapter(adapter); } - @Override - protected void loadData() { + public void updateData() { + super.updateData(); LiveNetManager.get(getContext()) .getBattlePassTask(new HttpCallback() { @Override @@ -120,18 +129,6 @@ public class BattlePassMissionFragment extends BaseFragment { @Override public void onError(String error) { - } - }); - LiveNetManager.get(getContext()) - .getBattlePassUserInfo(new HttpCallback() { - @Override - public void onSuccess(BattlePassUserInfoBean data) { - userInfoBean = data; - } - - @Override - public void onError(String error) { - } }); } diff --git a/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java b/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java index 93f74d49b..099f6431f 100644 --- a/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/BattlePassRewardFragment.java @@ -28,6 +28,7 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; import com.yunbao.main.adapter.BattlePassRewardAdapter; import com.yunbao.main.event.BattlePassTypeEvent; +import com.yunbao.main.interfaces.BattlePassUserInfoListener; import java.util.ArrayList; import java.util.Collection; @@ -44,6 +45,11 @@ public class BattlePassRewardFragment extends BaseFragment { String enjoySpendMoney = ""; String quintessenceSpendMoney = ""; + BattlePassUserInfoListener userInfoListener; + + public BattlePassRewardFragment(BattlePassUserInfoListener userInfoListener) { + this.userInfoListener = userInfoListener; + } @Override public View createView(LayoutInflater inflater, ViewGroup container) { @@ -62,9 +68,8 @@ public class BattlePassRewardFragment extends BaseFragment { } @Override - public void updateData() { - super.updateData(); - loadData(); + protected void loadData() { + } @Override @@ -78,7 +83,7 @@ public class BattlePassRewardFragment extends BaseFragment { adapter.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(LiveBattlePassRewardsBean.LiveBattlePassReward bean, int position) { - loadData(); + updateData(); Bus.get().post(new BattlePassTypeEvent(0)); } }); @@ -100,7 +105,7 @@ public class BattlePassRewardFragment extends BaseFragment { @Override public void onCallback(int code, String msg) { ToastUtil.show(msg); - loadData(); + updateData(); Bus.get().post(new BattlePassTypeEvent(0)); } }, @@ -123,7 +128,7 @@ public class BattlePassRewardFragment extends BaseFragment { @Override public void onCallback(int code, String msg) { ToastUtil.show(msg); - loadData(); + updateData(); Bus.get().post(new BattlePassTypeEvent(0)); } }, @@ -134,7 +139,8 @@ public class BattlePassRewardFragment extends BaseFragment { } @Override - protected void loadData() { + public void updateData() { + super.updateData(); LiveNetManager.get(getContext()) .getLiveBattlePassRewards(new HttpCallback() { @@ -170,20 +176,12 @@ public class BattlePassRewardFragment extends BaseFragment { }); } private void initData() { - LiveNetManager.get(getContext()) - .getBattlePassUserInfo(new HttpCallback() { - @Override - public void onSuccess(BattlePassUserInfoBean data) { - setTab(data); - adapter.setUserType(data); - adapter.notifyDataSetChanged(); - } - - @Override - public void onError(String error) { - - } - }); + BattlePassUserInfoBean userInfo = userInfoListener.getBattlePassUserInfo(); + if(userInfo!=null){ + setTab(userInfo); + adapter.setUserType(userInfo); + adapter.notifyDataSetChanged(); + } } private void setTab(BattlePassUserInfoBean data) { tab1.setImageResource(R.mipmap.ic_reward_tab_normal); diff --git a/main/src/main/java/com/yunbao/main/interfaces/BattlePassUserInfoListener.java b/main/src/main/java/com/yunbao/main/interfaces/BattlePassUserInfoListener.java new file mode 100644 index 000000000..722c2d5ab --- /dev/null +++ b/main/src/main/java/com/yunbao/main/interfaces/BattlePassUserInfoListener.java @@ -0,0 +1,7 @@ +package com.yunbao.main.interfaces; + +import com.yunbao.common.bean.BattlePassUserInfoBean; + +public interface BattlePassUserInfoListener { + BattlePassUserInfoBean getBattlePassUserInfo(); +}