添加游戏列表点击查询游戏状态

This commit is contained in:
18401019693 2023-10-06 10:01:39 +08:00
parent c1d6b67322
commit 2d7684a5c8
12 changed files with 127 additions and 48 deletions

View File

@ -25,6 +25,7 @@ import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.RoomHolderTypeEvent;
import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.event.SudGameListDissMissEvent;
import com.yunbao.common.event.SudGameListEvent; import com.yunbao.common.event.SudGameListEvent;
import com.yunbao.common.event.SudGameListRefreshEvent;
import com.yunbao.common.event.SudGameListSillEvent; import com.yunbao.common.event.SudGameListSillEvent;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.LiveHttpUtil;
@ -320,6 +321,10 @@ public class SudGameListPopup extends BottomPopupView {
public void onSudGameListDissMissEvent(SudGameListDissMissEvent event) { public void onSudGameListDissMissEvent(SudGameListDissMissEvent event) {
dialog.dismiss(); dialog.dismiss();
} }
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameListRefreshEvent(SudGameListRefreshEvent event) {
mRefreshView.initData();
}
} }

View File

@ -0,0 +1,6 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
public class SudGameListRefreshEvent extends BaseModel {
}

View File

@ -1028,5 +1028,10 @@ public interface PDLiveApi {
Observable<ResponseModel<CreateSudRoomModel>> randomRoom( Observable<ResponseModel<CreateSudRoomModel>> randomRoom(
); );
@GET("/api/public/?service=Sudgameserver.checkRoomStatus")
Observable<ResponseModel<CreateSudRoomModel>> checkRoomStatus(
@Query("room_id") String roomId
);
} }

View File

@ -2268,6 +2268,28 @@ public class LiveNetManager {
}).isDisposed(); }).isDisposed();
} }
public void checkRoomStatus(String roomId, HttpCallback<CreateSudRoomModel> callback) {
API.get().pdLiveApi(mContext)
.checkRoomStatus(roomId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<CreateSudRoomModel>>() {
@Override
public void accept(ResponseModel<CreateSudRoomModel> createSudRoomModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(createSudRoomModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@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<List<SudRoomListModel>> callback) { public void getRoomList(String sudGameId, String threshold, String roomHolderType, String liveUid, int page, HttpCallback<List<SudRoomListModel>> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.getRoomList(sudGameId, threshold, roomHolderType, liveUid, page) .getRoomList(sudGameId, threshold, roomHolderType, liveUid, page)

View File

@ -18,18 +18,20 @@ import com.yunbao.common.activity.SudGameActivity;
import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudRoomListModel;
import com.yunbao.common.bean.playerObject;
import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.event.SudGameListDissMissEvent;
import com.yunbao.common.event.SudGameListRefreshEvent;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.List; import java.util.Locale;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
@ -38,7 +40,7 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
private TextView roomName, playerWeAre, playerWeAre2, goldenBeanNumber; private TextView roomName, playerWeAre, playerWeAre2, goldenBeanNumber;
private RoundedImageView avatarList1, avatarList2, avatarList3, avatarList4, avatarList5; private RoundedImageView avatarList1, avatarList2, avatarList3, avatarList4, avatarList5;
private GifImageView gifImageView; private GifImageView gifImageView;
private ImageView sex,game_icon; private ImageView sex, game_icon;
public SudGameListViewHolder(@NonNull View itemView) { 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() { ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.layout), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel(); LiveNetManager.get(itemView.getContext()).checkRoomStatus(model.getId(), new com.yunbao.common.http.base.HttpCallback<CreateSudRoomModel>() {
createSudRoomModel.setSudGameId(model.getSudGameId()); @Override
createSudRoomModel.setSudGameRoomId(model.getSudGameRoomId()); public void onSuccess(CreateSudRoomModel data) {
createSudRoomModel.setAvatar(model.getAvatar()); if (TextUtils.equals(data.getRoomStatus(), "0")) {
createSudRoomModel.setRoomName(model.getRoomName()); if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
createSudRoomModel.setSudGameName(model.getSudGameName()); ToastUtil.show("房间不存在");
if (isHome) { } else {
if (TextUtils.equals(model.getLiveUid(), "0")) { ToastUtil.show("The room does not exist");
Intent intent = new Intent(itemView.getContext(), SudGameActivity.class); }
intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); Bus.get().post(new SudGameListRefreshEvent());
itemView.getContext().startActivity(intent); } else {
} else { CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel();
LiveHttpUtil.getLiveInfo(model.getLiveUid() + "", new HttpCallback() { createSudRoomModel.setSudGameId(model.getSudGameId());
@Override createSudRoomModel.setSudGameRoomId(model.getSudGameRoomId());
public void onSuccess(int code, String msg, String[] info) { createSudRoomModel.setAvatar(model.getAvatar());
if (code == 0 && info.length > 0) { createSudRoomModel.setRoomName(model.getRoomName());
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); createSudRoomModel.setSudGameName(model.getSudGameName());
new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { 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 @Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { public void onSuccess(int code, String msg, String[] info) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); if (code == 0 && info.length > 0) {
IMLoginManager.get(itemView.getContext()).setSudGame(new Gson().toJson(createSudRoomModel)); 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 @Override
public void onCheckError(String contextError) { 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 { @Override
new XPopup.Builder(itemView.getContext()) public void onError(String error) {
.enableDrag(false) ToastUtil.show(error);
.dismissOnTouchOutside(false) }
.dismissOnBackPressed(false) });
.asCustom(new LiveSudGamePopup(itemView.getContext(), createSudRoomModel))
.show();
Bus.get().post(new SudGameListDissMissEvent());
}
} }
}); });

View File

@ -97,30 +97,38 @@
android:layout_marginTop="10dp" /> android:layout_marginTop="10dp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/layout_history_empty" android:id="@+id/layout_history_empty"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="80dp"
android:src="@mipmap/icon_attention_noanchor" />
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/bg_home_search_not" android:layout_marginTop="20dp"
android:gravity="center" android:gravity="center"
android:paddingStart="30dp" android:paddingStart="30dp"
android:paddingTop="12dp" android:paddingTop="12dp"
android:paddingEnd="30dp" android:paddingEnd="30dp"
android:paddingBottom="12dp" android:paddingBottom="12dp"
android:text="@string/interactive_game_search_room_have_been_found" android:text="@string/interactive_game_search_room_have_been_found"
android:textColor="#CCFFFFFF" android:textColorHint="#000"
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_room" android:id="@+id/list_room"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -111,16 +111,22 @@
<LinearLayout <LinearLayout
android:id="@+id/layout_history_empty" android:id="@+id/layout_history_empty"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="80dp"
android:src="@mipmap/icon_attention_noanchor" />
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:background="@drawable/bg_home_search_not"
android:gravity="center" android:gravity="center"
android:paddingStart="30dp" android:paddingStart="30dp"
android:paddingTop="12dp" android:paddingTop="12dp"

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -1341,5 +1341,5 @@
<string name="interactive_game_search_room">搜索房間</string> <string name="interactive_game_search_room">搜索房間</string>
<string name="interactive_game_search_history">搜索历史</string> <string name="interactive_game_search_history">搜索历史</string>
<string name="interactive_game_search_room_name_input">請輸入您要搜索的房主昵稱、房主ID或房間名</string> <string name="interactive_game_search_room_name_input">請輸入您要搜索的房主昵稱、房主ID或房間名</string>
<string name="interactive_game_search_room_have_been_found">暫未搜索結果~</string> <string name="interactive_game_search_room_have_been_found">不存在此房间</string>
</resources> </resources>

View File

@ -1340,5 +1340,5 @@
<string name="interactive_game_search_room">搜索房間</string> <string name="interactive_game_search_room">搜索房間</string>
<string name="interactive_game_search_history">搜索历史</string> <string name="interactive_game_search_history">搜索历史</string>
<string name="interactive_game_search_room_name_input">請輸入您要搜索的房主昵稱、房主ID或房間名</string> <string name="interactive_game_search_room_name_input">請輸入您要搜索的房主昵稱、房主ID或房間名</string>
<string name="interactive_game_search_room_have_been_found">暫未搜索結果~</string> <string name="interactive_game_search_room_have_been_found">不存在此房间</string>
</resources> </resources>

View File

@ -1341,6 +1341,6 @@
<string name="interactive_game_search_room">搜索房間</string> <string name="interactive_game_search_room">搜索房間</string>
<string name="interactive_game_search_history">搜索历史</string> <string name="interactive_game_search_history">搜索历史</string>
<string name="interactive_game_search_room_name_input">請輸入您要搜索的房主昵稱、房主ID或房間名</string> <string name="interactive_game_search_room_name_input">請輸入您要搜索的房主昵稱、房主ID或房間名</string>
<string name="interactive_game_search_room_have_been_found">暫未搜索結果~</string> <string name="interactive_game_search_room_have_been_found">不存在此房间</string>
</resources> </resources>

View File

@ -30,6 +30,7 @@ import com.yunbao.common.dialog.SudGameListSelectPopup;
import com.yunbao.common.dialog.SudGameSearchDialogPopup; import com.yunbao.common.dialog.SudGameSearchDialogPopup;
import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.RoomHolderTypeEvent;
import com.yunbao.common.event.SudGameListEvent; import com.yunbao.common.event.SudGameListEvent;
import com.yunbao.common.event.SudGameListRefreshEvent;
import com.yunbao.common.event.SudGameListSillEvent; import com.yunbao.common.event.SudGameListSillEvent;
import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
@ -386,4 +387,8 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
} }
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameListRefreshEvent(SudGameListRefreshEvent event) {
mRefreshView.initData();
}
} }