侧边栏数据请求前移

This commit is contained in:
18401019693 2022-11-30 15:46:38 +08:00
parent cb55c09624
commit 8e7de87c6b
2 changed files with 45 additions and 19 deletions

View File

@ -59,7 +59,7 @@ public class CustomDrawerPopupView extends DrawerPopupView {
Bus.getOn(this); Bus.getOn(this);
super.onCreate(); super.onCreate();
initView(); initView();
initData();
} }
@ -148,7 +148,10 @@ public class CustomDrawerPopupView extends DrawerPopupView {
}); });
} }
private void initData() { public void initData(List<CustomSidebarInfoModel> data) {
if (data != null) {
adapter.updateData(data);
} else {
LiveNetManager.get(mContext) LiveNetManager.get(mContext)
.getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback<List<CustomSidebarInfoModel>>() { .getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback<List<CustomSidebarInfoModel>>() {
@Override @Override
@ -163,6 +166,8 @@ public class CustomDrawerPopupView extends DrawerPopupView {
}); });
} }
}
private CustomDrawerPopupCallBack callBack; private CustomDrawerPopupCallBack callBack;
public CustomDrawerPopupView setCallBack(CustomDrawerPopupCallBack callBack) { public CustomDrawerPopupView setCallBack(CustomDrawerPopupCallBack callBack) {
@ -226,7 +231,7 @@ public class CustomDrawerPopupView extends DrawerPopupView {
} }
if (event.isRefresh()) { if (event.isRefresh()) {
initData(); initData(null);
} }
} }

View File

@ -41,6 +41,7 @@ import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.AnchorRecommendItemModel;
import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.CrashSaveBean; import com.yunbao.common.bean.CrashSaveBean;
import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LinkMicUserBean; import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
@ -59,6 +60,7 @@ import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.http.main.MainNetManager; import com.yunbao.common.http.main.MainNetManager;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
@ -183,6 +185,7 @@ public class LiveAudienceActivity extends LiveActivity {
initData(); initData();
MicStatusManager.getInstance().addOnMicListener(onMicStatusListener); MicStatusManager.getInstance().addOnMicListener(onMicStatusListener);
} }
private final MicStatusManager.OnMicStatusListener onMicStatusListener = new MicStatusManager.OnMicStatusListener() { private final MicStatusManager.OnMicStatusListener onMicStatusListener = new MicStatusManager.OnMicStatusListener() {
@Override @Override
public void onStart() { public void onStart() {
@ -194,6 +197,7 @@ public class LiveAudienceActivity extends LiveActivity {
verticalViewPager.setEnableScroll(true); verticalViewPager.setEnableScroll(true);
} }
}; };
/** /**
* 初始化界面 * 初始化界面
*/ */
@ -304,6 +308,19 @@ public class LiveAudienceActivity extends LiveActivity {
}); });
getDrawer(); getDrawer();
//侧边栏
LiveNetManager.get(mContext)
.getCustomSidebarInfo(new com.yunbao.common.http.base.HttpCallback<List<CustomSidebarInfoModel>>() {
@Override
public void onSuccess(List<CustomSidebarInfoModel> data) {
customSidebarInfoModels = data;
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
} }
private void loadData(ViewGroup viewGroup, int currentItem) { private void loadData(ViewGroup viewGroup, int currentItem) {
@ -751,6 +768,7 @@ public class LiveAudienceActivity extends LiveActivity {
list.remove(userIndex); list.remove(userIndex);
} }
CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list).setLiveId(mLiveBean.getUid()); CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list).setLiveId(mLiveBean.getUid());
customDrawerPopupView.setCallBack(new CustomDrawerPopupView.CustomDrawerPopupCallBack() { customDrawerPopupView.setCallBack(new CustomDrawerPopupView.CustomDrawerPopupCallBack() {
@Override @Override
public void funGamesID(int zfunGamesID) { public void funGamesID(int zfunGamesID) {
@ -894,7 +912,7 @@ public class LiveAudienceActivity extends LiveActivity {
@Override @Override
public void onShow(BasePopupView popupView) { public void onShow(BasePopupView popupView) {
customDrawerPopupView.initData(customSidebarInfoModels);
} }
@Override @Override
@ -1275,6 +1293,7 @@ public class LiveAudienceActivity extends LiveActivity {
*/ */
private List<SlideInfoModel> slideInfoModels = new ArrayList<>(); private List<SlideInfoModel> slideInfoModels = new ArrayList<>();
private List<AnchorRecommendItemModel> list = new ArrayList<>(); private List<AnchorRecommendItemModel> list = new ArrayList<>();
private List<CustomSidebarInfoModel> customSidebarInfoModels = new ArrayList<>();
private void getDrawer() { private void getDrawer() {
@ -1295,6 +1314,8 @@ public class LiveAudienceActivity extends LiveActivity {
public void onError(String error) { public void onError(String error) {
} }
}); });
} }
public void onFollowEvent(FollowEvent e) { public void onFollowEvent(FollowEvent e) {