正在查看: Rilo v2.0.21 应用的 SudGameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 SudGameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.vdx.sud;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.blankj.utilcode.util.BarUtils;
import com.google.android.material.button.MaterialButton;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.vdx.sud.BaseGameViewModel;
import com.vdx.sud.SudGameActivity;
import com.vdx.sud.base.BaseActivity;
import com.vdx.sud.model.DataCallback;
import com.vdx.sud.model.LoadingScreen;
import com.vdx.sud.service.LudoGameService;
import com.vdx.sud.service.LudoGameServiceUtil;
import com.vdx.sud.utils.DensityUtils;
import com.vdx.sud.utils.SystemUtils;
import com.vdx.sud.utils.Utils;
import java.util.Objects;
import java.util.function.Consumer;
import tech.sud.mgp.SudMGPWrapper.model.GameConfigModel;
import tech.sud.mgp.SudMGPWrapper.model.GameViewInfoModel;
import tech.sud.mgp.SudMGPWrapper.state.SudMGPMGState;
import timber.log.Timber;
public class SudGameActivity extends BaseActivity {
public static boolean isSudGameActivityOpen = false;
private ImageView closeScreenBtn;
private long gameId;
private String roomId;
private String sessionToken;
private String userId;
MaterialButton videoCallButton;
private long videoId;
private final SudGameViewModel gameViewModel = new SudGameViewModel();
private Integer totalWinAmount = 0;
String closeScreenMessage = "Are you sure you want to resign from the game?";
private boolean screenClosed = false;
private final BroadcastReceiver broadcastReceiver = new AnonymousClass3();
private void showGameModeDialog() {
}
public void updateStatusBar() {
}
public static void start(Context context, String str, long j2, String str2, String str3) {
Intent intent = new Intent(context, (Class<?>) SudGameActivity.class);
intent.putExtra("roomId", str);
intent.putExtra("gameId", j2);
intent.putExtra("userId", str2);
intent.putExtra("sessionToken", str3);
context.startActivity(intent);
}
public static void start(Context context, String str, long j2, String str2, String str3, Long l) {
Intent intent = new Intent(context, (Class<?>) SudGameActivity.class);
intent.putExtra("roomId", str);
intent.putExtra("gameId", j2);
intent.putExtra("userId", str2);
intent.putExtra("videoId", l);
intent.putExtra("sessionToken", str3);
context.startActivity(intent);
}
@Override
protected void setStatusBar() {
updateStatusBar();
}
@Override
protected boolean beforeSetContentView() {
this.roomId = getIntent().getStringExtra("roomId");
this.gameId = getIntent().getLongExtra("gameId", 0L);
this.videoId = getIntent().getLongExtra("videoId", 0L);
this.userId = getIntent().getStringExtra("userId");
this.sessionToken = getIntent().getStringExtra("sessionToken");
return super.beforeSetContentView();
}
@Override
protected int getLayoutId() {
return R.layout.activity_game;
}
@Override
protected void initWidget() {
super.initWidget();
isSudGameActivityOpen = true;
this.closeScreenBtn = (ImageView) findViewById(R.id.close_screen_btn);
this.videoCallButton = findViewById(R.id.video_call_button);
final LinearLayout linearLayout = (LinearLayout) findViewById(R.id.loading_screen);
linearLayout.setVisibility(0);
GameViewInfoModel.GameViewRectModel gameViewRectModel = new GameViewInfoModel.GameViewRectModel();
gameViewRectModel.left = 0;
gameViewRectModel.top = DensityUtils.dp2px(this, 54.0f) + BarUtils.getStatusBarHeight();
gameViewRectModel.right = 0;
gameViewRectModel.bottom = DensityUtils.dp2px(this, 54.0f);
this.gameViewModel.gameViewRectModel = gameViewRectModel;
GameConfigModel gameConfigModel = this.gameViewModel.getGameConfigModel();
gameConfigModel.ui.ping.hide = true;
gameConfigModel.ui.version.hide = true;
gameConfigModel.ui.game_selected_tips.hide = true;
gameConfigModel.ui.game_settle_again_btn.hide = true;
gameConfigModel.ui.game_settle_close_btn.hide = true;
gameConfigModel.ui.game_managed_image.hide = true;
this.gameViewModel.languageCode = SystemUtils.getLanguageCode(this);
this.gameViewModel.setDataCallback(new DataCallback() {
@Override
public final void onDataChanged(Object obj) {
SudGameActivity.this.m1101lambda$initWidget$2$comvdxsudSudGameActivity(linearLayout, obj);
}
});
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
public void handleOnBackPressed() {
SudGameActivity sudGameActivity = SudGameActivity.this;
sudGameActivity.showDialog(sudGameActivity.closeScreenMessage);
}
});
handleVideoCallButton();
}
void m1101lambda$initWidget$2$comvdxsudSudGameActivity(LinearLayout linearLayout, Object obj) {
if (obj instanceof SudMGPMGState.MGCommonGameSettle) {
final SudMGPMGState.MGCommonGameSettle mGCommonGameSettle = (SudMGPMGState.MGCommonGameSettle) obj;
this.gameViewModel.handler.postDelayed(new Runnable() {
@Override
public final void run() {
SudGameActivity.this.m1100lambda$initWidget$1$comvdxsudSudGameActivity(mGCommonGameSettle);
}
}, 3000L);
} else {
if (!(obj instanceof LoadingScreen) || ((LoadingScreen) obj).isShow()) {
return;
}
linearLayout.setVisibility(8);
}
}
void m1100lambda$initWidget$1$comvdxsudSudGameActivity(SudMGPMGState.MGCommonGameSettle mGCommonGameSettle) {
mGCommonGameSettle.results.forEach(new Consumer() {
@Override
public final void accept(Object obj) {
SudGameActivity.this.m1099lambda$initWidget$0$comvdxsudSudGameActivity((SudMGPMGState.MGCommonGameSettle.PlayerResult) obj);
}
});
finish();
stopServiceFunc();
this.screenClosed = true;
}
void m1099lambda$initWidget$0$comvdxsudSudGameActivity(SudMGPMGState.MGCommonGameSettle.PlayerResult playerResult) {
if (Objects.equals(playerResult.uid, this.userId) && playerResult.rank == 1) {
Toast.makeText((Context) this.context, (CharSequence) "You won", 0).show();
}
}
private void handleVideoCallButton() {
try {
if (Long.valueOf(getIntent().getLongExtra("videoId", -1L)).longValue() == -1) {
MaterialButton materialButton = this.videoCallButton;
if (materialButton != null) {
materialButton.setVisibility(8);
}
} else {
MaterialButton materialButton2 = this.videoCallButton;
if (materialButton2 != null) {
materialButton2.setVisibility(0);
this.videoCallButton.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SudGameActivity.this.m1098lambda$handleVideoCallButton$3$comvdxsudSudGameActivity(view);
}
});
}
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
void m1098lambda$handleVideoCallButton$3$comvdxsudSudGameActivity(View view) {
openVideoCallActivityThroughReflection();
}
private void openVideoCallActivityThroughReflection() {
try {
startActivity(new Intent((Context) this, Class.forName("app.callpe.ui.call.ZegoVideoCallActivity")));
} catch (ClassNotFoundException e2) {
e2.printStackTrace();
}
}
@Override
protected void initData() {
super.initData();
this.gameViewModel.userId = this.userId;
this.gameViewModel.sessionToken = this.sessionToken;
if (this.videoId != 0) {
this.closeScreenMessage = "Are you sure you want to close the game?";
ImageView imageView = this.closeScreenBtn;
if (imageView != null) {
imageView.setVisibility(0);
}
updateStatusBar();
this.gameViewModel.switchGame(this, this.roomId, this.gameId);
this.gameViewModel.addPauseAsyncMgId(this.gameId);
this.gameViewModel.startPingUpdateScheduler(this, Long.valueOf(this.videoId), "VIDEO_CALL");
return;
}
this.gameViewModel.canStartGame(this, new BaseGameViewModel.GameGetCodeListener() {
@Override
public void onSuccess(String str) {
try {
JsonElement parseString = JsonParser.parseString(str);
if (parseString.isJsonObject()) {
JsonObject asJsonObject = parseString.getAsJsonObject();
SudGameActivity.this.totalWinAmount = Integer.valueOf(asJsonObject.get("totalWinAmount").getAsInt());
SudGameActivity.this.totalWinAmount = Integer.valueOf((int) ((asJsonObject.has("totalBetAmount") ? asJsonObject.get("totalBetAmount").getAsDouble() : 0.0d) / (asJsonObject.has("totalUsers") ? asJsonObject.get("totalUsers").getAsInt() : 0)));
SudGameActivity.this.closeScreenMessage = "Are you sure you want to resign from the game?.\n\nNote: You will lose ₹" + SudGameActivity.this.totalWinAmount;
if (SudGameActivity.this.closeScreenBtn != null) {
SudGameActivity.this.closeScreenBtn.setVisibility(0);
}
}
} catch (Exception e2) {
Timber.e(e2);
}
SudGameActivity.this.updateStatusBar();
SudGameViewModel sudGameViewModel = SudGameActivity.this.gameViewModel;
?? r0 = SudGameActivity.this;
sudGameViewModel.switchGame(r0, ((SudGameActivity) r0).roomId, SudGameActivity.this.gameId);
SudGameActivity.this.gameViewModel.addPauseAsyncMgId(SudGameActivity.this.gameId);
}
@Override
public void onFailed() {
SudGameActivity.this.handleScreen();
}
});
}
@Override
protected void setListeners() {
super.setListeners();
final FrameLayout frameLayout = (FrameLayout) findViewById(R.id.game_container);
this.gameViewModel.gameViewLiveData.observe(this, new Observer() {
public final void onChanged(Object obj) {
SudGameActivity.lambda$setListeners$4(frameLayout, (View) obj);
}
});
this.closeScreenBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SudGameActivity.this.m1102lambda$setListeners$5$comvdxsudSudGameActivity(view);
}
});
}
static void lambda$setListeners$4(FrameLayout frameLayout, View view) {
if (view == null) {
frameLayout.removeAllViews();
} else {
frameLayout.addView(view, -1, -1);
}
}
void m1102lambda$setListeners$5$comvdxsudSudGameActivity(View view) {
showDialog(this.closeScreenMessage);
}
public void onWindowFocusChanged(boolean z) {
super.onWindowFocusChanged(z);
if (z) {
updateStatusBar();
}
}
protected void onResume() {
super.onResume();
updateStatusBar();
this.gameViewModel.onResume();
}
protected void onPause() {
super.onPause();
}
public void finish() {
this.gameViewModel.destroyMG();
super.finish();
}
protected void onDestroy() {
unRegisterReceiver();
super.onDestroy();
isSudGameActivityOpen = false;
this.gameViewModel.destroyMG();
if (this.videoId != 0) {
this.gameViewModel.stopPingUpdateScheduler();
}
}
public void showDialog(String str) {
try {
new AlertDialog.Builder(this).setMessage(str).setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
SudGameActivity.this.m1103lambda$showDialog$6$comvdxsudSudGameActivity(dialogInterface, i2);
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.dismiss();
}
}).show();
} catch (Exception e2) {
Timber.e(e2, "showDialog: ", new Object[0]);
}
}
void m1103lambda$showDialog$6$comvdxsudSudGameActivity(DialogInterface dialogInterface, int i2) {
if (this.videoId == 0) {
this.gameViewModel.resign(this, this.roomId);
}
this.gameViewModel.destroyMG();
handleScreen();
}
public void stopServiceFunc() {
LudoGameService ludoGameService = new LudoGameService();
Intent intent = new Intent((Context) this, ludoGameService.getClass());
if (Utils.isMyServiceRunning(ludoGameService.getClass(), (Activity) this)) {
stopService(intent);
Timber.d("Service stopped!!", new Object[0]);
} else {
Timber.d("Service is already stopped!!", new Object[0]);
}
}
public void handleScreen() {
if (isTaskRoot()) {
Intent launchIntentForPackage = getPackageManager().getLaunchIntentForPackage(getPackageName());
if (launchIntentForPackage != null) {
launchIntentForPackage.addFlags(67108864);
startActivity(launchIntentForPackage);
finish();
return;
}
return;
}
finish();
}
class AnonymousClass3 extends BroadcastReceiver {
AnonymousClass3() {
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() != null && intent.getAction().equals(LudoGameServiceUtil.LUDO_GAME_ENDED)) {
intent.setAction("");
String stringExtra = intent.getStringExtra("roomId");
long longExtra = intent.getLongExtra("videoId", 0L);
if ((stringExtra == null || SudGameActivity.this.roomId == null || !stringExtra.equals(SudGameActivity.this.roomId)) && (SudGameActivity.this.videoId == 0 || longExtra != SudGameActivity.this.videoId)) {
return;
}
SudGameActivity.this.gameViewModel.handler.postDelayed(new Runnable() {
@Override
public final void run() {
SudGameActivity.AnonymousClass3.this.m1104lambda$onReceive$0$comvdxsudSudGameActivity$3();
}
}, 4000L);
}
}
void m1104lambda$onReceive$0$comvdxsudSudGameActivity$3() {
if (SudGameActivity.this.screenClosed) {
return;
}
SudGameActivity.this.handleScreen();
SudGameActivity.this.stopServiceFunc();
}
}
private void registerReceiver() {
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(LudoGameServiceUtil.LUDO_GAME_ENDED);
localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
}
private void unRegisterReceiver() {
if (this.broadcastReceiver != null) {
LocalBroadcastManager.getInstance(this).unregisterReceiver(this.broadcastReceiver);
}
}
protected void onStart() {
super.onStart();
registerReceiver();
}
protected void onStop() {
super.onStop();
}
}