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