diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java index 9c29d84be..d0d4c9bd3 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java @@ -25,6 +25,7 @@ import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.event.SudGameListEvent; +import com.yunbao.common.event.SudGameListRefreshEvent; import com.yunbao.common.event.SudGameListSillEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.LiveHttpUtil; @@ -320,6 +321,10 @@ public class SudGameListPopup extends BottomPopupView { public void onSudGameListDissMissEvent(SudGameListDissMissEvent event) { dialog.dismiss(); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameListRefreshEvent(SudGameListRefreshEvent event) { + mRefreshView.initData(); + } } diff --git a/common/src/main/java/com/yunbao/common/event/SudGameListRefreshEvent.java b/common/src/main/java/com/yunbao/common/event/SudGameListRefreshEvent.java new file mode 100644 index 000000000..b7a4ed188 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/SudGameListRefreshEvent.java @@ -0,0 +1,6 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class SudGameListRefreshEvent extends BaseModel { +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 328ef607c..1d283e0b8 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1028,5 +1028,10 @@ public interface PDLiveApi { Observable> randomRoom( ); + @GET("/api/public/?service=Sudgameserver.checkRoomStatus") + Observable> checkRoomStatus( + @Query("room_id") String roomId + ); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 4d34a996d..aa3336c3e 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -2268,6 +2268,28 @@ public class LiveNetManager { }).isDisposed(); } + public void checkRoomStatus(String roomId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .checkRoomStatus(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel createSudRoomModelResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(createSudRoomModelResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void getRoomList(String sudGameId, String threshold, String roomHolderType, String liveUid, int page, HttpCallback> callback) { API.get().pdLiveApi(mContext) .getRoomList(sudGameId, threshold, roomHolderType, liveUid, page) diff --git a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java index 40405986d..3074178c6 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java @@ -18,18 +18,20 @@ import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.SudRoomListModel; -import com.yunbao.common.bean.playerObject; import com.yunbao.common.event.SudGameListDissMissEvent; +import com.yunbao.common.event.SudGameListRefreshEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; -import java.util.List; +import java.util.Locale; import pl.droidsonroids.gif.GifImageView; @@ -38,7 +40,7 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { private TextView roomName, playerWeAre, playerWeAre2, goldenBeanNumber; private RoundedImageView avatarList1, avatarList2, avatarList3, avatarList4, avatarList5; private GifImageView gifImageView; - private ImageView sex,game_icon; + private ImageView sex, game_icon; public SudGameListViewHolder(@NonNull View itemView) { @@ -104,52 +106,72 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.layout), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel(); - createSudRoomModel.setSudGameId(model.getSudGameId()); - createSudRoomModel.setSudGameRoomId(model.getSudGameRoomId()); - createSudRoomModel.setAvatar(model.getAvatar()); - createSudRoomModel.setRoomName(model.getRoomName()); - createSudRoomModel.setSudGameName(model.getSudGameName()); - if (isHome) { - if (TextUtils.equals(model.getLiveUid(), "0")) { - Intent intent = new Intent(itemView.getContext(), SudGameActivity.class); - intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); - itemView.getContext().startActivity(intent); - } else { - LiveHttpUtil.getLiveInfo(model.getLiveUid() + "", new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); - new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + LiveNetManager.get(itemView.getContext()).checkRoomStatus(model.getId(), new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(CreateSudRoomModel data) { + if (TextUtils.equals(data.getRoomStatus(), "0")) { + if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("房间不存在"); + } else { + ToastUtil.show("The room does not exist"); + } + Bus.get().post(new SudGameListRefreshEvent()); + } else { + CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel(); + createSudRoomModel.setSudGameId(model.getSudGameId()); + createSudRoomModel.setSudGameRoomId(model.getSudGameRoomId()); + createSudRoomModel.setAvatar(model.getAvatar()); + createSudRoomModel.setRoomName(model.getRoomName()); + createSudRoomModel.setSudGameName(model.getSudGameName()); + if (isHome) { + if (TextUtils.equals(model.getLiveUid(), "0")) { + Intent intent = new Intent(itemView.getContext(), SudGameActivity.class); + intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); + itemView.getContext().startActivity(intent); + } else { + LiveHttpUtil.getLiveInfo(model.getLiveUid() + "", new HttpCallback() { @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); - IMLoginManager.get(itemView.getContext()).setSudGame(new Gson().toJson(createSudRoomModel)); - } + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + @Override + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); + IMLoginManager.get(itemView.getContext()).setSudGame(new Gson().toJson(createSudRoomModel)); + } - @Override - public void onCheckError(String contextError) { + @Override + public void onCheckError(String contextError) { + } + }); + } else { + RouteUtil.forwardUserHome(itemView.getContext(), model.getLiveUid(), 0); + } } }); - } else { - RouteUtil.forwardUserHome(itemView.getContext(), model.getLiveUid(), 0); } + + } else { + new XPopup.Builder(itemView.getContext()) + .enableDrag(false) + .dismissOnTouchOutside(false) + .dismissOnBackPressed(false) + .asCustom(new LiveSudGamePopup(itemView.getContext(), createSudRoomModel)) + .show(); + + Bus.get().post(new SudGameListDissMissEvent()); } - }); + } } - } else { - new XPopup.Builder(itemView.getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(itemView.getContext(), createSudRoomModel)) - .show(); + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); - Bus.get().post(new SudGameListDissMissEvent()); - } } }); diff --git a/common/src/main/res/layout/dialog_home_search_sud_game.xml b/common/src/main/res/layout/dialog_home_search_sud_game.xml index 9dbafb0a2..50a8d0fe9 100644 --- a/common/src/main/res/layout/dialog_home_search_sud_game.xml +++ b/common/src/main/res/layout/dialog_home_search_sud_game.xml @@ -97,30 +97,38 @@ android:layout_marginTop="10dp" /> - + + + + + + 搜索房間 搜索历史 請輸入您要搜索的房主昵稱、房主ID或房間名 - 暫未搜索結果~ + 不存在此房间 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index 9ebbfecbc..cfbf450c0 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1340,5 +1340,5 @@ 搜索房間 搜索历史 請輸入您要搜索的房主昵稱、房主ID或房間名 - 暫未搜索結果~ + 不存在此房间 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 29922b393..4789631f8 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1341,6 +1341,6 @@ 搜索房間 搜索历史 請輸入您要搜索的房主昵稱、房主ID或房間名 - 暫未搜索結果~ + 不存在此房间 diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java index a70963f5a..169398816 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java @@ -30,6 +30,7 @@ import com.yunbao.common.dialog.SudGameListSelectPopup; import com.yunbao.common.dialog.SudGameSearchDialogPopup; import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.SudGameListEvent; +import com.yunbao.common.event.SudGameListRefreshEvent; import com.yunbao.common.event.SudGameListSillEvent; import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.base.HttpCallback; @@ -386,4 +387,8 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement public void onPause() { super.onPause(); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameListRefreshEvent(SudGameListRefreshEvent event) { + mRefreshView.initData(); + } }