From 79fa6be3132e489b1454c87ee302fe6ea08ca32d Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Tue, 26 Sep 2023 16:05:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=8F=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/AndroidManifest.xml | 48 +++---- .../common/activity/SudGameActivity.java | 82 ++++++++++++ .../common/adapter/SudGameListAdapter.java | 2 +- .../adapter/SudHomeGameListAdapter.java | 2 +- .../common/dialog/CreateSudGamePopup.java | 30 +++-- .../common/dialog/SudGameListPopup.java | 2 +- .../common/views/SudGameListViewHolder.java | 26 ++-- .../src/main/res/layout/activity_sud_game.xml | 124 ++++++++++++++++++ .../main/views/MainHomeGameViewHolder.java | 26 ++-- .../yunbao/main/views/MainHomeViewHolder.java | 3 +- 10 files changed, 291 insertions(+), 54 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/activity/SudGameActivity.java create mode 100644 common/src/main/res/layout/activity_sud_game.xml diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index c1c7b4e46..d9bf690aa 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -1,16 +1,15 @@ - - - + + + - - - + + + - + 支付宝 + + + 支付宝 end + --> + () { + @Override + public void onChanged(View view) { + if (view == null) { // 在关闭游戏时,把游戏View给移除 + gameContainer.removeAllViews(); + } else { // 把游戏View添加到容器内 + gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); + } + } + }); + // 加载游戏,参数定义可查看BaseGameViewModel.switchGame()方法注释 + // 游戏配置 + GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel(); + gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值 + gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值 + // SudMGP平台64bit游戏ID + gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID); + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java index 8b43ab516..027340dd4 100644 --- a/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/SudGameListAdapter.java @@ -31,6 +31,6 @@ public class SudGameListAdapter extends RefreshAdapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { SudGameListViewHolder sudGameListViewHolder = (SudGameListViewHolder) holder; - sudGameListViewHolder.setData(mList.get(position)); + sudGameListViewHolder.setData(mList.get(position),isHome); } } diff --git a/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java index 18adc9cee..b4e52cbb5 100644 --- a/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/SudHomeGameListAdapter.java @@ -43,7 +43,7 @@ public class SudHomeGameListAdapter extends RecyclerView.Adapter child) { + public CreateSudGamePopup(@NonNull Context context, List child, boolean isHome) { super(context); customSidebarChildModels = child; + this.isHome = isHome; } public CreateSudGamePopup setHomeView(boolean homeView) { @@ -129,15 +134,22 @@ public class CreateSudGamePopup extends BottomPopupView { .createSudRoom(name, sill, id, new HttpCallback() { @Override public void onSuccess(CreateSudRoomModel data) { + if (isHome) { + dialog.dismiss(); + Intent intent = new Intent(getContext(), SudGameActivity.class); + intent.putExtra("CreateSudRoom", new Gson().toJson(data)); + getContext().startActivity(intent); + } else { + new XPopup.Builder(getContext()) + .enableDrag(false) + .dismissOnTouchOutside(false) + .dismissOnBackPressed(false) + .asCustom(new LiveSudGamePopup(getContext(), data)) + .show(); + dialog.dismiss(); + Bus.get().post(new SudGameListDissMissEvent()); + } - new XPopup.Builder(getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(getContext(), data)) - .show(); - dialog.dismiss(); - Bus.get().post(new SudGameListDissMissEvent()); } @Override 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 14bffd84a..a54d67bc8 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java @@ -238,7 +238,7 @@ public class SudGameListPopup extends BottomPopupView { public void onViewClicks() { new XPopup.Builder(getContext()) .enableDrag(false) - .asCustom(new CreateSudGamePopup(getContext(), customSidebarChildModels)) + .asCustom(new CreateSudGamePopup(getContext(), customSidebarChildModels, false)) .show(); } 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 ba7c4fbd4..b87f7e0f7 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java @@ -1,5 +1,6 @@ package com.yunbao.common.views; +import android.content.Intent; import android.text.TextUtils; import android.view.View; import android.widget.ImageView; @@ -8,9 +9,11 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; +import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.playerObject; @@ -51,7 +54,7 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { avatarList5.setVisibility(View.GONE); } - public void setData(SudRoomListModel model) { + public void setData(SudRoomListModel model, boolean isHome) { ImgLoader.display(itemView.getContext(), model.getAvatar(), mAvatar); roomName.setText(model.getRoomName()); playerWeAre.setText(String.format(itemView.getContext().getString(R.string.interactive_game_player_we_are), model.getPlayerTotal())); @@ -97,14 +100,21 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { createSudRoomModel.setAvatar(model.getAvatar()); createSudRoomModel.setRoomName(model.getRoomName()); createSudRoomModel.setSudGameName(model.getSudGameName()); - new XPopup.Builder(itemView.getContext()) - .enableDrag(false) - .dismissOnTouchOutside(false) - .dismissOnBackPressed(false) - .asCustom(new LiveSudGamePopup(itemView.getContext(), createSudRoomModel)) - .show(); + if (isHome) { + Intent intent = new Intent(itemView.getContext(), SudGameActivity.class); + intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); + itemView.getContext().startActivity(intent); + } else { + new XPopup.Builder(itemView.getContext()) + .enableDrag(false) + .dismissOnTouchOutside(false) + .dismissOnBackPressed(false) + .asCustom(new LiveSudGamePopup(itemView.getContext(), createSudRoomModel)) + .show(); + + Bus.get().post(new SudGameListDissMissEvent()); + } - Bus.get().post(new SudGameListDissMissEvent()); } }); } diff --git a/common/src/main/res/layout/activity_sud_game.xml b/common/src/main/res/layout/activity_sud_game.xml new file mode 100644 index 000000000..b06a792ed --- /dev/null +++ b/common/src/main/res/layout/activity_sud_game.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 5d93b94fd..039506cf7 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java @@ -1,8 +1,8 @@ package com.yunbao.main.views; import android.animation.ObjectAnimator; -import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.text.TextUtils; import android.util.Log; import android.view.ViewGroup; @@ -15,6 +15,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; 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.activity.SudGameActivity; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.SudGameListAdapter; import com.yunbao.common.bean.CreateSudRoomModel; @@ -35,7 +37,6 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.RandomUtil; -import com.yunbao.common.views.LiveSudGamePopup; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; @@ -61,9 +62,11 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement private long animDuration = 500; private String id = "0"; private SudGameListAdapter sudGameListAdapter; + private AbsActivity context; - public MainHomeGameViewHolder(Context context, ViewGroup parentView) { + public MainHomeGameViewHolder(AbsActivity context, ViewGroup parentView) { super(context, parentView); + this.context = context; Bus.getOn(this); } @@ -151,12 +154,15 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement 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(); + Intent intent = new Intent(context, SudGameActivity.class); + intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); + context.startActivity(intent); +// new XPopup.Builder(mContext) +// .enableDrag(false) +// .dismissOnTouchOutside(false) +// .dismissOnBackPressed(false) +// .asCustom(new LiveSudGamePopup(mContext, createSudRoomModel)) +// .show(); } @@ -233,7 +239,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement public void onViewClicks() { new XPopup.Builder(mContext) .enableDrag(false) - .asCustom(new CreateSudGamePopup(mContext, customSidebarChildModels).setHomeView(true)) + .asCustom(new CreateSudGamePopup(mContext, customSidebarChildModels,true).setHomeView(true)) .show(); } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index 5b9027da2..fc440dcad 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -6,6 +6,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import com.umeng.analytics.MobclickAgent; +import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.glide.ImgLoader; import com.yunbao.main.R; @@ -85,7 +86,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder { vh = mainHomeRecomLiveViewHolder; } else if (position == 3) { - mainHomeGameLiveViewHolder = new MainHomeGameViewHolder(mContext, parent); + mainHomeGameLiveViewHolder = new MainHomeGameViewHolder((AbsActivity) mContext, parent); vh = mainHomeGameLiveViewHolder; }