游戏部分功能修改完成

This commit is contained in:
ningwenqiang
2024-10-31 16:47:55 +08:00
parent af0cb7babe
commit 71277bc75d
141 changed files with 839 additions and 127 deletions

View File

@@ -12,11 +12,13 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.adapter.GameTypeItemAdapter;
import com.yunbao.live.activity.SudSwGameActivity;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.adapter.SudGameListAdapter;
@@ -62,6 +64,7 @@ import java.util.Locale;
public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener<LiveBean> {
private CommonRefreshView mRefreshView;
private RecyclerView topTitleRecyclerView;
private ImageView roomGameArrow, roomSillArrow, houseOwnerArrow;
private TextView gameTitle, sillTitle, houseOwnerTitle;
private long interactionID = 0;
@@ -70,6 +73,8 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
private long animDuration = 500;
private String id = "0";
private SudGameListAdapter sudGameListAdapter;
private GameTypeItemAdapter GameTypeAdapter;
private AbsActivity context;
public MainHomeGameViewHolder(AbsActivity context, ViewGroup parentView) {
@@ -80,7 +85,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
@Override
protected int getLayoutId() {
return R.layout.view_main_home_sud_game_list;
return R.layout.view_main_home_sud_game_list2;
}
@@ -91,10 +96,10 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
mSill = "0,0,0";
roomHolderType = "0";
id = "0";
roomGameArrow = (ImageView) findViewById(R.id.room_game_arrow);
// roomGameArrow = (ImageView) findViewById(R.id.room_game_arrow);
roomSillArrow = (ImageView) findViewById(R.id.room_sill_arrow);
houseOwnerArrow = (ImageView) findViewById(R.id.house_owner_arrow);
gameTitle = (TextView) findViewById(R.id.game_title);
// gameTitle = (TextView) findViewById(R.id.game_title);
sillTitle = (TextView) findViewById(R.id.room_sill_text);
houseOwnerTitle = (TextView) findViewById(R.id.house_owner_text);
mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView);
@@ -102,6 +107,8 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
sudGameListAdapter = new SudGameListAdapter(mContext, true);
mRefreshView.setLoadMoreEnable(true);
mRefreshView.setRecyclerViewAdapter(sudGameListAdapter);
topTitleRecyclerView = findViewById(R.id.topTitleRecyclerView);
topTitleRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<SudRoomListModel>() {
@Override
public RefreshAdapter<SudRoomListModel> getAdapter() {
@@ -150,87 +157,87 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
});
mRefreshView.initData();
mRefreshView.setEmptyLayoutId(R.layout.sud_no_data);
ViewClicksAntiShake.clicksAntiShake(findViewById(com.yunbao.common.R.id.random_start), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
LiveNetManager.get(mContext)
.randomRoom(id, mSill, roomHolderType, new com.yunbao.common.http.base.HttpCallback<CreateSudRoomModel>() {
@Override
public void onSuccess(CreateSudRoomModel data) {
if (data != null) {
Intent intent = new Intent(context, SudSwGameActivity.class);
intent.putExtra("CreateSudRoom", new Gson().toJson(data));
context.startActivity(intent);
} else {
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("当前没有可加入的房间");
} else {
ToastUtil.show("There are currently no rooms to join");
}
}
}
@Override
public void onError(String error) {
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("当前没有可加入的房间");
} else {
ToastUtil.show("There are currently no rooms to join");
}
}
});
// List<SudRoomListModel> sudRoomListModels = sudGameListAdapter.getList();
// if (sudRoomListModels.size() > 1) {
// int random = RandomUtil.nextInt(sudRoomListModels.size() - 1);
// CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel();
// createSudRoomModel.setSudGameId(sudRoomListModels.get(random).getSudGameId());
// createSudRoomModel.setSudGameRoomId(sudRoomListModels.get(random).getSudGameRoomId());
// createSudRoomModel.setAvatar(sudRoomListModels.get(random).getAvatar());
// createSudRoomModel.setRoomName(sudRoomListModels.get(random).getRoomName());
// createSudRoomModel.setSudGameName(sudRoomListModels.get(random).getSudGameName());
// new XPopup.Builder(mContext)
// .enableDrag(false)
// .dismissOnTouchOutside(false)
// .dismissOnBackPressed(false)
// .asCustom(new LiveSudGamePopup(mContext, createSudRoomModel))
// .show();
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_room_game), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 0f, 90f);
animator.setDuration(animDuration);
animator.setInterpolator(new LinearInterpolator());
animator.start();
XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.interactive_game_room_game));
builder.hasShadowBg(false)
.isDestroyOnDismiss(true)
.isLightStatusBar(false)
.popupPosition(PopupPosition.Bottom)
.asCustom(new SudGameListSelectPopup(mContext, 0, customSidebarChildModels, interactionID)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
closeAnimSudGameListEvent();
}
})
)
.show();
}
});
// ViewClicksAntiShake.clicksAntiShake(findViewById(com.yunbao.common.R.id.random_start), new ViewClicksAntiShake.ViewClicksCallBack() {
// @Override
// public void onViewClicks() {
// LiveNetManager.get(mContext)
// .randomRoom(id, mSill, roomHolderType, new com.yunbao.common.http.base.HttpCallback<CreateSudRoomModel>() {
// @Override
// public void onSuccess(CreateSudRoomModel data) {
// if (data != null) {
// Intent intent = new Intent(context, SudSwGameActivity.class);
// intent.putExtra("CreateSudRoom", new Gson().toJson(data));
// context.startActivity(intent);
// } else {
// if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
// ToastUtil.show("当前没有可加入的房间");
// } else {
// ToastUtil.show("There are currently no rooms to join");
// }
// }
// }
//
// @Override
// public void onError(String error) {
// if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
// ToastUtil.show("当前没有可加入的房间");
// } else {
// ToastUtil.show("There are currently no rooms to join");
// }
// }
// });
//// List<SudRoomListModel> sudRoomListModels = sudGameListAdapter.getList();
//// if (sudRoomListModels.size() > 1) {
//// int random = RandomUtil.nextInt(sudRoomListModels.size() - 1);
//// CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel();
//// createSudRoomModel.setSudGameId(sudRoomListModels.get(random).getSudGameId());
//// createSudRoomModel.setSudGameRoomId(sudRoomListModels.get(random).getSudGameRoomId());
//// createSudRoomModel.setAvatar(sudRoomListModels.get(random).getAvatar());
//// createSudRoomModel.setRoomName(sudRoomListModels.get(random).getRoomName());
//// createSudRoomModel.setSudGameName(sudRoomListModels.get(random).getSudGameName());
//
//// new XPopup.Builder(mContext)
//// .enableDrag(false)
//// .dismissOnTouchOutside(false)
//// .dismissOnBackPressed(false)
//// .asCustom(new LiveSudGamePopup(mContext, createSudRoomModel))
//// .show();
//
//
// }
// });
// ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_room_game), new ViewClicksAntiShake.ViewClicksCallBack() {
// @Override
// public void onViewClicks() {
// ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 0f, 90f);
// animator.setDuration(animDuration);
// animator.setInterpolator(new LinearInterpolator());
// animator.start();
// XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.interactive_game_room_game));
// builder.hasShadowBg(false)
// .isDestroyOnDismiss(true)
// .isLightStatusBar(false)
// .popupPosition(PopupPosition.Bottom)
// .asCustom(new SudGameListSelectPopup(mContext, 0, customSidebarChildModels, interactionID)
// .setOnDismissListener(new DialogInterface.OnDismissListener() {
// @Override
// public void onDismiss(DialogInterface dialog) {
// closeAnimSudGameListEvent();
// }
// })
// )
// .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(animDuration);
animator.setInterpolator(new LinearInterpolator());
animator.start();
// ObjectAnimator animator = ObjectAnimator.ofFloat(roomSillArrow, "scaleX", 1f, -1f);
// animator.setDuration(animDuration);
// animator.setInterpolator(new LinearInterpolator());
// animator.start();
XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.room_sill));
builder.hasShadowBg(false)
.isDestroyOnDismiss(true)
@@ -247,10 +254,10 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.house_owner), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
ObjectAnimator animator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 0f, 90f);
animator.setDuration(animDuration);
animator.setInterpolator(new LinearInterpolator());
animator.start();
// ObjectAnimator animator = ObjectAnimator.ofFloat(roomSillArrow, "scaleX", 1f, -1f);
// animator.setDuration(animDuration);
// animator.setInterpolator(new LinearInterpolator());
// animator.start();
XPopup.Builder builder = new XPopup.Builder(mContext).atView(findViewById(com.yunbao.common.R.id.house_owner));
builder.hasShadowBg(false)
.isDestroyOnDismiss(true)
@@ -298,6 +305,8 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
for (CustomSidebarInfoModel datum : data) {
if (datum.getType().equals("6")) {
customSidebarChildModels = datum.getChild();
GameTypeAdapter=new GameTypeItemAdapter(customSidebarChildModels,mContext);
topTitleRecyclerView.setAdapter(GameTypeAdapter);
return;
}
}
@@ -308,15 +317,15 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_rule), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
new XPopup.Builder(mContext)
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
.asCustom(new SudGameRulePopup(mContext)).show();
}
});
// ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_rule), new ViewClicksAntiShake.ViewClicksCallBack() {
// @Override
// public void onViewClicks() {
// new XPopup.Builder(mContext)
// .enableDrag(false)
// .maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
// .asCustom(new SudGameRulePopup(mContext)).show();
// }
// });
}
private void initData() {
@@ -327,20 +336,20 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSudGameListEvent(SudGameListEvent event) {
interactionID = event.getInteractionID();
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
gameTitle.setText(event.getTitle());
} else {
if (event.getTitle().contains("All")) {
gameTitle.setText("All");
} else {
if ((event.getTitle().length() > 6)) {
gameTitle.setText(event.getTitle());
} else {
gameTitle.setText(event.getTitle());
}
}
}
// if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
// gameTitle.setText(event.getTitle());
// } else {
// if (event.getTitle().contains("All")) {
// gameTitle.setText("All");
// } else {
// if ((event.getTitle().length() > 6)) {
// gameTitle.setText(event.getTitle());
// } else {
// gameTitle.setText(event.getTitle());
// }
//
// }
// }
id = event.getId();
mRefreshView.initData();
@@ -370,24 +379,24 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
}
private void closeAnimSudGameListEvent() {
ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 90f, 0f);
animator.setDuration(animDuration);
animator.setInterpolator(new LinearInterpolator());
animator.start();
// ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 90f, 0f);
// animator.setDuration(animDuration);
// animator.setInterpolator(new LinearInterpolator());
// animator.start();
}
private void closeAnimSudGameListSillEvent() {
ObjectAnimator backAnimator = ObjectAnimator.ofFloat(roomSillArrow, "rotation", 90f, 0f);
backAnimator.setDuration(animDuration);
backAnimator.setInterpolator(new LinearInterpolator());
backAnimator.start();
// ObjectAnimator backAnimator = ObjectAnimator.ofFloat(roomSillArrow, "scaleX", -1f, 1f);
// backAnimator.setDuration(animDuration);
// backAnimator.setInterpolator(new LinearInterpolator());
// backAnimator.start();
}
private void closeAnimRoomHolderTypeEvent() {
ObjectAnimator backAnimator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 90f, 0f);
backAnimator.setDuration(animDuration);
backAnimator.setInterpolator(new LinearInterpolator());
backAnimator.start();
// ObjectAnimator backAnimator = ObjectAnimator.ofFloat(roomSillArrow, "scaleX", -1f, 1f);
// backAnimator.setDuration(animDuration);
// backAnimator.setInterpolator(new LinearInterpolator());
// backAnimator.start();
}

View File

@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg_main_home_sub_game"
android:orientation="vertical">
<TextView
android:id="@+id/meTitleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="34dp"
android:text="@string/game"
android:textColor="@color/color_111111"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:padding="6dp"
android:src="@mipmap/ic_yola_search"
app:layout_constraintBottom_toBottomOf="@+id/meTitleTv"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/meTitleTv" />
<ImageView
android:id="@+id/interactive_game_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:padding="6dp"
android:src="@mipmap/ic_yola_game_create"
app:layout_constraintBottom_toBottomOf="@+id/meTitleTv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/meTitleTv" />
<ImageView
android:id="@+id/sud_history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:padding="6dp"
android:src="@mipmap/ic_yola_game_record"
app:layout_constraintBottom_toBottomOf="@+id/meTitleTv"
app:layout_constraintEnd_toStartOf="@+id/interactive_game_add"
app:layout_constraintTop_toTopOf="@+id/meTitleTv" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/topTitleRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/meTitleTv"
tools:itemCount="3" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:src="@mipmap/ic_yola_game_line"
app:layout_constraintBottom_toBottomOf="@+id/hall"
app:layout_constraintEnd_toEndOf="@+id/hall"
app:layout_constraintStart_toStartOf="@+id/hall" />
<TextView
android:id="@+id/hall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/game_hall"
android:textColor="@color/color_111111"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topTitleRecyclerView" />
<View
android:id="@+id/house_owner"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_white_radius17"
app:layout_constraintBottom_toBottomOf="@id/house_owner_text"
app:layout_constraintEnd_toEndOf="@+id/house_owner_arrow"
app:layout_constraintStart_toStartOf="@+id/house_owner_text"
app:layout_constraintTop_toTopOf="@+id/house_owner_text" />
<ImageView
android:id="@+id/house_owner_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:paddingEnd="8dp"
android:src="@mipmap/ic_yola_game_bot_arrow"
app:layout_constraintBottom_toBottomOf="@id/hall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/hall" />
<TextView
android:id="@+id/house_owner_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:minEms="4"
android:paddingBottom="4dp"
android:text="@string/unrestricted_players"
android:textColor="#777777"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@id/hall"
app:layout_constraintEnd_toStartOf="@+id/house_owner_arrow"
app:layout_constraintTop_toTopOf="@+id/hall" />
<View
android:id="@+id/room_sill"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_white_radius17"
app:layout_constraintBottom_toBottomOf="@id/room_sill_text"
app:layout_constraintEnd_toEndOf="@+id/room_sill_arrow"
app:layout_constraintStart_toStartOf="@+id/room_sill_text"
app:layout_constraintTop_toTopOf="@+id/room_sill_text" />
<ImageView
android:id="@+id/room_sill_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:paddingEnd="8dp"
android:src="@mipmap/ic_yola_game_bot_arrow"
app:layout_constraintBottom_toBottomOf="@id/hall"
app:layout_constraintEnd_toStartOf="@+id/house_owner"
app:layout_constraintTop_toTopOf="@+id/hall" />
<TextView
android:id="@+id/room_sill_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:text="@string/unlimited_threshold"
android:minEms="4"
android:textColor="#777777"
android:textSize="11sp"
app:layout_constraintBottom_toBottomOf="@id/hall"
app:layout_constraintEnd_toStartOf="@+id/room_sill_arrow"
app:layout_constraintTop_toTopOf="@+id/hall" />
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/hall"
app:layout_goneMarginTop="8dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -108,7 +108,5 @@
<string name="live_room_sud_hint_join">Join</string>
<string name="live_dialog_top_guardian_tasks">Guard tasks</string>
<string name="game">game</string>
<string name="user_rights">用戶權益</string>
<string name="creation_center">創作中心</string>
<string name="other_functions">其他功能</string>
</resources>