创建游戏,游戏界面完成

This commit is contained in:
18401019693 2023-09-25 11:25:03 +08:00
parent 37217e529e
commit 866024ae95
7 changed files with 220 additions and 7 deletions

View File

@ -18,10 +18,12 @@ public class SudTitleSelectAdapter extends RecyclerView.Adapter {
private List<String> selectString = new ArrayList<>(); private List<String> selectString = new ArrayList<>();
private int mIndex; private int mIndex;
private int mType;
public SudTitleSelectAdapter(List<String> selectString, int index) { public SudTitleSelectAdapter(List<String> selectString, int index, int type) {
this.selectString = selectString; this.selectString = selectString;
mIndex = index; mIndex = index;
mType = type;
} }
@NonNull @NonNull
@ -39,6 +41,7 @@ public class SudTitleSelectAdapter extends RecyclerView.Adapter {
public void onSudTitleSelectCallBack(int index) { public void onSudTitleSelectCallBack(int index) {
if (sudTitleSelectCallBack != null) { if (sudTitleSelectCallBack != null) {
sudTitleSelectCallBack.onSudTitleSelectCallBack(index); sudTitleSelectCallBack.onSudTitleSelectCallBack(index);
} }
} }
}); });

View File

@ -15,8 +15,10 @@ import com.lxj.xpopup.enums.PopupPosition;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudRoomListModel;
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.SudGameListSillEvent;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
@ -31,11 +33,12 @@ import java.util.List;
public class SudGameListPopup extends BottomPopupView { public class SudGameListPopup extends BottomPopupView {
private long interactionID = 0; private long interactionID = 0;
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>(); private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
private ImageView roomGameArrow; private ImageView roomGameArrow, roomSillArrow, houseOwnerArrow;
private TextView gameTitle; private TextView gameTitle, sillTitle, houseOwnerTitle;
private String id = "0", mLiveUid; private String id = "0", mLiveUid;
private int page = 0; private int page = 0;
private String mSill = "0,0", mSillName, roomHolderType = "0", roomHolderTypeName;
public SudGameListPopup(@NonNull Context context, long interactionID, List<CustomSidebarChildModel> child, String liveUid) { public SudGameListPopup(@NonNull Context context, long interactionID, List<CustomSidebarChildModel> child, String liveUid) {
super(context); super(context);
@ -62,7 +65,7 @@ public class SudGameListPopup extends BottomPopupView {
private void initDate() { private void initDate() {
LiveNetManager.get(getContext()) LiveNetManager.get(getContext())
.getRoomList(id, "0,0", "0", mLiveUid, page, new HttpCallback<List<SudRoomListModel>>() { .getRoomList(id, mSill, roomHolderType, mLiveUid, page, new HttpCallback<List<SudRoomListModel>>() {
@Override @Override
public void onSuccess(List<SudRoomListModel> data) { public void onSuccess(List<SudRoomListModel> data) {
@ -77,7 +80,11 @@ public class SudGameListPopup extends BottomPopupView {
private void initView() { private void initView() {
roomGameArrow = findViewById(R.id.room_game_arrow); roomGameArrow = findViewById(R.id.room_game_arrow);
roomSillArrow = findViewById(R.id.room_sill_arrow);
houseOwnerArrow = findViewById(R.id.house_owner_arrow);
gameTitle = findViewById(R.id.game_title); gameTitle = findViewById(R.id.game_title);
sillTitle = findViewById(R.id.room_sill_text);
houseOwnerTitle = findViewById(R.id.house_owner_text);
for (CustomSidebarChildModel model : customSidebarChildModels) { for (CustomSidebarChildModel model : customSidebarChildModels) {
if (TextUtils.equals(String.valueOf(interactionID), model.getSrc())) { if (TextUtils.equals(String.valueOf(interactionID), model.getSrc())) {
gameTitle.setText(model.getTitle().substring(0, 2)); gameTitle.setText(model.getTitle().substring(0, 2));
@ -101,6 +108,42 @@ public class SudGameListPopup extends BottomPopupView {
.show(); .show();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.room_sill), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
ObjectAnimator animator = ObjectAnimator.ofFloat(roomSillArrow, "rotation", 0f, 90f);
animator.setDuration(500);
animator.setInterpolator(new LinearInterpolator());
animator.start();
XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.room_sill));
builder.hasShadowBg(false)
.isDestroyOnDismiss(true)
.isLightStatusBar(false)
.popupPosition(PopupPosition.Bottom)
.asCustom(new SudGameListSelectPopup(getContext(), 1, mSillName))
.show();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.house_owner), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
ObjectAnimator animator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 0f, 90f);
animator.setDuration(500);
animator.setInterpolator(new LinearInterpolator());
animator.start();
XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.house_owner));
builder.hasShadowBg(false)
.isDestroyOnDismiss(true)
.isLightStatusBar(false)
.popupPosition(PopupPosition.Bottom)
.asCustom(new SudGameListSelectPopup(getContext(), 2, roomHolderTypeName))
.show();
} }
}); });
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_add), new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_add), new ViewClicksAntiShake.ViewClicksCallBack() {
@ -132,6 +175,40 @@ public class SudGameListPopup extends BottomPopupView {
animator.setDuration(500); animator.setDuration(500);
animator.setInterpolator(new LinearInterpolator()); animator.setInterpolator(new LinearInterpolator());
animator.start(); animator.start();
page=0;
initDate();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameListEvent(SudGameListSillEvent event) {
mSill = event.getSill();
mSillName = event.getSillName();
if (TextUtils.equals("0,0", mSill)) {
sillTitle.setText(mSillName);
} else {
sillTitle.setText(mSillName.substring(0, mSillName.length() - 2));
}
ObjectAnimator animator = ObjectAnimator.ofFloat(roomSillArrow, "rotation", 90f, 0f);
animator.setDuration(500);
animator.setInterpolator(new LinearInterpolator());
animator.start();
page=0;
initDate();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameListEvent(RoomHolderTypeEvent event) {
roomHolderType = event.getRoomHolderType();
roomHolderTypeName = event.getRoomHolderTypeName();
houseOwnerTitle.setText(roomHolderTypeName);
ObjectAnimator animator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 90f, 0f);
animator.setDuration(500);
animator.setInterpolator(new LinearInterpolator());
animator.start();
page=0;
initDate();
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)

View File

@ -13,23 +13,29 @@ import com.yunbao.common.R;
import com.yunbao.common.adapter.SudTitleSelectAdapter; import com.yunbao.common.adapter.SudTitleSelectAdapter;
import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.event.CreateSudGameEvent; import com.yunbao.common.event.CreateSudGameEvent;
import com.yunbao.common.event.RoomHolderTypeEvent;
import com.yunbao.common.event.SudGameListEvent; import com.yunbao.common.event.SudGameListEvent;
import com.yunbao.common.event.SudGameListSillEvent;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class SudGameListSelectPopup extends AttachPopupView { public class SudGameListSelectPopup extends AttachPopupView {
private int mType; private int mType;
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>(); private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
private List<String> selectString = new ArrayList<>(); private List<String> selectString = new ArrayList<>();
private Map<String, String> selectSill = new HashMap<>();
private TextView topSelect; private TextView topSelect;
private RecyclerView sudTitleSelect; private RecyclerView sudTitleSelect;
private SudTitleSelectAdapter sudTitleSelectAdapter; private SudTitleSelectAdapter sudTitleSelectAdapter;
private long interactionID = 0; private long interactionID = 0;
private String mSill;
public SudGameListSelectPopup(@NonNull Context context, int type, List<CustomSidebarChildModel> child, long interactionID) { public SudGameListSelectPopup(@NonNull Context context, int type, List<CustomSidebarChildModel> child, long interactionID) {
super(context); super(context);
@ -38,6 +44,13 @@ public class SudGameListSelectPopup extends AttachPopupView {
this.interactionID = interactionID; this.interactionID = interactionID;
} }
public SudGameListSelectPopup(@NonNull Context context, int mType, String sill) {
super(context);
this.mType = mType;
mSill = sill;
}
protected int getImplLayoutId() { protected int getImplLayoutId() {
return R.layout.view_sud_game_slelect; return R.layout.view_sud_game_slelect;
} }
@ -55,7 +68,7 @@ public class SudGameListSelectPopup extends AttachPopupView {
index = i; index = i;
} }
} }
sudTitleSelectAdapter = new SudTitleSelectAdapter(selectString, index); sudTitleSelectAdapter = new SudTitleSelectAdapter(selectString, index, mType);
sudTitleSelect.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); sudTitleSelect.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
sudTitleSelect.setAdapter(sudTitleSelectAdapter); sudTitleSelect.setAdapter(sudTitleSelectAdapter);
if (interactionID == 0) { if (interactionID == 0) {
@ -80,6 +93,62 @@ public class SudGameListSelectPopup extends AttachPopupView {
.setTitle(customSidebarChildModels.get(index).getTitle())); .setTitle(customSidebarChildModels.get(index).getTitle()));
} }
dialog.dismiss();
}
});
} else if (mType == 1) {
selectString.add(getContext().getString(R.string.interactive_game_create_unlimited));
selectString.add(getContext().getString(R.string.interactive_game_create_0_1));
selectString.add(getContext().getString(R.string.interactive_game_create_1_2));
selectString.add(getContext().getString(R.string.interactive_game_create_2_5));
selectString.add(getContext().getString(R.string.interactive_game_create_5));
selectSill.put(getContext().getString(R.string.interactive_game_create_unlimited), "0,0");
selectSill.put(getContext().getString(R.string.interactive_game_create_0_1), "0,1");
selectSill.put(getContext().getString(R.string.interactive_game_create_1_2), "1,2");
selectSill.put(getContext().getString(R.string.interactive_game_create_2_5), "2,5");
selectSill.put(getContext().getString(R.string.interactive_game_create_5), "5,0");
index = 0;
for (int i = 0; i < selectString.size(); i++) {
if (TextUtils.equals(mSill, selectString.get(i))) {
index = i;
}
}
sudTitleSelectAdapter = new SudTitleSelectAdapter(selectString, index, mType);
sudTitleSelect.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
sudTitleSelect.setAdapter(sudTitleSelectAdapter);
topSelect.setVisibility(GONE);
sudTitleSelectAdapter.setSudTitleSelectCallBack(new SudTitleSelectAdapter.SudTitleSelectCallBack() {
@Override
public void onSudTitleSelectCallBack(int index) {
String sillName = selectString.get(index);
String sill = selectSill.get(sillName);
Bus.get().post(new SudGameListSillEvent().setSill(sill).setSillName(sillName));
dialog.dismiss();
}
});
} else if (mType == 2) {
selectString.add(getContext().getString(R.string.interactive_game_create_unlimited));
selectString.add(getContext().getString(R.string.live_anchor));
selectString.add(getContext().getString(R.string.interactive_game_player));
selectSill.put(getContext().getString(R.string.interactive_game_create_unlimited), "0");
selectSill.put(getContext().getString(R.string.live_anchor), "1");
selectSill.put(getContext().getString(R.string.interactive_game_player), "2");
index = 0;
for (int i = 0; i < selectString.size(); i++) {
if (TextUtils.equals(mSill, selectString.get(i))) {
index = i;
}
}
sudTitleSelectAdapter = new SudTitleSelectAdapter(selectString, index, mType);
sudTitleSelect.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
sudTitleSelect.setAdapter(sudTitleSelectAdapter);
topSelect.setVisibility(GONE);
sudTitleSelectAdapter.setSudTitleSelectCallBack(new SudTitleSelectAdapter.SudTitleSelectCallBack() {
@Override
public void onSudTitleSelectCallBack(int index) {
String roomHolderTypeName = selectString.get(index);
String roomHolderType = selectSill.get(roomHolderTypeName);
Bus.get().post(new RoomHolderTypeEvent().setRoomHolderType(roomHolderType).setRoomHolderTypeName(roomHolderTypeName));
dialog.dismiss(); dialog.dismiss();
} }
}); });

View File

@ -0,0 +1,26 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
public class RoomHolderTypeEvent extends BaseModel {
private String roomHolderType;
private String roomHolderTypeName;
public String getRoomHolderType() {
return roomHolderType;
}
public RoomHolderTypeEvent setRoomHolderType(String roomHolderType) {
this.roomHolderType = roomHolderType;
return this;
}
public String getRoomHolderTypeName() {
return roomHolderTypeName;
}
public RoomHolderTypeEvent setRoomHolderTypeName(String roomHolderTypeName) {
this.roomHolderTypeName = roomHolderTypeName;
return this;
}
}

View File

@ -0,0 +1,26 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
public class SudGameListSillEvent extends BaseModel {
private String sillName;
private String sill;
public String getSillName() {
return sillName;
}
public SudGameListSillEvent setSillName(String sillName) {
this.sillName = sillName;
return this;
}
public String getSill() {
return sill;
}
public SudGameListSillEvent setSill(String sill) {
this.sill = sill;
return this;
}
}

View File

@ -103,21 +103,24 @@
android:textSize="14sp" /> android:textSize="14sp" />
<FrameLayout <FrameLayout
android:id="@+id/room_sill"
android:layout_width="74dp" android:layout_width="74dp"
android:layout_height="28dp" android:layout_height="28dp"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:background="@drawable/bg_live_sud_list_btn"> android:background="@drawable/bg_live_sud_list_btn">
<TextView <TextView
android:id="@+id/room_sill_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:text="2k-5k" android:text="@string/interactive_game_create_unlimited"
android:textColor="#fff" android:textColor="#fff"
android:textSize="14sp" /> android:textSize="14sp" />
<ImageView <ImageView
android:id="@+id/room_sill_arrow"
android:layout_width="8dp" android:layout_width="8dp"
android:layout_height="14dp" android:layout_height="14dp"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
@ -134,6 +137,7 @@
android:textSize="14sp" /> android:textSize="14sp" />
<LinearLayout <LinearLayout
android:id="@+id/house_owner"
android:layout_width="58dp" android:layout_width="58dp"
android:layout_height="28dp" android:layout_height="28dp"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
@ -141,14 +145,16 @@
android:gravity="center_vertical"> android:gravity="center_vertical">
<TextView <TextView
android:id="@+id/house_owner_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:text="@string/interactive_game_room_game_all" android:text="@string/interactive_game_create_unlimited"
android:textColor="#fff" android:textColor="#fff"
android:textSize="14sp" /> android:textSize="14sp" />
<ImageView <ImageView
android:id="@+id/house_owner_arrow"
android:layout_width="8dp" android:layout_width="8dp"
android:layout_height="14dp" android:layout_height="14dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"

View File

@ -1336,4 +1336,10 @@ Limited ride And limited avatar frame</string>
<string name="interactive_game_create_game_sill">游戲門檻:</string> <string name="interactive_game_create_game_sill">游戲門檻:</string>
<string name="interactive_game_create_game_select">請選擇游戲</string> <string name="interactive_game_create_game_select">請選擇游戲</string>
<string name="interactive_game_create_gold_bean_quantity">請選擇金豆數量</string> <string name="interactive_game_create_gold_bean_quantity">請選擇金豆數量</string>
<string name="interactive_game_create_unlimited">不限</string>
<string name="interactive_game_create_0_1">0K-1K金豆</string>
<string name="interactive_game_create_1_2">1K-2K金豆</string>
<string name="interactive_game_create_2_5">2K-5K金豆</string>
<string name="interactive_game_create_5">5K以上金豆</string>
<string name="interactive_game_player">玩家</string>
</resources> </resources>