合并接口第三次上传
This commit is contained in:
parent
5e631652a9
commit
082c9d7d12
@ -63,9 +63,9 @@ public class API extends BaseApi {
|
||||
loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
OkHttpClient.Builder builder = new OkHttpClient()
|
||||
.newBuilder()
|
||||
|
||||
.addInterceptor(initQuery(isNeedUid,CommonAppContext.sInstance.getApplicationContext()))
|
||||
.addInterceptor(loggingInterceptor);
|
||||
|
||||
return create(builder.build(),
|
||||
GsonConverterFactory.create(gson), RxJava2CallAdapterFactory.create(), CommonAppConfig.HOST, PDLiveApi.class);
|
||||
}
|
||||
|
@ -324,11 +324,12 @@ public interface PDLiveApi {
|
||||
@Query("GroupId") String GroupId,
|
||||
@Query("stream") String stream
|
||||
);
|
||||
|
||||
/**
|
||||
* 加入房间推送Im欢迎语
|
||||
*/
|
||||
@GET("/api/public/?service=Tx.leaveRoomNew")
|
||||
Observable<ResponseModel<String>> leaveRoomNew(
|
||||
Observable<ResponseModel<List<Object>>> leaveRoomNew(
|
||||
@Query("GroupId") String GroupId,
|
||||
@Query("stream") String stream
|
||||
);
|
||||
|
@ -25,6 +25,7 @@ import com.yunbao.common.http.base.HttpCallback;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
@ -361,14 +362,17 @@ public class LiveNetManager {
|
||||
* @param city
|
||||
* @param callback
|
||||
*/
|
||||
private Disposable enterRoomDisposable = null;
|
||||
|
||||
public void enterRoomNew(String stream, String liveUid, String city, HttpCallback<EnterRoomNewModel> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
enterRoomDisposable = API.get().pdLiveApi(mContext)
|
||||
.enterRoomNew("g" + liveUid, stream, liveUid, city)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<EnterRoomNewModel>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<EnterRoomNewModel> enterRoomNewModelResponseModel) throws Exception {
|
||||
enterRoomDisposable = null;
|
||||
if (callback != null) {
|
||||
callback.onSuccess(enterRoomNewModelResponseModel.getData().getInfo());
|
||||
}
|
||||
@ -376,11 +380,12 @@ public class LiveNetManager {
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
enterRoomDisposable = null;
|
||||
if (callback != null) {
|
||||
callback.onError(throwable.getMessage());
|
||||
}
|
||||
}
|
||||
}).isDisposed();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -389,22 +394,24 @@ public class LiveNetManager {
|
||||
* @param stream
|
||||
* @param liveUid
|
||||
*/
|
||||
private Disposable userJoinDisposable = null;
|
||||
|
||||
public void userJoinRoomNew(String stream, String liveUid) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
userJoinDisposable = API.get().pdLiveApi(mContext)
|
||||
.userJoinRoomNew("g" + liveUid, stream)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<String>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<String> stringResponseModel) throws Exception {
|
||||
|
||||
userJoinDisposable = null;
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
|
||||
userJoinDisposable = null;
|
||||
}
|
||||
}).isDisposed();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -415,14 +422,14 @@ public class LiveNetManager {
|
||||
*/
|
||||
public void leaveRoomNew(String stream, String liveUid, HttpCallback<String> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.userJoinRoomNew("g" + liveUid, stream)
|
||||
.leaveRoomNew("g" + liveUid, stream)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<ResponseModel<String>>() {
|
||||
.subscribe(new Consumer<ResponseModel<List<Object>>>() {
|
||||
@Override
|
||||
public void accept(ResponseModel<String> stringResponseModel) throws Exception {
|
||||
public void accept(ResponseModel<List<Object>> listResponseModel) throws Exception {
|
||||
if (callback != null) {
|
||||
callback.onSuccess("");
|
||||
callback.onError("");
|
||||
}
|
||||
}
|
||||
}, new Consumer<Throwable>() {
|
||||
@ -434,4 +441,16 @@ public class LiveNetManager {
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间取消网络请求
|
||||
*/
|
||||
public void cancelLive() {
|
||||
if (userJoinDisposable != null) {
|
||||
userJoinDisposable.dispose();
|
||||
}
|
||||
if (enterRoomDisposable != null) {
|
||||
enterRoomDisposable.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -850,6 +850,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
mChatRecyclerView.setLayoutManager(layoutManager);
|
||||
mChatRecyclerView.addItemDecoration(new TopGradual());
|
||||
mLiveChatAdapter = new LiveChatAdapter(mContext);
|
||||
mChatRecyclerView.setAdapter(mLiveChatAdapter);
|
||||
mLiveChatAdapter.setOnItemClickListener(new OnItemClickListener<LiveChatBean>() {
|
||||
@Override
|
||||
public void onItemClick(LiveChatBean bean, int position) {
|
||||
@ -878,7 +879,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
}
|
||||
}
|
||||
});
|
||||
mChatRecyclerView.setAdapter(mLiveChatAdapter);
|
||||
|
||||
mChatRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
|
@ -273,6 +273,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
mLiveRoomViewHolder.setTitle(data.getTitle());
|
||||
mLiveRoomViewHolder.setAnchorGoodNumber(data.getGoodNum());
|
||||
mLiveRoomViewHolder.clearGuardIcon();
|
||||
mLiveRoomViewHolder.clearChat();
|
||||
mLiveRoomViewHolder.releaseGift();
|
||||
mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
|
||||
mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this);
|
||||
@ -294,7 +295,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
.enterRoomNew(mLiveBean.getStream(), mLiveBean.getUid(), mLiveBean.getCity(), new com.yunbao.common.http.base.HttpCallback<EnterRoomNewModel>() {
|
||||
@Override
|
||||
public void onSuccess(EnterRoomNewModel data) {
|
||||
mLiveRoomViewHolder.clearChat();
|
||||
|
||||
isEnterRoom = true;
|
||||
//加入房间发送Im消息
|
||||
LiveNetManager.get(mContext).userJoinRoomNew(mLiveBean.getStream(), mLiveBean.getUid());
|
||||
@ -527,6 +528,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
|
||||
@Override
|
||||
public void onRemove(boolean isQuit) {
|
||||
LiveNetManager.get(mContext).cancelLive();
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
|
||||
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
|
||||
|
Loading…
Reference in New Issue
Block a user