修复:

侧边栏优先加载数据侧边栏
This commit is contained in:
18401019693 2022-08-24 15:03:26 +08:00
parent 112125bd69
commit 5f2fdd7052
4 changed files with 54 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import com.yunbao.common.HtmlConfig;
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.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog; import com.yunbao.common.dialog.EffectsSettingsDialog;
import com.yunbao.common.dialog.LiveChargeDialogFragment; import com.yunbao.common.dialog.LiveChargeDialogFragment;
@ -272,6 +273,7 @@ public class LiveAudienceActivity extends LiveActivity {
}); });
getDrawer();
} }
private void loadData(ViewGroup viewGroup, int currentItem) { private void loadData(ViewGroup viewGroup, int currentItem) {
@ -699,6 +701,8 @@ public class LiveAudienceActivity extends LiveActivity {
//从右边打开侧边栏 //从右边打开侧边栏
SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience(); SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience();
bundle.putString("Avatar", mLiveBean.getAvatar()); bundle.putString("Avatar", mLiveBean.getAvatar());
bundle.putString("banner", GsonUtils.toJson(slideInfoModels));
bundle.putString("list", GsonUtils.toJson(list));
sidebarLiveAudience.setArguments(bundle); sidebarLiveAudience.setArguments(bundle);
sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience"); sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience");
// manager.openDrawer(); // manager.openDrawer();
@ -856,5 +860,39 @@ public class LiveAudienceActivity extends LiveActivity {
context.startActivity(intent); context.startActivity(intent);
} }
/**
* 获取侧边栏数据
*/
private List<SlideInfoModel> slideInfoModels = new ArrayList<>();
private List<AnchorRecommendItemModel> list = new ArrayList<>();
private void getDrawer() {
//侧边栏轮播
MainNetManager.get(mContext)
.getHot(1, new com.yunbao.common.http.base.HttpCallback<List<SlideInfoModel>>() {
@Override
public void onSuccess(List<SlideInfoModel> data) {
slideInfoModels = data;
}
@Override
public void onError(String error) {
}
});
//推荐位
MainNetManager.get(mContext)
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
@Override
public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
list = anchorRecommendModel.getList();
}
@Override
public void onError(String error) {
}
});
}
} }

View File

@ -11,6 +11,8 @@ import android.widget.ImageView;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.GsonUtils;
import com.google.gson.reflect.TypeToken;
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.SlideInfoModel; import com.yunbao.common.bean.SlideInfoModel;
@ -29,6 +31,7 @@ import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -42,6 +45,8 @@ public class SidebarLiveAudience extends AbsDialogFragment {
//侧边栏适配器 //侧边栏适配器
private SidebarAdapter sidebarAdapter; private SidebarAdapter sidebarAdapter;
private List<SlideInfoModel> slideInfoModels = new ArrayList<>();
private List<AnchorRecommendItemModel> list = new ArrayList<>();
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
@ -60,8 +65,13 @@ public class SidebarLiveAudience extends AbsDialogFragment {
sidebarBack = (ImageView) findViewById(R.id.sidebar_back); sidebarBack = (ImageView) findViewById(R.id.sidebar_back);
if (bundle != null) { if (bundle != null) {
String avatar = bundle.getString("Avatar"); String avatar = bundle.getString("Avatar");
slideInfoModels = GsonUtils.fromJson(bundle.getString("banner"), new TypeToken<List<SlideInfoModel>>() {
}.getType());
list = GsonUtils.fromJson(bundle.getString("list"), new TypeToken<List<AnchorRecommendItemModel>>() {
}.getType());
//侧边栏背景 //侧边栏背景
ImgLoader.displayBlurLive(mContext, avatar, sidebarBack); ImgLoader.displayBlurLive(mContext, avatar, sidebarBack);
} }
sidebarList = (CommonRefreshView) findViewById(R.id.sidebarList); sidebarList = (CommonRefreshView) findViewById(R.id.sidebarList);
GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false); GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, 2, GridLayoutManager.VERTICAL, false);
@ -84,6 +94,10 @@ public class SidebarLiveAudience extends AbsDialogFragment {
sidebarAdapter = new SidebarAdapter(mContext, mDisplay.getHeight()); sidebarAdapter = new SidebarAdapter(mContext, mDisplay.getHeight());
sidebarAdapter.setHasStableIds(true); sidebarAdapter.setHasStableIds(true);
sidebarList.setRecyclerViewAdapter(sidebarAdapter); sidebarList.setRecyclerViewAdapter(sidebarAdapter);
if (sidebarAdapter != null) {
sidebarAdapter.addData(list);
sidebarAdapter.setData(slideInfoModels);
}
sidebarList.setDataHelperNew(new CommonRefreshView.DataHelperNew() { sidebarList.setDataHelperNew(new CommonRefreshView.DataHelperNew() {
@Override @Override
public void loadData(int p) { public void loadData(int p) {
@ -97,7 +111,6 @@ public class SidebarLiveAudience extends AbsDialogFragment {
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() { .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
@Override @Override
public void onSuccess(AnchorRecommendModel anchorRecommendModel) { public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
if (getActivity().isFinishing()) return;
//侧边栏 //侧边栏
MainNetManager.get(getActivity()) MainNetManager.get(getActivity())
.getHot(1, new com.yunbao.common.http.base.HttpCallback<List<SlideInfoModel>>() { .getHot(1, new com.yunbao.common.http.base.HttpCallback<List<SlideInfoModel>>() {

View File

@ -26,7 +26,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="56dp"> android:paddingTop="26dp">
<com.yunbao.common.custom.CommonRefreshView <com.yunbao.common.custom.CommonRefreshView

View File

@ -6,6 +6,7 @@
<LinearLayout <LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">