优化:

进入直播间的时间,筛选
This commit is contained in:
18401019693 2022-08-24 16:59:57 +08:00
parent 15bb24fa83
commit cff66d234d
5 changed files with 60 additions and 40 deletions

View File

@ -115,6 +115,17 @@ public interface PDLiveApi {
@Query("num") String num @Query("num") String num
); );
/**
* 直播间上下滚动列表
*
* @param num 请求数量
* @return
*/
@GET("/api/public/?service=Home.anchorRecommend ")
Observable<ResponseModel<AnchorRecommendModel>> anchorRecommend(
@Query("num") String num, @Query("type") String type
);
/** /**
* 获取直播间信息 * 获取直播间信息
* *
@ -150,6 +161,7 @@ public interface PDLiveApi {
*/ */
@GET("/api/public/?service=Active.getActiveList") @GET("/api/public/?service=Active.getActiveList")
Observable<ResponseModel<List<ActiveModel>>> getActiveList(); Observable<ResponseModel<List<ActiveModel>>> getActiveList();
/** /**
* 获取活动 * 获取活动
*/ */
@ -158,14 +170,16 @@ public interface PDLiveApi {
/** /**
* 获取日榜周榜数据 * 获取日榜周榜数据
*
* @param uid 直播间id并非用户uid * @param uid 直播间id并非用户uid
* @return 榜单结构 * @return 榜单结构
*/ */
@GET("/api/public/?service=Contribute.index") @GET("/api/public/?service=Contribute.index")
Observable<ResponseModel<ContributeModel>> getRanksList(@Query("uid")String uid); Observable<ResponseModel<ContributeModel>> getRanksList(@Query("uid") String uid);
/** /**
* 直播间新人特惠信息 * 直播间新人特惠信息
*
* @return 新人特惠数据 * @return 新人特惠数据
*/ */
@GET("/api/public/?service=Live.newUserPreferential") @GET("/api/public/?service=Live.newUserPreferential")

View File

@ -112,6 +112,28 @@ public class MainNetManager {
}).isDisposed(); }).isDisposed();
} }
/**
* 猜你喜欢
*
* @param num 请求数量
* @return
*/
public void anchorRecommendType(String num, HttpCallback<AnchorRecommendModel> httpCallback) {
API.get().pdLiveApi(mContext).anchorRecommend(num, "1")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(anchorRecommendModelResponseModel -> {
if (httpCallback != null) {
AnchorRecommendModel model = anchorRecommendModelResponseModel.getData().getInfo();
httpCallback.onSuccess(model);
}
}, throwable -> {
if (httpCallback != null) {
httpCallback.onError(throwable.getMessage());
}
}).isDisposed();
}
/** /**
* 搜索 * 搜索
* *

View File

@ -71,7 +71,6 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.RCRTCEngine;
@ -187,38 +186,12 @@ public class LiveAudienceActivity extends LiveActivity {
* 初始化数据 * 初始化数据
*/ */
private void initData() { private void initData() {
//直播间列表 String json = GsonUtils.toJson(mLiveBean);
MainNetManager.get(mContext) AnchorRecommendItemModel model = GsonUtils.fromJson(json, AnchorRecommendItemModel.class);
.anchorRecommend("30", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() { itemModelList.add(0, model);
@Override mPagerAdapter = new VerticalPagerAdapter(itemModelList, mContext);
public void onSuccess(AnchorRecommendModel data) { verticalViewPager.setAdapter(mPagerAdapter);
itemModelList = data.getList(); loadingView.hide();
//查询直播间状态
int index = -1;
for (int i = 0; i < itemModelList.size(); i++) {
AnchorRecommendItemModel model = itemModelList.get(i);
if (TextUtils.equals(mLiveBean.getUid(), model.getUid())) {
index = i;
}
}
if (index > -1) {
Collections.swap(itemModelList, index, 0);
} else {
String json = GsonUtils.toJson(mLiveBean);
AnchorRecommendItemModel model = GsonUtils.fromJson(json, AnchorRecommendItemModel.class);
itemModelList.add(0, model);
}
mPagerAdapter = new VerticalPagerAdapter(itemModelList, mContext);
verticalViewPager.setAdapter(mPagerAdapter);
loadingView.hide();
}
@Override
public void onError(String error) {
}
});
verticalViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { verticalViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override @Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@ -226,10 +199,12 @@ public class LiveAudienceActivity extends LiveActivity {
Log.e(TAG, "mCurrentItem:" + mCurrentItem); Log.e(TAG, "mCurrentItem:" + mCurrentItem);
if (mCurrentItem == itemModelList.size() - 1) { if (mCurrentItem == itemModelList.size() - 1) {
MainNetManager.get(mContext) MainNetManager.get(mContext)
.anchorRecommend("30", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() { .anchorRecommendType("30", new com.yunbao.common.http.base.HttpCallback<AnchorRecommendModel>() {
@Override @Override
public void onSuccess(AnchorRecommendModel data) { public void onSuccess(AnchorRecommendModel data) {
if (TextUtils.equals(data.getList().get(0).getUid(), mLiveBean.getUid())) {
data.getList().remove(0);
}
itemModelList.addAll(data.getList()); itemModelList.addAll(data.getList());
mPagerAdapter.notifyDataSetChanged(); mPagerAdapter.notifyDataSetChanged();
} }
@ -827,11 +802,15 @@ public class LiveAudienceActivity extends LiveActivity {
url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
Log.i("tag", url); Log.i("tag", url);
Intent intent=new Intent(mContext,ZhuangBanActivity.class); Intent intent = new Intent(mContext, ZhuangBanActivity.class);
intent.putExtra("url", url); intent.putExtra("url", url);
intent.putExtra("isFull",true); intent.putExtra("isFull", true);
mContext.startActivity(intent); mContext.startActivity(intent);
break; break;
case LIVE_ROOM_EXCEPTION:
//主播未直播时自动下滑至下一个直播间
verticalViewPager.setCurrentItem(mCurrentPage + 1);
break;
} }

View File

@ -59,7 +59,8 @@ public class LiveAudienceEvent extends BaseModel {
EFFECTS_SETTINGS(10, "特效設置"), EFFECTS_SETTINGS(10, "特效設置"),
WISH_LIST(11, "心愿单"), WISH_LIST(11, "心愿单"),
OPEN_PARAMETERS(12, "开放参数"), OPEN_PARAMETERS(12, "开放参数"),
ACTIVITY_CENTER(13, "活動中心"); ACTIVITY_CENTER(13, "活動中心"),
LIVE_ROOM_EXCEPTION(14, "直播间异常");
private int type; private int type;
private String name; private String name;

View File

@ -9,12 +9,14 @@ import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.MD5Util; import com.yunbao.common.utils.MD5Util;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
@ -76,6 +78,8 @@ public class LiveRoomCheckLivePresenter {
} }
} }
} else { } else {
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.LIVE_ROOM_EXCEPTION));
ToastUtil.show(msg); ToastUtil.show(msg);
} }
} }
@ -119,7 +123,7 @@ public class LiveRoomCheckLivePresenter {
} }
} }
}); });
}else { } else {
enterLiveRoom(); enterLiveRoom();
isRoom = false; isRoom = false;
} }