diff --git a/IAP6Helper/build.gradle b/IAP6Helper/build.gradle index ba734c03e..29919cb60 100644 --- a/IAP6Helper/build.gradle +++ b/IAP6Helper/build.gradle @@ -23,4 +23,5 @@ android { } dependencies { + // api 'com.google.code.gson:gson:2.8.8' } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d7065ed3b..e2bfa4116 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,10 +4,8 @@ apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' apply plugin: 'com.alibaba.arouter' apply from: "../package_config.gradle" + android { - dexOptions { - jumboMode = true - } project.tasks.getByName("tasks").doFirst { } @@ -90,12 +88,13 @@ android { applicationVariants.all { variant -> println "清空build文件夹"; - for (final def project in rootProject.getAllprojects()) { - def name = variant.name.replace('Debug', '').replace('Release', '').toLowerCase() - delete project.buildDir - delete 'app' + File.separator + name - println project.buildDir - } + /* for (final def project in rootProject.getAllprojects()) { + def name = variant.name.replace('Debug', '').replace('Release', '').toLowerCase() + delete project.buildDir + delete project.rootDir.absolutePath+File.separator+"app"+File.separator+name + println project.buildDir + }*/ + //delete project.rootDir.absolutePath + File.separator + "outputs" String variantName = variant.name.capitalize() def processManifestTask = project.tasks.getByName("process${variantName}Manifest") processManifestTask.doLast { pm -> @@ -160,29 +159,39 @@ android { } } } - variant.outputs.all { vt -> - println("输出文件名:${vt}") + variant.assemble.doLast { vt -> def channel = '' - def server='' - if (variant.name.startsWith('huawei')) { + def server = '' + if (variant.name.contains('huawei')) { channel = "华为" - } else if (variant.name.startsWith('samsung')) { + } else if (variant.name.contains('samsung')) { channel = "三星" - } else if (variant.name.startsWith('google')) { + } else if (variant.name.contains('google')) { channel = "谷歌" } else { channel = "链接" } - if(variant.name.contains('online')){ - server='正式服' - }else{ - server='测试服' + if (variant.name.contains('online')) { + server = '正式服' + } else { + server = '测试服' } - outputFileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${channel}-${server}-${variant.buildType.name}.apk" + def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.apk" + variant.outputs.forEach { fe -> + copy { + from fe.outputFile + into file("${project.rootDir}\\outputs\\apk\\") + rename { fn -> + fileName + } + } + } + } tasks.named("sign${variant.name.capitalize()}Bundle", com.android.build.gradle.internal.tasks.FinalizeBundleTask) { File file = finalBundleFile.asFile.get() def channel = '' + def server = '' if (variant.name.startsWith('huawei')) { channel = "华为" } else if (variant.name.startsWith('samsung')) { @@ -192,43 +201,14 @@ android { } else { channel = "链接" } - File finalFile = new File(file.parentFile, "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${channel}-${variant.buildType.name}.aab") - finalBundleFile.set(finalFile) - } - project.afterEvaluate { project -> - project.tasks.each { - if (it.name.startsWith('assemble') && it.name.endsWith('Release')) { - it.doLast { - def dir = it.name.replace('assemble', '').replace('Release', '').toLowerCase() - println("处理assembleRelease ${project.rootDir}\\app\\$dir\\release\\ | " + new File("${project.rootDir}\\app\\$dir\\release\\").exists()) - if (new File("${project.rootDir}\\app\\$dir\\release\\").exists()) { - println("准备拷贝apk文件") - copy { - from file("${project.rootDir}\\app\\$dir\\release\\") - into file("${project.rootDir}\\outputs\\apk\\") - include '**/*.apk' - } - - } - println("打包apk结束") - } - } else if (it.name.startsWith('sign') && it.name.endsWith('ReleaseBundle')) { - it.doLast { - def dir = it.name.replace('sign', '').replace('ReleaseBundle', '').toLowerCase() - println("处理signReleaseBundle ${project.rootDir}\\app\\$dir\\release\\ | " + new File("${project.rootDir}\\app\\$dir\\release\\").exists()) - if (new File("${project.rootDir}\\app\\$dir\\release\\").exists()) { - println("准备拷贝aab文件") - copy { - from file("${project.rootDir}\\app\\$dir\\release\\") - into file("${project.rootDir}\\outputs\\aab\\") - include '**/*.aab' - } - - } - println("打包aab结束") - } - } + if (variant.name.contains('online')) { + server = '正式服' + } else { + server = '测试服' } + def fileName = "[${new Date().format("yyyy-MM-dd HHmmss", TimeZone.getTimeZone("GMT+8"))}]PDLive-${defaultConfig.versionName}-${defaultConfig.versionCode}-${channel}-${server}-${variant.buildType.name}.aab" + File finalFile = new File("${project.rootDir}\\outputs\\aab", fileName) + finalBundleFile.set(finalFile) } } signingConfigs { @@ -269,9 +249,17 @@ android { manifestPlaceholders = rootProject.ext.manifestPlaceholders multiDexEnabled true ndk { - // TODO: 谷歌商城需要兼容两个平台 - //abiFilters "armeabi-v7a", "arm64-v8a" - abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + Gradle gradle = getGradle() + String tskReqStr = gradle.getStartParameter().getTaskRequests().args.toString() + println("处理ndk 版本 = " + tskReqStr) + def isLink = tskReqStr.contains("Link") + if (isLink) { + abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + println("打包ndk 链接") + } else { + abiFilters "armeabi-v7a", "arm64-v8a" + println("打包ndk其他") + } } javaCompileOptions { annotationProcessorOptions { @@ -326,18 +314,4 @@ dependencies { //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10' -} -// 链接包需要注释掉 否正无法更新 谷歌包需要打开 -/* -project.afterEvaluate { - android.applicationVariants.all { variant -> - variant.outputs.each { output -> - output.processResources.doFirst { pm-> - String manifestPath = output.processResources.manifestFile; - def manifestContent = file(manifestPath).getText() - manifestContent = manifestContent.replace('android.permission.REQUEST_INSTALL_PACKAGES', '') - file(manifestPath).write(manifestContent) - } - } - } -}*/ +} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index fdc222cf4..39c0f0dd1 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -235,4 +235,6 @@ dependencies { //ExoPlayer,腾讯的播放器不支持无缝切换 api 'com.google.android.exoplayer:exoplayer:2.18.2' api 'com.google.android.exoplayer:exoplayer-core:2.18.2@aar' + + api rootProject.ext.dependencies["blank-utilcode"] } diff --git a/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java b/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java index e53971c5b..ba0cc148f 100644 --- a/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/BaseAdapter.java @@ -9,7 +9,7 @@ import java.util.HashMap; import java.util.List; public abstract class BaseAdapter extends RecyclerView.Adapter { - private Context context; + public Context context; public List data; public BaseAdapter(Context context, List data) { @@ -34,7 +34,7 @@ public abstract class BaseAdapter extends RecyclerView.Adapter extends RecyclerView.Adapter { + public SudGameAdapter(Context context, List data) { + super(context, data); + } + + private AppCompatImageView sub_rank_image; + private RoundedImageView sub_head; + private AppCompatTextView sub_rank_text,sub_name,sub_score; + + @SuppressLint("SetTextI18n") + @Override + public void convert(BaseAdapter.BaseViewHolder holder, SudSettleBean item) { + sub_rank_image = (AppCompatImageView) holder.getView(R.id.sub_rank_image); + sub_rank_text = (AppCompatTextView) holder.getView(R.id.sub_rank_text); + sub_head = (RoundedImageView) holder.getView(R.id.sub_head); + sub_name = (AppCompatTextView) holder.getView(R.id.sub_name); + sub_score = (AppCompatTextView) holder.getView(R.id.sub_score); + + switch (item.getRank()){ + case 1: + sub_rank_text.setVisibility(View.GONE); + sub_rank_image.setVisibility(View.VISIBLE); + sub_rank_image.setImageResource(R.mipmap.sub_1); + break; + case 2: + sub_rank_text.setVisibility(View.GONE); + sub_rank_image.setVisibility(View.VISIBLE); + sub_rank_image.setImageResource(R.mipmap.sub_2); + break; + case 3: + sub_rank_text.setVisibility(View.GONE); + sub_rank_image.setVisibility(View.VISIBLE); + sub_rank_image.setImageResource(R.mipmap.sub_3); + break; + default: + sub_rank_text.setVisibility(View.VISIBLE); + sub_rank_image.setVisibility(View.GONE); + sub_rank_text.setText(String.valueOf(item.getRank())); + break; + } + + ImgLoader.display(context, item.getAvatar_url(),sub_head); + sub_name.setText(item.getNick_name()); + if (item.getWin_num()>0){ + sub_score.setText("+"+item.getWin_num()); + }else { + sub_score.setText(String.valueOf(item.getWin_num())); + } + } + + @Override + public int getItemLayoutId() { + return R.layout.view_sub_rank; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/SudGameInfoBean.java b/common/src/main/java/com/yunbao/common/bean/SudGameInfoBean.java new file mode 100644 index 000000000..d47f5fe09 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/SudGameInfoBean.java @@ -0,0 +1,60 @@ +package com.yunbao.common.bean; + +public class SudGameInfoBean { + private String uid;//玩家id + private String nick_name;//玩家昵称 + private String avatar_url;//玩家头像 + private String gender;//玩家性别 + private int is_ai;//是否是ai + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getNick_name() { + return nick_name; + } + + public void setNick_name(String nick_name) { + this.nick_name = nick_name; + } + + public String getAvatar_url() { + return avatar_url; + } + + public void setAvatar_url(String avatar_url) { + this.avatar_url = avatar_url; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public int getIs_ai() { + return is_ai; + } + + public void setIs_ai(int is_ai) { + this.is_ai = is_ai; + } + + @Override + public String toString() { + return "SudGameInfoBean{" + + "uid=" + uid + + ", nick_name='" + nick_name + '\'' + + ", avatar_url='" + avatar_url + '\'' + + ", gender='" + gender + '\'' + + ", is_ai=" + is_ai + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/SudGameScoreBean.java b/common/src/main/java/com/yunbao/common/bean/SudGameScoreBean.java new file mode 100644 index 000000000..4742eaec0 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/SudGameScoreBean.java @@ -0,0 +1,60 @@ +package com.yunbao.common.bean; + +public class SudGameScoreBean extends BaseModel{ + private int golden_bean_remaining_balance;// + private int room_sill;//房间的金豆门槛 + private int room_ticket;//收取的门票费 + private int room_win_num;//赢家获得的金豆 + private int game_mode;//1.双人对战 2.多人游戏 + + @Override + public String toString() { + return "SudGameScoreBean{" + + "golden_bean_remaining_balance=" + golden_bean_remaining_balance + + ", room_sill=" + room_sill + + ", room_ticket=" + room_ticket + + ", room_win_num=" + room_win_num + + ", game_mode=" + game_mode + + '}'; + } + + public int getGame_mode() { + return game_mode; + } + + public void setGame_mode(int game_mode) { + this.game_mode = game_mode; + } + + public int getGolden_bean_remaining_balance() { + return golden_bean_remaining_balance; + } + + public void setGolden_bean_remaining_balance(int golden_bean_remaining_balance) { + this.golden_bean_remaining_balance = golden_bean_remaining_balance; + } + + public int getRoom_sill() { + return room_sill; + } + + public void setRoom_sill(int room_sill) { + this.room_sill = room_sill; + } + + public int getRoom_ticket() { + return room_ticket; + } + + public void setRoom_ticket(int room_ticket) { + this.room_ticket = room_ticket; + } + + public int getRoom_win_num() { + return room_win_num; + } + + public void setRoom_win_num(int room_win_num) { + this.room_win_num = room_win_num; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/SudSettleBean.java b/common/src/main/java/com/yunbao/common/bean/SudSettleBean.java new file mode 100644 index 000000000..9738a1e87 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/SudSettleBean.java @@ -0,0 +1,71 @@ +package com.yunbao.common.bean; + +import java.util.List; + +public class SudSettleBean { + private String uid;//玩家id + private String nick_name;//玩家昵称 + private String avatar_url;//玩家头像 + private int rank;//玩家排名 + private int win_num;//赢得或者失去的金豆 + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getNick_name() { + return nick_name; + } + + public void setNick_name(String nick_name) { + this.nick_name = nick_name; + } + + public String getAvatar_url() { + return avatar_url; + } + + public void setAvatar_url(String avatar_url) { + this.avatar_url = avatar_url; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } + + public int getWin_num() { + return win_num; + } + + public void setWin_num(int win_num) { + this.win_num = win_num; + } + + + public SudSettleBean(String uid, String nick_name, String avatar_url, int rank, int win_num) { + this.uid = uid; + this.nick_name = nick_name; + this.avatar_url = avatar_url; + this.rank = rank; + this.win_num = win_num; + } + + @Override + public String toString() { + return "SudSettleBean{" + + "uid='" + uid + '\'' + + ", nick_name='" + nick_name + '\'' + + ", avatar_url='" + avatar_url + '\'' + + ", rank=" + rank + + ", win_num=" + win_num + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java index b0b894576..a685192b0 100644 --- a/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/AbsDialogCenterPopupWindow.java @@ -24,6 +24,11 @@ public abstract class AbsDialogCenterPopupWindow extends CenterPopupView { public abstract void buildDialog(XPopup.Builder builder); public abstract int bindLayoutId(); + @Override + protected void onShow() { + super.onShow(); + } + @Override protected int getImplLayoutId() { return bindLayoutId(); @@ -36,4 +41,24 @@ public abstract class AbsDialogCenterPopupWindow extends CenterPopupView { buildDialog(builder); builder.asCustom(this).show(); } + + /** + * Dismiss监听 + */ + private OnDismissListener onDismissListener; + public interface OnDismissListener{ + void onDismiss(); + } + + public void setOnDismissListener(OnDismissListener onDismissListener) { + this.onDismissListener = onDismissListener; + } + + @Override + protected void onDismiss() { + super.onDismiss(); + if (onDismissListener != null){ + onDismissListener.onDismiss(); + } + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java b/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java new file mode 100644 index 000000000..96aefe35c --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameDoubleDialog.java @@ -0,0 +1,172 @@ +package com.yunbao.common.dialog; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.CountDownTimer; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatTextView; + +import com.blankj.utilcode.util.LogUtils; +import com.lxj.xpopup.XPopup; +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.R; +import com.yunbao.common.bean.SudSettleBean; +import com.yunbao.common.event.CheckRemainingBalanceEvent; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.sud.state.SudMGPMGState; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.WordUtil; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * 双人小游戏结算弹窗 + */ +public class SudGameDoubleDialog extends AbsDialogCenterPopupWindow{ + public SudGameDoubleDialog(@NonNull Context context) { + super(context); + } + @Override + public int bindLayoutId() { + return R.layout.dialog_sub_double; + } + + private AppCompatImageView sub_win_hat,sub_leave,sub_again,sub_title; + private RoundedImageView sub_win_head,sub_loss_head; + private AppCompatTextView sub_win_name,sub_win_score,sub_loss_name,sub_loss_score,sub_time; + private CountDownTimer countDownTimer; + private List settleBeans = new ArrayList<>(); + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.dismissOnTouchOutside(false); + } + + @Override + protected void onCreate() { + super.onCreate(); + sub_title = findViewById(R.id.sub_title);//弹窗标题 + sub_win_hat = findViewById(R.id.sub_win_hat);//胜利皇冠(平局隐藏) + sub_leave = findViewById(R.id.sub_leave);//离开按钮 + sub_again = findViewById(R.id.sub_again);//再来一局按钮 + sub_win_head = findViewById(R.id.sub_win_head);//胜利方头像 + sub_loss_head = findViewById(R.id.sub_loss_head);//失败方头像 + sub_win_name = findViewById(R.id.sub_win_name);//胜利方昵称 + sub_win_score = findViewById(R.id.sub_win_score);//胜利方分数 + sub_loss_name = findViewById(R.id.sub_loss_name);//失败方昵称 + sub_loss_score = findViewById(R.id.sub_loss_score);//失败方分数 + sub_time = findViewById(R.id.sub_time);//关闭倒计时 + + + initData(); + + if (WordUtil.isNewZh()){ + sub_leave.setImageResource(R.mipmap.sub_leave_zh); + sub_again.setImageResource(R.mipmap.sub_again_zh); + }else { + sub_leave.setImageResource(R.mipmap.sub_leave_en); + sub_again.setImageResource(R.mipmap.sub_again_en); + } + + sub_leave.setOnClickListener(v-> destroyDialog()); + sub_again.setOnClickListener(v-> { + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false)); + destroyDialog(); + }); + + } + + @SuppressLint("SetTextI18n") + private void initData() { + if (settleBeans.size() == 2){ + sortByWinNum(settleBeans); + SudSettleBean sudSettleBean1 = settleBeans.get(0); // 第一名 + SudSettleBean sudSettleBean2 = settleBeans.get(1); // 第二名 + + ImgLoader.display(mContext,sudSettleBean1.getAvatar_url(),sub_win_head); + ImgLoader.display(mContext,sudSettleBean2.getAvatar_url(),sub_loss_head); + sub_win_name.setText(sudSettleBean1.getNick_name()); + sub_loss_name.setText(sudSettleBean2.getNick_name()); + if (sudSettleBean1.getWin_num()>0){ + sub_win_score.setText("+"+sudSettleBean1.getWin_num()); + }else { + sub_win_score.setText(String.valueOf(sudSettleBean1.getWin_num())); + } + sub_loss_score.setText(String.valueOf(sudSettleBean2.getWin_num())); + + if (sudSettleBean1.getWin_num() == sudSettleBean2.getWin_num()){ + //平局 + if (WordUtil.isNewZh()){ + sub_title.setImageResource(R.mipmap.sub_draw_zh); + }else { + sub_title.setImageResource(R.mipmap.sub_draw_en); + } + sub_win_hat.setVisibility(View.GONE); + }else { + //有胜负 + sub_win_hat.setVisibility(View.VISIBLE); + if (CommonAppConfig.getInstance().getUid().equals(sudSettleBean1.getUid())){ + //本人胜利 + if (WordUtil.isNewZh()){ + sub_title.setImageResource(R.mipmap.sub_win_zh); + }else { + sub_title.setImageResource(R.mipmap.sub_win_en); + } + }else { + //本人失败 + if (WordUtil.isNewZh()){ + sub_title.setImageResource(R.mipmap.sub_loss_zh); + }else { + sub_title.setImageResource(R.mipmap.sub_loss_en); + } + } + } + } + } + + @Override + protected void onShow() { + super.onShow(); + //关闭倒计时 + countDownTimer = new CountDownTimer(10000, 1000){ + + @Override + public void onTick(long l) { + sub_time.setText(String.valueOf((l+500)/1000)); + } + + @Override + public void onFinish() { + destroyDialog(); + } + }.start(); + initData(); + } + + public void setSudSettleList(List data){ + settleBeans.clear(); + settleBeans.addAll(data); + LogUtils.e("yqw=====>"+settleBeans); + } + + private void sortByWinNum(List list){ + // 按照胜利数排序 settleBeans 列表 + Collections.sort(list, (bean1, bean2) -> { + return Integer.compare(bean2.getWin_num(), bean1.getWin_num()); // 从大到小排序 + }); + } + + private void destroyDialog(){ + dismiss(); + countDownTimer.cancel(); + countDownTimer = null; + } + +} diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameMultipleDialog.java b/common/src/main/java/com/yunbao/common/dialog/SudGameMultipleDialog.java new file mode 100644 index 000000000..3ad4d68db --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameMultipleDialog.java @@ -0,0 +1,124 @@ +package com.yunbao.common.dialog; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.CountDownTimer; +import android.view.View; +import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import com.lxj.xpopup.XPopup; +import com.yunbao.common.R; +import com.yunbao.common.adapter.SudGameAdapter; +import com.yunbao.common.bean.SudSettleBean; +import com.yunbao.common.event.CheckRemainingBalanceEvent; +import com.yunbao.common.sud.state.SudMGPMGState; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.WordUtil; +import java.util.ArrayList; +import java.util.List; + +/** + * 多人小游戏弹窗 + */ +public class SudGameMultipleDialog extends AbsDialogCenterPopupWindow{ + public SudGameMultipleDialog(@NonNull Context context) { + super(context); + } + @Override + public int bindLayoutId() { + return R.layout.dialog_sub_multiple; + } + + private RecyclerView sub_recycle_rank; + private AppCompatImageView sub_leave,sub_again,sub_title; + private AppCompatTextView sub_time; + private CountDownTimer countDownTimer; + private SudGameAdapter sudGameAdapter; + private final List settleBeans = new ArrayList<>(); + @Override + public void buildDialog(XPopup.Builder builder) { + builder.dismissOnTouchOutside(false); + } + + @Override + protected void onCreate() { + super.onCreate(); + sub_recycle_rank = findViewById(R.id.sub_recycle_rank);//分数排名 + sub_leave = findViewById(R.id.sub_leave);//离开按钮 + sub_again = findViewById(R.id.sub_again);//再来一局按钮 + sub_title = findViewById(R.id.sub_title);//弹窗标题 + sub_time = findViewById(R.id.sub_time);//关闭倒计时 + + if (WordUtil.isNewZh()){ + sub_leave.setImageResource(R.mipmap.sub_leave_zh); + sub_again.setImageResource(R.mipmap.sub_again_zh); + sub_title.setImageResource(R.mipmap.sub_over_zh); + }else { + sub_leave.setImageResource(R.mipmap.sub_leave_en); + sub_again.setImageResource(R.mipmap.sub_again_en); + sub_title.setImageResource(R.mipmap.sub_over_en); + } + + sub_leave.setOnClickListener(v-> destroyDialog()); + sub_again.setOnClickListener(v-> { + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false)); + destroyDialog(); + }); + + //设置排名数据 + sudGameAdapter = new SudGameAdapter(mContext,settleBeans); + sub_recycle_rank.setLayoutManager(new LinearLayoutManager(mContext)); + sub_recycle_rank.setAdapter(sudGameAdapter); + + } + + @SuppressLint("NotifyDataSetChanged") + @Override + protected void onShow() { + super.onShow(); + //关闭倒计时 + countDownTimer = new CountDownTimer(10000, 1000){ + + @Override + public void onTick(long l) { + sub_time.setText(String.valueOf((l+500)/1000)); + } + + @Override + public void onFinish() { + destroyDialog(); + } + }.start(); + sudGameAdapter.notifyDataSetChanged(); +// limitItem(); + } + + public void setSudSettleList(List data){ + settleBeans.clear(); + settleBeans.addAll(data); + } + + //设置最多显示的高度 + private void limitItem(){ + sub_recycle_rank.post(() -> { + View itemView = sub_recycle_rank.getChildAt(0); + if (itemView != null){ + int height = (int) (itemView.getHeight()*3.5); + ViewGroup.LayoutParams layoutParams = sub_recycle_rank.getLayoutParams(); + layoutParams.height = height; + sub_recycle_rank.setLayoutParams(layoutParams); + } + }); + } + + private void destroyDialog(){ + dismiss(); + countDownTimer.cancel(); + countDownTimer = null; + } + +} diff --git a/common/src/main/java/com/yunbao/common/dialog/SudLoadDialog.java b/common/src/main/java/com/yunbao/common/dialog/SudLoadDialog.java new file mode 100644 index 000000000..d0e074dcc --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/SudLoadDialog.java @@ -0,0 +1,96 @@ +package com.yunbao.common.dialog; + +import android.content.Context; +import android.view.View; +import android.widget.ProgressBar; +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.LinearLayoutCompat; +import androidx.core.content.ContextCompat; +import com.lxj.xpopup.XPopup; +import com.yunbao.common.R; +import com.yunbao.common.utils.WordUtil; + +public class SudLoadDialog extends AbsDialogCenterPopupWindow{ + public SudLoadDialog(@NonNull Context context) { + super(context); + } + + private LinearLayoutCompat sud_load_bg; + private AppCompatImageView sud_load,sud_load_skip,sud_load_again; + private ProgressBar sud_load_bar_double,sud_load_bar_multiple; + private int isDouble = 0;//游戏模式 1:双人对战 2:多人游戏 + private int clickStatus = 0;//0:什么都不点击 1:点击跳过 2:点击再来一局 + + public int getClickStatus() { + return clickStatus; + } + + public void setClickStatus(int clickStatus) { + this.clickStatus = clickStatus; + } + + @Override + public void buildDialog(XPopup.Builder builder) { + builder.dismissOnTouchOutside(false); + } + + @Override + public int bindLayoutId() { + return R.layout.dialog_sud_load; + } + + @Override + protected void onCreate() { + super.onCreate(); + sud_load_bg = findViewById(R.id.sud_load_bg); + sud_load = findViewById(R.id.sud_load); + sud_load_skip = findViewById(R.id.sud_load_skip); + sud_load_again = findViewById(R.id.sud_load_again); + sud_load_bar_double = findViewById(R.id.sud_load_bar_double); + sud_load_bar_multiple = findViewById(R.id.sud_load_bar_multiple); + + if (WordUtil.isNewZh()){ + sud_load.setImageResource(R.mipmap.sud_load_zh); + sud_load_skip.setImageResource(R.mipmap.sud_load_skip_zh); + sud_load_again.setImageResource(R.mipmap.sub_again_zh); + }else { + sud_load.setImageResource(R.mipmap.sud_load_en); + sud_load_skip.setImageResource(R.mipmap.sud_load_skip_en); + sud_load_again.setImageResource(R.mipmap.sub_again_en); + } + + sud_load_skip.setOnClickListener(v->{ + clickStatus = 1; + dismiss(); + }); + + sud_load_again.setOnClickListener(v->{ + clickStatus = 2; + dismiss(); + }); + } + + @Override + protected void onShow() { + super.onShow(); + if (isDouble == 1){ + sud_load_bg.setBackground(ContextCompat.getDrawable(mContext,R.mipmap.sud_load_bg_double)); + sud_load_bar_double.setVisibility(View.VISIBLE); + sud_load_bar_multiple.setVisibility(View.GONE); + }else { + sud_load_bg.setBackground(ContextCompat.getDrawable(mContext,R.mipmap.sud_load_bg_multiple)); + sud_load_bar_double.setVisibility(View.GONE); + sud_load_bar_multiple.setVisibility(View.VISIBLE); + } +// new Handler(Looper.getMainLooper()).postDelayed(() -> { +// if (this.isShow()){ +// dismiss(); +// } +// },10000); + } + + public void setDouble(int isDouble){ + this.isDouble = isDouble; + } +} diff --git a/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java b/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java index 09471d14f..928b1e46a 100644 --- a/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java +++ b/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java @@ -1,10 +1,22 @@ package com.yunbao.common.event; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.sud.state.SudMGPMGState; public class CheckRemainingBalanceEvent extends BaseModel { public int seatIndex=0; private String SudMGPMGState; + private boolean subReady = false;//是否直接自动准备 + private SudMGPMGState.MGCommonGameSettle mgCommonGameSettle;//结算数据 + + public SudMGPMGState.MGCommonGameSettle getMgCommonGameSettle() { + return mgCommonGameSettle; + } + + public CheckRemainingBalanceEvent setMgCommonGameSettle(SudMGPMGState.MGCommonGameSettle mgCommonGameSettle) { + this.mgCommonGameSettle = mgCommonGameSettle; + return this; + } public String getSudMGPMGState() { return SudMGPMGState; @@ -23,4 +35,13 @@ public class CheckRemainingBalanceEvent extends BaseModel { this.seatIndex = seatIndex; return this; } + + public CheckRemainingBalanceEvent setSubReady(boolean subReady){ + this.subReady = subReady; + return this; + } + + public boolean getSubReady(){ + return subReady; + } } 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 e0e42ce10..9db79a79a 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -70,6 +70,8 @@ import com.yunbao.common.bean.SendMoneyLongModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.SudGameInfoBean; +import com.yunbao.common.bean.SudGameScoreBean; import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudgameCodeModel; @@ -1022,6 +1024,22 @@ public interface PDLiveApi { @GET("/api/public/?service=Sudgame.getCode") Observable>> getCode(); + /** + * 获取房间金豆门槛和赢家获得的金豆 + */ + @GET("/api/public/?service=Sudgameserver.checkRemainingBalance") + Observable> getScore( + @Query("room_id") String roomId + ); + + /** + * 获取游戏中玩家的信息 + */ + @GET("/api/public/?service=Sudgameserver.getGameUser") + Observable>> getSudGameInfo( + @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 29fa05c34..c1c14bd71 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 @@ -68,6 +68,8 @@ import com.yunbao.common.bean.RoomMicStatusModel; import com.yunbao.common.bean.SendMoneyLongModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.SudGameInfoBean; +import com.yunbao.common.bean.SudGameScoreBean; import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudgameCodeModel; @@ -2294,6 +2296,48 @@ public class LiveNetManager { }).isDisposed(); } + /** + * 获取房间金豆门槛和赢家获得的金豆 + * @param roomId + * @param callback + */ + public void getScore(String roomId,HttpCallback callback){ + API.get().pdLiveApi(mContext) + .getScore(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(sudGameScoreBeanResponseModel -> { + if (callback != null){ + callback.onSuccess(sudGameScoreBeanResponseModel.getData().getInfo()); + } + }, throwable -> { + if (callback != null){ + callback.onError(mContext.getString(R.string.net_error)); + } + }).isDisposed(); + } + + /** + * 获取游戏中所有玩家的信息 + * @param roomId + * @param callback + */ + public void getSudGameInfo(String roomId,HttpCallback> callback){ + API.get().pdLiveApi(mContext) + .getSudGameInfo(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(infoModel->{ + if (callback != null){ + callback.onSuccess(infoModel.getData().getInfo()); + } + },throwable -> { + if (callback != null){ + callback.onError(mContext.getString(R.string.net_error)); + } + }).isDisposed(); + } + public void createSudRoom(String roomName, String goldenBeanNumber, String currencyType, String gameId, HttpCallback callback) { API.get().pdLiveApi(mContext) .createSudRoom(roomName, goldenBeanNumber, currencyType, gameId) diff --git a/common/src/main/java/com/yunbao/common/sud/BaseGameViewModel.java b/common/src/main/java/com/yunbao/common/sud/BaseGameViewModel.java index 780775644..39cba517d 100644 --- a/common/src/main/java/com/yunbao/common/sud/BaseGameViewModel.java +++ b/common/src/main/java/com/yunbao/common/sud/BaseGameViewModel.java @@ -17,11 +17,13 @@ import com.yunbao.common.sud.decorator.SudFSTAPPDecorator; import com.yunbao.common.sud.model.GameConfigModel; import com.yunbao.common.sud.model.GameViewInfoModel; import com.yunbao.common.sud.state.MGStateResponse; +import com.yunbao.common.sud.state.SudMGPMGState; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.SudJsonUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; +import tech.sud.logger.LogUtils; import tech.sud.mgp.core.ISudFSMStateHandle; import tech.sud.mgp.core.ISudFSTAPP; import tech.sud.mgp.core.ISudListenerInitSDK; @@ -479,4 +481,13 @@ public abstract class BaseGameViewModel implements SudFSMMGListener { return sudFSMMGDecorator.getSudFSMMGCache(); } + /** + * 游戏结算状态 + */ + @Override + public void onGameMGCommonGameSettle(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSettle model) { + LogUtils.e("yqw=====>"+model); + } + + } diff --git a/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java b/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java index e7fa09b58..6a36e2c1b 100644 --- a/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java +++ b/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java @@ -6,8 +6,13 @@ import android.view.View; import androidx.lifecycle.MutableLiveData; +import com.blankj.utilcode.util.LogUtils; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; +import com.yunbao.common.bean.PrankProgressBean; +import com.yunbao.common.bean.SudGameInfoBean; +import com.yunbao.common.bean.SudGameScoreBean; +import com.yunbao.common.bean.SudSettleBean; import com.yunbao.common.bean.SudgameCodeModel; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; @@ -15,9 +20,14 @@ import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.sud.model.GameConfigModel; import com.yunbao.common.sud.model.GameViewInfoModel; import com.yunbao.common.sud.state.SudMGPMGState; +import com.yunbao.common.utils.ToastUtil; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Locale; +import java.util.function.Consumer; import tech.sud.mgp.core.ISudFSMMG; import tech.sud.mgp.core.ISudFSMStateHandle; @@ -62,6 +72,22 @@ public class QuickStartGameViewModel extends BaseGameViewModel { public String languageCode = "zh-TW"; public final MutableLiveData gameViewLiveData = new MutableLiveData<>(); // 游戏View回调 + private SudGameScoreBean sudGameScoreBean;//房间金豆的门槛和赢家奖励 + private List sudGameInfoBeanList = new ArrayList<>();//玩家信息 + public final MutableLiveData> listMutableLiveData = new MutableLiveData<>();//玩家排名信息 + + public void setSudGameInfoBeanList(List sudGameInfoBeanList) { + this.sudGameInfoBeanList = sudGameInfoBeanList; + } + + + public SudGameScoreBean getSudGameScoreBean() { + return sudGameScoreBean; + } + + public void setSudGameScoreBean(SudGameScoreBean sudGameScoreBean) { + this.sudGameScoreBean = sudGameScoreBean; + } /** * 向接入方服务器获取code @@ -70,7 +96,7 @@ public class QuickStartGameViewModel extends BaseGameViewModel { protected void getCode(Activity activity, String userId, String appId, GameGetCodeListener listener) { if (IMLoginManager.get(activity).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { languageCode = "zh-TW"; - }else { + } else { languageCode = "en-US"; } // TODO: 2022/6/10 注意,这里是演示使用OkHttpClient请求hello-sud服务 @@ -147,6 +173,81 @@ public class QuickStartGameViewModel extends BaseGameViewModel { // }); } + /** + * 获取房间的金豆数量和赢家获得的金豆 + */ + public void getScore(String roomId, Activity activity) { + LiveNetManager.get(activity).getScore(roomId, new HttpCallback() { + @Override + public void onSuccess(SudGameScoreBean data) { + sudGameScoreBean = data; + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + + /** + * 进行排名和结算 + */ + public void sudGameRank(SudMGPMGState.MGCommonGameSettle mgCommonGameSettle) { + List settleBeans = new ArrayList<>(); + int playerNum = mgCommonGameSettle.results.size();//玩家人数 + int winnerNUm = countWinners(mgCommonGameSettle.results);//第一名人数 + int winNum;//赢得或者失去的金豆 + // 构建结算信息 + for (SudMGPMGState.MGCommonGameSettle.PlayerResult playerResult : mgCommonGameSettle.results) { + String uid = playerResult.uid; + int rank = playerResult.rank; + SudGameInfoBean sudGameInfoBean = findGameInfoBean(uid); + if (sudGameInfoBean == null) return; + + if (sudGameScoreBean.getGame_mode() == 1) { + //双人游戏 + if (winnerNUm == 1){ + winNum = (rank == 1) ? (int) (sudGameScoreBean.getRoom_sill() * 0.8) : -sudGameScoreBean.getRoom_sill(); + }else { + winNum = -sudGameScoreBean.getRoom_ticket(); + } + } else { + //多人游戏 + if (rank == 1){ + winNum = (playerNum*sudGameScoreBean.getRoom_win_num()-winnerNUm*sudGameScoreBean.getRoom_sill())/winnerNUm; + }else { + winNum = -sudGameScoreBean.getRoom_sill(); + } + } + settleBeans.add(new SudSettleBean(uid,sudGameInfoBean.getNick_name(),sudGameInfoBean.getAvatar_url(),rank,winNum)); + } + // 更新LiveData + listMutableLiveData.setValue(settleBeans); + } + + // 统计第一名的玩家数量 + private int countWinners(List results) { + int count = 0; + for (SudMGPMGState.MGCommonGameSettle.PlayerResult result : results) { + if (result.rank == 1) { + count++; + } + } + return count; + } + + // 根据uid查找对应的游戏信息Bean + private SudGameInfoBean findGameInfoBean(String uid) { + for (SudGameInfoBean sudGameInfoBean : sudGameInfoBeanList) { + if (sudGameInfoBean.getUid().equals(uid)) { + return sudGameInfoBean; + } + } + return null; + } + + /** * 设置当前用户id(接入方定义) */ @@ -255,7 +356,7 @@ public class QuickStartGameViewModel extends BaseGameViewModel { @Override public void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) { super.onGameMGCommonGameState(handle, model); - Log.e("QuickStartGameViewModel",model.toString()); + Log.e("QuickStartGameViewModel", model.toString()); } } diff --git a/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java b/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java index 1bfba5b82..43d0d5807 100644 --- a/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java +++ b/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java @@ -8,6 +8,7 @@ package com.yunbao.common.sud.decorator; import android.util.Log; +import com.blankj.utilcode.util.LogUtils; import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.sud.state.SudMGPMGState; import com.yunbao.common.utils.Bus; @@ -177,11 +178,11 @@ public class SudFSMMGDecorator implements ISudFSMMG { } else { listener.onGameMGCommonGameSettle(handle, mgCommonGameSettle); } - Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_GAME_SETTLE)); + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_GAME_SETTLE).setMgCommonGameSettle(mgCommonGameSettle)); break; case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: // 4. 加入游戏按钮点击状态 SudMGPMGState.MGCommonSelfClickJoinBtn mgCommonSelfClickJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickJoinBtn.class); - Bus.get().post(new CheckRemainingBalanceEvent().setSeatIndex(mgCommonSelfClickJoinBtn.seatIndex).setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN)); + Bus.get().post(new CheckRemainingBalanceEvent().setSeatIndex(mgCommonSelfClickJoinBtn.seatIndex).setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN).setSubReady(false)); // if (listener == null) { // ISudFSMStateHandleUtils.handleSuccess(handle); // } else { @@ -258,7 +259,7 @@ public class SudFSMMGDecorator implements ISudFSMMG { // } else { // listener.onGameMGCommonSelfClickGameSettleAgainBtn(handle, mgCommonSelfClickGameSettleAgainBtn); // } - Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN)); + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false)); break; case SudMGPMGState.MG_COMMON_GAME_SOUND_LIST: // 13. 游戏上报游戏中的声音列表(2021-12-30新增,现在只支持碰碰我最强) SudMGPMGState.MGCommonGameSoundList mgCommonGameSoundList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSoundList.class); diff --git a/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java b/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java index dc358b332..082dc1802 100644 --- a/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java +++ b/common/src/main/java/com/yunbao/common/sud/state/SudMGPMGState.java @@ -170,6 +170,15 @@ public class SudMGPMGState implements Serializable { // 游戏结果玩家列表 public List results; + @Override + public String toString() { + return "MGCommonGameSettle{" + + "gameMode=" + gameMode + + ", gameRoundId='" + gameRoundId + '\'' + + ", results=" + results + + '}'; + } + /** * 游戏结果玩家定义 */ @@ -181,6 +190,19 @@ public class SudMGPMGState implements Serializable { public int isEscaped; // 是否逃跑 1:逃跑 0:非逃跑 public String killerId; // 杀自己的玩家的id public int isAI; // 是否是AI玩家,1为AI + + @Override + public String toString() { + return "PlayerResult{" + + "uid='" + uid + '\'' + + ", rank=" + rank + + ", award=" + award + + ", score=" + score + + ", isEscaped=" + isEscaped + + ", killerId='" + killerId + '\'' + + ", isAI=" + isAI + + '}'; + } } } diff --git a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java index 9bb18cb88..46e062f2c 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java @@ -2,6 +2,8 @@ package com.yunbao.common.views; import android.app.Activity; import android.content.Context; +import android.os.Handler; +import android.os.Looper; import android.util.Log; import android.view.View; import android.widget.FrameLayout; @@ -11,6 +13,7 @@ import androidx.annotation.NonNull; import androidx.lifecycle.Observer; import com.alibaba.fastjson.JSONObject; +import com.blankj.utilcode.util.LogUtils; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BottomPopupView; import com.makeramen.roundedimageview.RoundedImageView; @@ -19,7 +22,11 @@ import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.CustomSidebarInfoModel; -import com.yunbao.common.dialog.DebugDialog; +import com.yunbao.common.bean.SudGameInfoBean; +import com.yunbao.common.bean.SudGameScoreBean; +import com.yunbao.common.dialog.SudGameDoubleDialog; +import com.yunbao.common.dialog.SudGameMultipleDialog; +import com.yunbao.common.dialog.SudLoadDialog; import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.event.HideShowEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; @@ -57,6 +64,9 @@ public class LiveSudGamePopup extends BottomPopupView { private TextView gameTitle, roomName, roomNumber; private RoundedImageView mAvatar; private boolean selfClick = false; + private SudGameDoubleDialog sudGameDoubleDialog;//双人游戏弹窗 + private SudGameMultipleDialog sudGameMultipleDialog;//多人游戏弹窗 + private SudLoadDialog sudLoadDialog;//加载弹窗 public LiveSudGamePopup(@NonNull Context context, long interactionID, String liveUid) { super(context); @@ -69,7 +79,13 @@ public class LiveSudGamePopup extends BottomPopupView { mCreateSudRoomModel = createSudRoomModel; mInteractionID = mCreateSudRoomModel.getLongSudGameId(); mLiveUid = mCreateSudRoomModel.getSudGameRoomId(); + //第二次进入时,viewmodel数据丢失,所以初始化时直接获取 + gameViewModel.getScore(mCreateSudRoomModel.getSudGameRoomId(),getActivity()); IMLoginManager.get(context).setSudGame(""); + //初始化结算弹窗 + sudGameDoubleDialog = new SudGameDoubleDialog(context);//双人游戏 + sudGameMultipleDialog = new SudGameMultipleDialog(context);//多人游戏 + sudLoadDialog = new SudLoadDialog(context);//加载弹窗 } // 返回自定义弹窗的布局 @@ -166,6 +182,7 @@ public class LiveSudGamePopup extends BottomPopupView { gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值 + gameConfigModel.ui.gameSettle.hide = true;//是否隐藏结算界面(false: 显示; true: 隐藏,默认为 false) gameConfigModel.ui.lobby_players.custom = true; gameConfigModel.ui.join_btn.custom = true; @@ -173,6 +190,29 @@ public class LiveSudGamePopup extends BottomPopupView { gameConfigModel.ui.start_btn.custom = true; // SudMGP平台64bit游戏ID gameViewModel.switchGame((Activity) getContext(), mLiveUid, mInteractionID); + + //游戏结算结束 + gameViewModel.listMutableLiveData.observe(this, sudSettleBeans -> { + if (sudLoadDialog.getClickStatus() == 0) { + sudLoadDialog.dismiss(); + if (gameViewModel.getSudGameScoreBean().getGame_mode() == 1) { + //双人游戏 + sudGameDoubleDialog.setSudSettleList(sudSettleBeans); + sudGameDoubleDialog.showDialog(); + } else { + //多人游戏 + sudGameMultipleDialog.setSudSettleList(sudSettleBeans); + sudGameMultipleDialog.showDialog(); + } + } + }); + + //加载弹窗监听 + sudLoadDialog.setOnDismissListener(() -> { + if (sudLoadDialog.getClickStatus() == 2){ + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false)); + } + }); } private List customSidebarChildModels = new ArrayList<>(); @@ -225,11 +265,14 @@ public class LiveSudGamePopup extends BottomPopupView { switch (event.getSudMGPMGState()) { case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN: - LiveNetManager.get(getContext()).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { + //获取筹码信息,检查是否足够 + LiveNetManager.get(getContext()).getScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { @Override - public void onSuccess(CheckRemainingBalance data) { - if (data.getGoldenBeanRemainingBalance() == 1) { + public void onSuccess(SudGameScoreBean data) { + if (data.getGolden_bean_remaining_balance() == 1) { + gameViewModel.setSudGameScoreBean(data); gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1); + gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfReady(event.getSubReady()); } else { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ToastUtil.show("貨幣数量不足 "); @@ -251,9 +294,31 @@ public class LiveSudGamePopup extends BottomPopupView { }); break; case SudMGPMGState.MG_COMMON_GAME_SETTLE: + //结算状态 gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1); + sudLoadDialog.setClickStatus(0); + sudLoadDialog.setDouble(gameViewModel.getSudGameScoreBean().getGame_mode()); + sudLoadDialog.showDialog(); + //获取用户信息 + LiveNetManager.get(getContext()).getSudGameInfo(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback>() { + @Override + public void onSuccess(List data) { + if (!data.isEmpty()){ + gameViewModel.setSudGameInfoBeanList(data); + gameViewModel.sudGameRank(event.getMgCommonGameSettle()); + }else { + ToastUtil.show(getContext().getString(R.string.net_error)); + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); break; case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN: + //点击开始游戏 LiveNetManager.get(getContext()).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(), mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { @@ -279,9 +344,9 @@ public class LiveSudGamePopup extends BottomPopupView { break; } - } + @Subscribe(threadMode = ThreadMode.MAIN) public void onSudGameStatus(SubGameEvent event) { if (event.getType() == 0) { diff --git a/common/src/main/res/drawable/anim_loading_double.xml b/common/src/main/res/drawable/anim_loading_double.xml new file mode 100644 index 000000000..2f726ba5d --- /dev/null +++ b/common/src/main/res/drawable/anim_loading_double.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/common/src/main/res/drawable/anim_loading_multiple.xml b/common/src/main/res/drawable/anim_loading_multiple.xml new file mode 100644 index 000000000..70912948d --- /dev/null +++ b/common/src/main/res/drawable/anim_loading_multiple.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/common/src/main/res/drawable/shape_sub_rank.xml b/common/src/main/res/drawable/shape_sub_rank.xml new file mode 100644 index 000000000..a0d1f44c4 --- /dev/null +++ b/common/src/main/res/drawable/shape_sub_rank.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_sub_double.xml b/common/src/main/res/layout/dialog_sub_double.xml new file mode 100644 index 000000000..c86e5a573 --- /dev/null +++ b/common/src/main/res/layout/dialog_sub_double.xml @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_sub_multiple.xml b/common/src/main/res/layout/dialog_sub_multiple.xml new file mode 100644 index 000000000..617e967af --- /dev/null +++ b/common/src/main/res/layout/dialog_sub_multiple.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_sud_load.xml b/common/src/main/res/layout/dialog_sud_load.xml new file mode 100644 index 000000000..636307c8a --- /dev/null +++ b/common/src/main/res/layout/dialog_sud_load.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_sub_rank.xml b/common/src/main/res/layout/view_sub_rank.xml new file mode 100644 index 000000000..32a4495b0 --- /dev/null +++ b/common/src/main/res/layout/view_sub_rank.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xhdpi/sub_1.png b/common/src/main/res/mipmap-xhdpi/sub_1.png new file mode 100644 index 000000000..d2e3ed4f3 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_1.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_2.png b/common/src/main/res/mipmap-xhdpi/sub_2.png new file mode 100644 index 000000000..dc88bbbe9 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_2.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_3.png b/common/src/main/res/mipmap-xhdpi/sub_3.png new file mode 100644 index 000000000..ea360085b Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_3.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_again_en.png b/common/src/main/res/mipmap-xhdpi/sub_again_en.png new file mode 100644 index 000000000..0ef4f37bd Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_again_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_again_zh.png b/common/src/main/res/mipmap-xhdpi/sub_again_zh.png new file mode 100644 index 000000000..19e736458 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_again_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_bg.png b/common/src/main/res/mipmap-xhdpi/sub_bg.png new file mode 100644 index 000000000..7178231e7 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_bg.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_bg2.png b/common/src/main/res/mipmap-xhdpi/sub_bg2.png new file mode 100644 index 000000000..357798c60 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_bg2.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_draw_en.png b/common/src/main/res/mipmap-xhdpi/sub_draw_en.png new file mode 100644 index 000000000..b0fd12771 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_draw_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_draw_zh.png b/common/src/main/res/mipmap-xhdpi/sub_draw_zh.png new file mode 100644 index 000000000..be79e21fa Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_draw_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_leave_en.png b/common/src/main/res/mipmap-xhdpi/sub_leave_en.png new file mode 100644 index 000000000..533c0dca4 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_leave_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_leave_zh.png b/common/src/main/res/mipmap-xhdpi/sub_leave_zh.png new file mode 100644 index 000000000..6b69f7404 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_leave_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_loss_en.png b/common/src/main/res/mipmap-xhdpi/sub_loss_en.png new file mode 100644 index 000000000..cded722b6 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_loss_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_loss_zh.png b/common/src/main/res/mipmap-xhdpi/sub_loss_zh.png new file mode 100644 index 000000000..df783c0b7 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_loss_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_over_en.png b/common/src/main/res/mipmap-xhdpi/sub_over_en.png new file mode 100644 index 000000000..3b2847992 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_over_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_over_zh.png b/common/src/main/res/mipmap-xhdpi/sub_over_zh.png new file mode 100644 index 000000000..719cd0f4e Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_over_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_vs.png b/common/src/main/res/mipmap-xhdpi/sub_vs.png new file mode 100644 index 000000000..6a77d88e3 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_vs.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_win_en.png b/common/src/main/res/mipmap-xhdpi/sub_win_en.png new file mode 100644 index 000000000..5cb13fa56 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_win_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_win_hat.png b/common/src/main/res/mipmap-xhdpi/sub_win_hat.png new file mode 100644 index 000000000..344e11b7f Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_win_hat.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sub_win_zh.png b/common/src/main/res/mipmap-xhdpi/sub_win_zh.png new file mode 100644 index 000000000..91457b195 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sub_win_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_bg_double.png b/common/src/main/res/mipmap-xhdpi/sud_load_bg_double.png new file mode 100644 index 000000000..43d3a504c Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_bg_double.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_bg_multiple.png b/common/src/main/res/mipmap-xhdpi/sud_load_bg_multiple.png new file mode 100644 index 000000000..e185ad395 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_bg_multiple.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_double.png b/common/src/main/res/mipmap-xhdpi/sud_load_double.png new file mode 100644 index 000000000..a7d00a92c Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_double.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_en.png b/common/src/main/res/mipmap-xhdpi/sud_load_en.png new file mode 100644 index 000000000..07e0d399b Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_multiple.png b/common/src/main/res/mipmap-xhdpi/sud_load_multiple.png new file mode 100644 index 000000000..dbd2148b4 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_multiple.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_skip_en.png b/common/src/main/res/mipmap-xhdpi/sud_load_skip_en.png new file mode 100644 index 000000000..1773f13c2 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_skip_en.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_skip_zh.png b/common/src/main/res/mipmap-xhdpi/sud_load_skip_zh.png new file mode 100644 index 000000000..ddfe6ceb6 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_skip_zh.png differ diff --git a/common/src/main/res/mipmap-xhdpi/sud_load_zh.png b/common/src/main/res/mipmap-xhdpi/sud_load_zh.png new file mode 100644 index 000000000..a81db51b5 Binary files /dev/null and b/common/src/main/res/mipmap-xhdpi/sud_load_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_1.png b/common/src/main/res/mipmap-xxhdpi/sub_1.png new file mode 100644 index 000000000..a54791a4a Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_1.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_2.png b/common/src/main/res/mipmap-xxhdpi/sub_2.png new file mode 100644 index 000000000..8d633e398 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_2.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_3.png b/common/src/main/res/mipmap-xxhdpi/sub_3.png new file mode 100644 index 000000000..1b46f4465 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_3.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_again_en.png b/common/src/main/res/mipmap-xxhdpi/sub_again_en.png new file mode 100644 index 000000000..a6602cfb8 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_again_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_again_zh.png b/common/src/main/res/mipmap-xxhdpi/sub_again_zh.png new file mode 100644 index 000000000..add3f5671 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_again_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_bg.png b/common/src/main/res/mipmap-xxhdpi/sub_bg.png new file mode 100644 index 000000000..1ad394bf6 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_bg.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_bg2.png b/common/src/main/res/mipmap-xxhdpi/sub_bg2.png new file mode 100644 index 000000000..da1e6a5ee Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_bg2.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_draw_en.png b/common/src/main/res/mipmap-xxhdpi/sub_draw_en.png new file mode 100644 index 000000000..18be3bcfe Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_draw_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_draw_zh.png b/common/src/main/res/mipmap-xxhdpi/sub_draw_zh.png new file mode 100644 index 000000000..293d63557 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_draw_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_leave_en.png b/common/src/main/res/mipmap-xxhdpi/sub_leave_en.png new file mode 100644 index 000000000..f560d3924 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_leave_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_leave_zh.png b/common/src/main/res/mipmap-xxhdpi/sub_leave_zh.png new file mode 100644 index 000000000..5acd8ced7 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_leave_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_loss_en.png b/common/src/main/res/mipmap-xxhdpi/sub_loss_en.png new file mode 100644 index 000000000..08d24b34d Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_loss_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_loss_zh.png b/common/src/main/res/mipmap-xxhdpi/sub_loss_zh.png new file mode 100644 index 000000000..293871787 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_loss_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_over_en.png b/common/src/main/res/mipmap-xxhdpi/sub_over_en.png new file mode 100644 index 000000000..8320eeef3 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_over_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_over_zh.png b/common/src/main/res/mipmap-xxhdpi/sub_over_zh.png new file mode 100644 index 000000000..3736af6ba Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_over_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_vs.png b/common/src/main/res/mipmap-xxhdpi/sub_vs.png new file mode 100644 index 000000000..e2632e3df Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_vs.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_win_en.png b/common/src/main/res/mipmap-xxhdpi/sub_win_en.png new file mode 100644 index 000000000..97f1cbf58 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_win_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_win_hat.png b/common/src/main/res/mipmap-xxhdpi/sub_win_hat.png new file mode 100644 index 000000000..e13737596 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_win_hat.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sub_win_zh.png b/common/src/main/res/mipmap-xxhdpi/sub_win_zh.png new file mode 100644 index 000000000..d8860a4e3 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sub_win_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_bg_double.png b/common/src/main/res/mipmap-xxhdpi/sud_load_bg_double.png new file mode 100644 index 000000000..78260dda2 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_bg_double.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_bg_multiple.png b/common/src/main/res/mipmap-xxhdpi/sud_load_bg_multiple.png new file mode 100644 index 000000000..881fb74ab Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_bg_multiple.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_double.png b/common/src/main/res/mipmap-xxhdpi/sud_load_double.png new file mode 100644 index 000000000..7d728062c Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_double.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_en.png b/common/src/main/res/mipmap-xxhdpi/sud_load_en.png new file mode 100644 index 000000000..a8dcd1d1e Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_multiple.png b/common/src/main/res/mipmap-xxhdpi/sud_load_multiple.png new file mode 100644 index 000000000..1dccf0371 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_multiple.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_skip_en.png b/common/src/main/res/mipmap-xxhdpi/sud_load_skip_en.png new file mode 100644 index 000000000..cbcf8d603 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_skip_en.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_skip_zh.png b/common/src/main/res/mipmap-xxhdpi/sud_load_skip_zh.png new file mode 100644 index 000000000..5ccdaa950 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_skip_zh.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/sud_load_zh.png b/common/src/main/res/mipmap-xxhdpi/sud_load_zh.png new file mode 100644 index 000000000..0e3084cb2 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/sud_load_zh.png differ diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index f7b69bd82..8df4b9592 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -1500,4 +1500,7 @@ Limited ride And limited avatar frame 1.Dragon\'s Wealth is a free golden bean benefit provided to live stream viewers by users who have activated the 【God Guardian】 feature; 2.Users who follow the anchor and participate in the activity will divide the gold beans of the activity after the countdown of five minutes ends; 3.The final interpretation of this activity belongs to PDLIVE. + + + *10% of the threshold will be charged as ticket diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index 0ca615a3c..c2fd83d9f 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1501,4 +1501,6 @@ 短劇 完成*1 主播正在PK,稍後再試 + + *將收取門檻的10%作為門票 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index d2ff10baf..269cb23b0 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1500,4 +1500,6 @@ 短劇 完成*1 主播正在PK,稍後再試 + + *將收取門檻的10%作為門票 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index f118df88a..540099933 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1498,4 +1498,5 @@ 完成*1 主播正在PK,稍後再試 + *將收取門檻的10%作為門票 diff --git a/common/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml index d7a566eca..d0ad06807 100644 --- a/common/src/main/res/values/colors.xml +++ b/common/src/main/res/values/colors.xml @@ -13,6 +13,7 @@ #98000000 #323232 #fff + #99FFFFFF #85ffffff #969696 #f5f5f5 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 136420081..dfa53e5c1 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1506,4 +1506,7 @@ Limited ride And limited avatar frame Theater The anchor is in PK, please try again later once + + + *10% of the threshold will be charged as ticket diff --git a/lib_google/build.gradle b/lib_google/build.gradle index 9670d94c4..a236a90cc 100644 --- a/lib_google/build.gradle +++ b/lib_google/build.gradle @@ -30,7 +30,7 @@ dependencies { implementation rootProject.ext.dependencies["appcompat-androidx"] //谷歌内购 - api 'com.android.billingclient:billing:5.0.0' + api 'com.android.billingclient:billing:7.0.0' //谷歌登录 api 'com.google.android.gms:play-services-auth:15.0.0' api 'com.google.android.gms:play-services-ads-identifier:15.0.1' diff --git a/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java index 1a568cb1f..8d115b657 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java @@ -4,6 +4,7 @@ import android.Manifest; import android.app.Activity; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -33,8 +34,13 @@ import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.RoomMicStatusModel; import com.yunbao.common.bean.SudGameChatImModel; +import com.yunbao.common.bean.SudGameInfoBean; +import com.yunbao.common.bean.SudGameScoreBean; import com.yunbao.common.bean.SudGameUserModel; +import com.yunbao.common.dialog.SudGameDoubleDialog; +import com.yunbao.common.dialog.SudGameMultipleDialog; import com.yunbao.common.dialog.SudGameInputPopupWindow; +import com.yunbao.common.dialog.SudLoadDialog; import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.event.SubGameEvent; import com.yunbao.common.event.SudGameSocketImEvent; @@ -44,7 +50,6 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.imrongcloud.GameRyMicManager; import com.yunbao.common.sud.QuickStartGameViewModel; -import com.yunbao.common.sud.decorator.SudFSMMGDecorator; import com.yunbao.common.sud.model.GameConfigModel; import com.yunbao.common.sud.model.GameViewInfoModel; import com.yunbao.common.sud.state.SudMGPAPPState; @@ -93,6 +98,9 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M private ProcessResultUtil mProcessResultUtil; private List muteUser = new ArrayList<>(); private boolean imOff; + private SudGameDoubleDialog sudGameDoubleDialog;//双人游戏弹窗 + private SudGameMultipleDialog sudGameMultipleDialog;//多人游戏弹窗 + private SudLoadDialog sudLoadDialog;//加载弹窗 @Override protected int getLayoutId() { @@ -227,7 +235,8 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class); mInteractionID = mCreateSudRoomModel.getLongSudGameId(); mLiveUid = mCreateSudRoomModel.getSudGameRoomId(); - + //第二次进入时,viewmodel数据丢失,所以初始化时直接获取 + gameViewModel.getScore(mCreateSudRoomModel.getSudGameRoomId(),mContext); gameContainer = findViewById(R.id.game_container); roomName = findViewById(R.id.room_name); roomNumber = findViewById(R.id.room_number); @@ -428,6 +437,7 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值 + gameConfigModel.ui.gameSettle.hide = true;//是否隐藏结算界面(false: 显示; true: 隐藏,默认为 false) gameConfigModel.ui.lobby_players.custom = true; gameConfigModel.ui.join_btn.custom = true; @@ -453,7 +463,33 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M gameViewRectModel.bottom = DpUtil.dp2px(155); gameViewModel.gameViewRectModel = gameViewRectModel; + //初始化结算弹窗 + sudGameDoubleDialog = new SudGameDoubleDialog(this);//双人游戏 + sudGameMultipleDialog = new SudGameMultipleDialog(this);//多人游戏 + sudLoadDialog = new SudLoadDialog(this);//加载弹窗 + //游戏结算结束 + gameViewModel.listMutableLiveData.observe(this, sudSettleBeans -> { + if (sudLoadDialog.getClickStatus() == 0) { + sudLoadDialog.dismiss(); + if (gameViewModel.getSudGameScoreBean().getGame_mode() == 1) { + //双人游戏 + sudGameDoubleDialog.setSudSettleList(sudSettleBeans); + sudGameDoubleDialog.showDialog(); + } else { + //多人游戏 + sudGameMultipleDialog.setSudSettleList(sudSettleBeans); + sudGameMultipleDialog.showDialog(); + } + } + }); + + //加载弹窗监听 + sudLoadDialog.setOnDismissListener(() -> { + if (sudLoadDialog.getClickStatus() == 2){ + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false)); + } + }); } @Subscribe(threadMode = ThreadMode.MAIN) @@ -461,12 +497,14 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M switch (event.getSudMGPMGState()) { case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN: - - LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { + //获取筹码信息,检查是否足够 + LiveNetManager.get(mContext).getScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { @Override - public void onSuccess(CheckRemainingBalance data) { - if (TextUtils.equals(String.valueOf(data.getGoldenBeanRemainingBalance()), "1")) { + public void onSuccess(SudGameScoreBean data) { + if (data.getGolden_bean_remaining_balance() == 1) { + gameViewModel.setSudGameScoreBean(data); gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1); + gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfReady(event.getSubReady()); } else { if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ToastUtil.show("貨幣数量不足 "); @@ -491,9 +529,31 @@ public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.M }); break; case SudMGPMGState.MG_COMMON_GAME_SETTLE: + //结算状态 gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1); + sudLoadDialog.setClickStatus(0); + sudLoadDialog.setDouble(gameViewModel.getSudGameScoreBean().getGame_mode()); + sudLoadDialog.showDialog(); + //获取用户信息 + LiveNetManager.get(mContext).getSudGameInfo(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback>() { + @Override + public void onSuccess(List data) { + if (!data.isEmpty()){ + gameViewModel.setSudGameInfoBeanList(data); + gameViewModel.sudGameRank(event.getMgCommonGameSettle()); + }else { + ToastUtil.show(getString(R.string.net_error)); + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); break; case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN: + //点击开始游戏 LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(), mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { diff --git a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java index 4b8130988..7d5926ea5 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java @@ -4,6 +4,7 @@ import android.Manifest; import android.app.Activity; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -16,6 +17,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.alibaba.android.arouter.facade.annotation.Route; +import com.blankj.utilcode.util.LogUtils; import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.lzf.easyfloat.EasyFloat; @@ -32,10 +34,16 @@ import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.RoomMicStatusModel; import com.yunbao.common.bean.SudGameChatImModel; +import com.yunbao.common.bean.SudGameInfoBean; +import com.yunbao.common.bean.SudGameScoreBean; import com.yunbao.common.bean.SudGameUserModel; +import com.yunbao.common.bean.SudSettleBean; +import com.yunbao.common.dialog.AbsDialogCenterPopupWindow; +import com.yunbao.common.dialog.SudGameDoubleDialog; +import com.yunbao.common.dialog.SudGameMultipleDialog; import com.yunbao.common.dialog.SudGameInputPopupWindow; +import com.yunbao.common.dialog.SudLoadDialog; import com.yunbao.common.event.CheckRemainingBalanceEvent; -import com.yunbao.common.event.LiveFloatEvent; import com.yunbao.common.event.SudGameSocketImEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; @@ -70,7 +78,6 @@ import cn.rongcloud.rtc.api.RCRTCRemoteUser; import cn.rongcloud.rtc.api.RCRTCRoom; import cn.rongcloud.rtc.api.stream.RCRTCInputStream; import cn.rongcloud.rtc.base.RTCErrorCode; -import io.agora.beautyapi.faceunity.agora.LiveFloatView; import io.agora.beautyapi.faceunity.agora.SWAuManager; import io.rong.imlib.IRongCoreCallback; import io.rong.imlib.IRongCoreEnum; @@ -96,6 +103,9 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M private List muteUser = new ArrayList<>(); private boolean imOff; private boolean isSw = CommonAppConfig.getInstance().getConfig().isSw(); + private SudGameDoubleDialog sudGameDoubleDialog;//双人游戏弹窗 + private SudGameMultipleDialog sudGameMultipleDialog;//多人游戏弹窗 + private SudLoadDialog sudLoadDialog;//加载弹窗 @Override protected int getLayoutId() { @@ -257,6 +267,8 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class); mInteractionID = mCreateSudRoomModel.getLongSudGameId(); mLiveUid = mCreateSudRoomModel.getSudGameRoomId(); + //第二次进入时,viewmodel数据丢失,所以初始化时直接获取 + gameViewModel.getScore(mCreateSudRoomModel.getSudGameRoomId(),mContext); gameContainer = findViewById(R.id.game_container); roomName = findViewById(R.id.room_name); @@ -476,6 +488,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值 + gameConfigModel.ui.gameSettle.hide = true;//是否隐藏结算界面(false: 显示; true: 隐藏,默认为 false) gameConfigModel.ui.lobby_players.custom = true; gameConfigModel.ui.join_btn.custom = true; @@ -501,7 +514,34 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M gameViewRectModel.bottom = DpUtil.dp2px(155); gameViewModel.gameViewRectModel = gameViewRectModel; + //初始化结算弹窗 + sudGameDoubleDialog = new SudGameDoubleDialog(this);//双人游戏 + sudGameMultipleDialog = new SudGameMultipleDialog(this);//多人游戏 + sudLoadDialog = new SudLoadDialog(this);//加载弹窗 + //游戏结算结束 + gameViewModel.listMutableLiveData.observe(this, sudSettleBeans -> { + //观察结算排名数据,点击跳过和再来一局不需要显示结算界面 + if (sudLoadDialog.getClickStatus() == 0) { + sudLoadDialog.dismiss(); + if (gameViewModel.getSudGameScoreBean().getGame_mode() == 1) { + //双人游戏 + sudGameDoubleDialog.setSudSettleList(sudSettleBeans); + sudGameDoubleDialog.showDialog(); + } else { + //多人游戏 + sudGameMultipleDialog.setSudSettleList(sudSettleBeans); + sudGameMultipleDialog.showDialog(); + } + } + }); + + //加载弹窗消失监听,自动消失和点击跳过在这个监听中都不做处理 + sudLoadDialog.setOnDismissListener(() -> { + if (sudLoadDialog.getClickStatus() == 2){ + Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false)); + } + }); } @Subscribe(threadMode = ThreadMode.MAIN) @@ -509,12 +549,14 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M switch (event.getSudMGPMGState()) { case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN: - - LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { + //获取筹码信息,检查是否足够 + LiveNetManager.get(mContext).getScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { @Override - public void onSuccess(CheckRemainingBalance data) { - if (TextUtils.equals(String.valueOf(data.getGoldenBeanRemainingBalance()), "1")) { + public void onSuccess(SudGameScoreBean data) { + if (data.getGolden_bean_remaining_balance() == 1) { + gameViewModel.setSudGameScoreBean(data); gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1); + gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfReady(event.getSubReady()); } else { if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ToastUtil.show("貨幣数量不足 "); @@ -539,9 +581,31 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M }); break; case SudMGPMGState.MG_COMMON_GAME_SETTLE: + //结算状态 gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1); + sudLoadDialog.setClickStatus(0); + sudLoadDialog.setDouble(gameViewModel.getSudGameScoreBean().getGame_mode()); + sudLoadDialog.showDialog(); + //先获取用户信息再进行结算处理 + LiveNetManager.get(mContext).getSudGameInfo(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback>() { + @Override + public void onSuccess(List data) { + if (!data.isEmpty()){ + gameViewModel.setSudGameInfoBeanList(data); + gameViewModel.sudGameRank(event.getMgCommonGameSettle());//结算游戏 + }else { + ToastUtil.show(getString(R.string.net_error)); + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); break; case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN: + //点击开始游戏 LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(), mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { @Override public void onSuccess(CheckRemainingBalance data) { diff --git a/package_config.gradle b/package_config.gradle index da551c1dd..5397b1b5f 100644 --- a/package_config.gradle +++ b/package_config.gradle @@ -1,4 +1,11 @@ android{ + dexOptions { + jumboMode = true + javaMaxHeapSize "8g" + preDexLibraries = true + threadCount = 8 + } + flavorDimensions 'packageApk' productFlavors { link_test {