diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 42bac001d..1cfce84e9 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -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 slideInfoModels = new ArrayList<>(); + private List list = new ArrayList<>(); + + private void getDrawer() { + //侧边栏轮播 + MainNetManager.get(mContext) + .getHot(1, new com.yunbao.common.http.base.HttpCallback>() { + @Override + public void onSuccess(List data) { + slideInfoModels = data; + } + + @Override + public void onError(String error) { + + } + }); + //推荐位 + MainNetManager.get(mContext) + .anchorRecommend("10", new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(AnchorRecommendModel anchorRecommendModel) { + list = anchorRecommendModel.getList(); + + } + + @Override + public void onError(String error) { + } + }); + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java index 6bebc9b88..3cddb178c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java +++ b/live/src/main/java/com/yunbao/live/dialog/SidebarLiveAudience.java @@ -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 slideInfoModels = new ArrayList<>(); + private List 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>() { + }.getType()); + list = GsonUtils.fromJson(bundle.getString("list"), new TypeToken>() { + }.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() { @Override public void onSuccess(AnchorRecommendModel anchorRecommendModel) { - if (getActivity().isFinishing()) return; //侧边栏 MainNetManager.get(getActivity()) .getHot(1, new com.yunbao.common.http.base.HttpCallback>() { diff --git a/live/src/main/res/layout/view_sidebar_live_audience.xml b/live/src/main/res/layout/view_sidebar_live_audience.xml index bf238c7d0..633315de9 100644 --- a/live/src/main/res/layout/view_sidebar_live_audience.xml +++ b/live/src/main/res/layout/view_sidebar_live_audience.xml @@ -26,7 +26,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:paddingTop="56dp"> + android:paddingTop="26dp">