修复:

侧边栏优先加载数据侧边栏
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.AnchorRecommendModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.SlideInfoModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.EffectsSettingsDialog;
import com.yunbao.common.dialog.LiveChargeDialogFragment;
@ -272,6 +273,7 @@ public class LiveAudienceActivity extends LiveActivity {
});
getDrawer();
}
private void loadData(ViewGroup viewGroup, int currentItem) {
@ -699,6 +701,8 @@ public class LiveAudienceActivity extends LiveActivity {
//从右边打开侧边栏
SidebarLiveAudience sidebarLiveAudience = new SidebarLiveAudience();
bundle.putString("Avatar", mLiveBean.getAvatar());
bundle.putString("banner", GsonUtils.toJson(slideInfoModels));
bundle.putString("list", GsonUtils.toJson(list));
sidebarLiveAudience.setArguments(bundle);
sidebarLiveAudience.show(getSupportFragmentManager(), "SidebarLiveAudience");
// manager.openDrawer();
@ -856,5 +860,39 @@ public class LiveAudienceActivity extends LiveActivity {
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 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.AnchorRecommendModel;
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.presenter.LiveRoomCheckLivePresenter;
import java.util.ArrayList;
import java.util.List;
/**
@ -42,6 +45,8 @@ public class SidebarLiveAudience extends AbsDialogFragment {
//侧边栏适配器
private SidebarAdapter sidebarAdapter;
private List<SlideInfoModel> slideInfoModels = new ArrayList<>();
private List<AnchorRecommendItemModel> list = new ArrayList<>();
@Override
protected int getLayoutId() {
@ -60,8 +65,13 @@ public class SidebarLiveAudience extends AbsDialogFragment {
sidebarBack = (ImageView) findViewById(R.id.sidebar_back);
if (bundle != null) {
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);
}
sidebarList = (CommonRefreshView) findViewById(R.id.sidebarList);
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.setHasStableIds(true);
sidebarList.setRecyclerViewAdapter(sidebarAdapter);
if (sidebarAdapter != null) {
sidebarAdapter.addData(list);
sidebarAdapter.setData(slideInfoModels);
}
sidebarList.setDataHelperNew(new CommonRefreshView.DataHelperNew() {
@Override
public void loadData(int p) {
@ -97,7 +111,6 @@ public class SidebarLiveAudience extends AbsDialogFragment {
.anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
@Override
public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
if (getActivity().isFinishing()) return;
//侧边栏
MainNetManager.get(getActivity())
.getHot(1, new com.yunbao.common.http.base.HttpCallback<List<SlideInfoModel>>() {

View File

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

View File

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