正在查看: Rilo v2.0.21 应用的 SpinWheelGameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 SpinWheelGameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.ui.user.games.spinner;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import androidx.activity.ComponentActivity;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import app.callpe.adapters.SpinWheelHistoryAdapter;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.custom.games.spinwheel.LuckyWheelView;
import app.callpe.common.utils.custom.games.spinwheel.model.LuckyItem;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.common.utils.helper_functions.Utils;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.SpinWheelGameModel;
import app.callpe.databinding.ActivitySpinwheelGameBinding;
import app.callpe.ui.dialog.RechargeDialog;
import app.callpe.ui.home.BaseActivity;
import app.callpe.ui.payment.WalletActivity;
import app.callpe.ui.user.games.GameViewModel;
import app.callpe.ui.user.games.bottomsheet.GameRulesInfoSheet;
import app.callpe.ui.user.games.bottomsheet.GameWinLoseSheet;
import com.google.android.material.snackbar.Snackbar;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.random.Random;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
import timber.log.Timber;
@Metadata(d1 = {"\u0000~\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0010\t\n\u0002\b\u0004\b\u0007\u0018\u0000 H2\b\u0012\u0004\u0012\u00020\u00020\u0001:\u0002GHB\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\u001f\u001a\u00020 H\u0002J\b\u0010!\u001a\u00020\u000fH\u0002J\u0010\u0010\"\u001a\u00020\u000f2\u0006\u0010#\u001a\u00020\u0007H\u0002J\b\u0010$\u001a\u00020 H\u0002J\b\u0010%\u001a\u00020 H\u0002J\u0010\u0010&\u001a\u00020 2\u0006\u0010'\u001a\u00020(H\u0002J\u0018\u0010)\u001a\u00020 2\u0006\u0010\u000e\u001a\u00020\u000f2\u0006\u0010'\u001a\u00020(H\u0002J\u0010\u0010*\u001a\u00020\u00022\u0006\u0010+\u001a\u00020,H\u0016J\b\u0010-\u001a\u00020 H\u0002J\b\u0010.\u001a\u00020 H\u0002J\b\u0010/\u001a\u00020 H\u0002J\b\u00100\u001a\u00020 H\u0016J\b\u00101\u001a\u00020 H\u0002J\u0012\u00102\u001a\u00020 2\b\u00103\u001a\u0004\u0018\u000104H\u0014J\u0010\u00105\u001a\u00020\u00112\u0006\u00106\u001a\u000207H\u0016J\b\u00108\u001a\u00020 H\u0014J\b\u00109\u001a\u00020 H\u0014J\b\u0010:\u001a\u00020 H\u0002J\b\u0010;\u001a\u00020 H\u0002J\u0010\u0010<\u001a\u00020 2\u0006\u0010=\u001a\u00020\u0007H\u0002J\b\u0010>\u001a\u00020 H\u0002J\b\u0010?\u001a\u00020 H\u0002J\b\u0010@\u001a\u00020 H\u0002J\b\u0010A\u001a\u00020 H\u0002J\b\u0010B\u001a\u00020 H\u0002J\u0018\u0010C\u001a\u00020 2\u0006\u0010D\u001a\u00020E2\u0006\u0010F\u001a\u00020\u0011H\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\b\u001a\u0012\u0012\u0004\u0012\u00020\n0\tj\b\u0012\u0004\u0012\u00020\n`\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0015X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0018\u001a\u00020\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u0019\u001a\u00020\u001a8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u001d\u0010\u001e\u001a\u0004\b\u001b\u0010\u001c¨\u0006I"}, d2 = {"Lapp/callpe/ui/user/games/spinner/SpinWheelGameActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivitySpinwheelGameBinding;", "()V", "adapter", "Lapp/callpe/adapters/SpinWheelHistoryAdapter;", "currentSelectedColor", "", "data", "Ljava/util/ArrayList;", "Lapp/callpe/common/utils/custom/games/spinwheel/model/LuckyItem;", "Lkotlin/collections/ArrayList;", "gameWinLoseSheet", "Lapp/callpe/ui/user/games/bottomsheet/GameWinLoseSheet;", "indexWon", "", "isSpinning", "", "maxBetAmount", "retryCount", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "userHasLowLevel", "userLevel", "userLevelToUnlockGames", "viewModel", "Lapp/callpe/ui/user/games/GameViewModel;", "getViewModel", "()Lapp/callpe/ui/user/games/GameViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "checkForUserLevel", "", "getRandomIndex", "getTargetIndex", "resultColor", "handleMaxBet", "handleRedWhiteButtonClicks", "handleSpinWheelResults", "gameResult", "Lapp/callpe/data/model/SpinWheelGameModel;", "handleWinLoose", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "initViews", "observeAmountEt", "observeEvent", "onBackPressed", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "onResume", "onStop", "openGameRulesBottomSheet", "refresh", "saveBetAmount", "amount", "setSpinnerWheel", "setUpToolbar", "setUserLevelRequiredToUnlockGames", "setupRv", "showSnackbar", "showWinLoseDialog", "winAmount", "", "isWinner", "COLORS", "Companion", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class SpinWheelGameActivity extends BaseActivity<ActivitySpinwheelGameBinding> {
public static final int spinWheelHistoryCount = 10;
private SpinWheelHistoryAdapter adapter;
private GameWinLoseSheet gameWinLoseSheet;
private boolean isSpinning;
private int retryCount;
private Toolbar toolbar;
private boolean userHasLowLevel;
private final Lazy viewModel;
private ArrayList<LuckyItem> data = new ArrayList<>();
private String currentSelectedColor = "";
private int indexWon = -1;
private int userLevelToUnlockGames = -1;
private int maxBetAmount = -1;
private String userLevel = "0";
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0005\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004j\u0002\b\u0005¨\u0006\u0006"}, d2 = {"Lapp/callpe/ui/user/games/spinner/SpinWheelGameActivity$COLORS;", "", "(Ljava/lang/String;I)V", "RED", "WHITE", "BLACK", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public enum COLORS {
RED,
WHITE,
BLACK
}
public SpinWheelGameActivity() {
final ComponentActivity componentActivity = (ComponentActivity) this;
final Function0 function0 = null;
this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(GameViewModel.class), new Function0<ViewModelStore>() {
{
super(0);
}
public final ViewModelStore m2412invoke() {
return componentActivity.getViewModelStore();
}
}, new Function0<ViewModelProvider.Factory>() {
{
super(0);
}
public final ViewModelProvider.Factory m2411invoke() {
return componentActivity.getDefaultViewModelProviderFactory();
}
}, new Function0<CreationExtras>() {
{
super(0);
}
public final CreationExtras m2413invoke() {
CreationExtras creationExtras;
Function0 function02 = function0;
return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
}
});
}
@Override
public ActivitySpinwheelGameBinding inflateLayout(LayoutInflater layoutInflater) {
Intrinsics.checkNotNullParameter(layoutInflater, "layoutInflater");
ActivitySpinwheelGameBinding inflate = ActivitySpinwheelGameBinding.inflate(layoutInflater);
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
return inflate;
}
public final GameViewModel getViewModel() {
return (GameViewModel) this.viewModel.getValue();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setStatusBarColor(ContextCompat.getColor((Context) this, 2131100053));
try {
Intent intent = getIntent();
String stringExtra = intent != null ? intent.getStringExtra("userLevel") : null;
if (stringExtra == null) {
stringExtra = "0";
}
this.userLevel = stringExtra;
if (stringExtra.length() == 0) {
getViewModel().setUserLevel(0);
} else if (!Intrinsics.areEqual(this.userLevel, "0")) {
getViewModel().setUserLevel(Integer.valueOf(Integer.parseInt(this.userLevel)));
}
} catch (Exception e) {
getViewModel().setUserLevel(0);
Timber.e(e);
}
handleMaxBet();
initViews();
setUpToolbar();
setSpinnerWheel();
observeEvent();
onClicks();
setupRv();
setUserLevelRequiredToUnlockGames();
observeAmountEt();
}
private final void observeAmountEt() {
getBinding().amountEt.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
int i;
String str;
ActivitySpinwheelGameBinding binding;
ActivitySpinwheelGameBinding binding2;
ActivitySpinwheelGameBinding binding3;
ActivitySpinwheelGameBinding binding4;
int i2;
int i3;
int i4;
int i5;
ActivitySpinwheelGameBinding binding5;
int i6;
try {
String valueOf = String.valueOf(s);
if (!(valueOf.length() > 0)) {
SpinWheelGameActivity.this.saveBetAmount("1");
return;
}
int parseInt = Integer.parseInt(valueOf);
i = SpinWheelGameActivity.this.maxBetAmount;
if (parseInt > i) {
binding4 = SpinWheelGameActivity.this.getBinding();
EditText editText = binding4.amountEt;
i2 = SpinWheelGameActivity.this.maxBetAmount;
editText.setText(String.valueOf(i2));
try {
i5 = SpinWheelGameActivity.this.maxBetAmount;
if (String.valueOf(i5).length() > 0) {
binding5 = SpinWheelGameActivity.this.getBinding();
EditText editText2 = binding5.amountEt;
i6 = SpinWheelGameActivity.this.maxBetAmount;
editText2.setSelection(String.valueOf(i6).length());
}
} catch (Exception e) {
Timber.e(e);
}
SpinWheelGameActivity spinWheelGameActivity = SpinWheelGameActivity.this;
i3 = spinWheelGameActivity.maxBetAmount;
spinWheelGameActivity.saveBetAmount(String.valueOf(i3));
StringBuilder sb = new StringBuilder();
sb.append("Winning Amount: ₹");
i4 = SpinWheelGameActivity.this.maxBetAmount;
sb.append(i4 * 2);
str = sb.toString();
binding3 = SpinWheelGameActivity.this.getBinding();
binding3.winText.setText(str);
}
if (Integer.parseInt(valueOf) == 0) {
try {
binding = SpinWheelGameActivity.this.getBinding();
binding.amountEt.setText("1");
binding2 = SpinWheelGameActivity.this.getBinding();
binding2.amountEt.setSelection(1);
} catch (Exception e2) {
Timber.e(e2);
}
str = "Winning Amount: ₹2";
} else {
SpinWheelGameActivity.this.saveBetAmount(valueOf);
str = "Winning Amount: ₹" + (Integer.parseInt(valueOf) * 2);
}
binding3 = SpinWheelGameActivity.this.getBinding();
binding3.winText.setText(str);
} catch (Exception e3) {
e3.printStackTrace();
}
}
});
}
private final void openGameRulesBottomSheet() {
GameRulesInfoSheet newInstance = GameRulesInfoSheet.INSTANCE.newInstance("SPIN_WHEEL_GAME");
newInstance.setListener(new GameRulesInfoSheet.BottomSheetDialogListener() {
@Override
public void onBottomSheetDismissed() {
}
});
newInstance.show(getSupportFragmentManager(), "gameRulesSheet");
}
public final void saveBetAmount(String amount) {
try {
SharedPref.setInt((Context) this, PrefKeys.USER_BET_AMOUNT, Integer.parseInt(amount));
} catch (Exception e) {
Timber.e(e);
}
}
private final void handleMaxBet() {
Integer num = SharedPref.getInt((Context) this, PrefKeys.MAX_BET_AMOUNT);
Intrinsics.checkNotNullExpressionValue(num, "getInt(this, PrefKeys.MAX_BET_AMOUNT)");
int intValue = num.intValue();
this.maxBetAmount = intValue;
if (intValue == -1) {
this.maxBetAmount = 100;
}
}
private final void setUserLevelRequiredToUnlockGames() {
Integer num = SharedPref.getInt((Context) this, PrefKeys.USER_LEVEL_TO_UNLOCK_GAMES);
Intrinsics.checkNotNullExpressionValue(num, "getInt(this, PrefKeys.USER_LEVEL_TO_UNLOCK_GAMES)");
this.userLevelToUnlockGames = num.intValue();
}
public final void refresh() {
Timber.e("isSpinning " + this.isSpinning, new Object[0]);
if (this.isSpinning) {
return;
}
getViewModel().getUserWalletBalance();
GameViewModel.getUserDetails$default(getViewModel(), false, 1, null);
getViewModel().getSpinWheelGameHistory(10);
}
private final void setupRv() {
((ActivitySpinwheelGameBinding) getBinding()).historyRv.setLayoutManager(new CustomLinearLayoutManager((Context) this, 0, false));
this.adapter = new SpinWheelHistoryAdapter(null, new SpinWheelHistoryAdapter.ItemClickListener() {
@Override
public void onItemClick(SpinWheelGameModel item) {
Intrinsics.checkNotNullParameter(item, "item");
}
}, 1, null);
((ActivitySpinwheelGameBinding) getBinding()).historyRv.setAdapter(this.adapter);
}
private final void onClicks() {
Integer num = SharedPref.getInt((Context) this, PrefKeys.USER_BET_AMOUNT, 1);
String str = "Winning Amount: ₹" + (num.intValue() * 2);
EditText editText = ((ActivitySpinwheelGameBinding) getBinding()).amountEt;
Intrinsics.checkNotNullExpressionValue(num, "userBetAmount");
editText.setText(String.valueOf(Math.min(num.intValue(), this.maxBetAmount)));
((ActivitySpinwheelGameBinding) getBinding()).winText.setText(str);
((ActivitySpinwheelGameBinding) getBinding()).gameRulesBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.onClicks$lambda$0(SpinWheelGameActivity.this, view);
}
});
((ActivitySpinwheelGameBinding) getBinding()).plusBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.onClicks$lambda$1(SpinWheelGameActivity.this, view);
}
});
((ActivitySpinwheelGameBinding) getBinding()).minusBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.onClicks$lambda$2(SpinWheelGameActivity.this, view);
}
});
((ActivitySpinwheelGameBinding) getBinding()).balanceParent.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.onClicks$lambda$4(SpinWheelGameActivity.this, view);
}
});
((ActivitySpinwheelGameBinding) getBinding()).unlocksOnRecharge.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.onClicks$lambda$5(SpinWheelGameActivity.this, view);
}
});
((ActivitySpinwheelGameBinding) getBinding()).play.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.onClicks$lambda$6(SpinWheelGameActivity.this, view);
}
});
handleRedWhiteButtonClicks();
}
public static final void onClicks$lambda$0(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
spinWheelGameActivity.openGameRulesBottomSheet();
}
public static final void onClicks$lambda$1(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
spinWheelGameActivity.getBinding().amountEt.clearFocus();
String obj = spinWheelGameActivity.getBinding().amountEt.getText().toString();
int parseInt = obj.length() > 0 ? Integer.parseInt(obj) : 0;
spinWheelGameActivity.getBinding().amountEt.setText(String.valueOf(parseInt != 1 ? Math.min(parseInt + 10, spinWheelGameActivity.maxBetAmount) : 10));
}
public static final void onClicks$lambda$2(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
spinWheelGameActivity.getBinding().amountEt.clearFocus();
String obj = spinWheelGameActivity.getBinding().amountEt.getText().toString();
int parseInt = obj.length() > 0 ? Integer.parseInt(obj) : 0;
spinWheelGameActivity.getBinding().amountEt.setText(String.valueOf(parseInt > 10 ? parseInt - 10 : 1));
}
public static final void onClicks$lambda$4(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
spinWheelGameActivity.startActivity(new Intent((Context) spinWheelGameActivity, (Class<?>) WalletActivity.class));
}
public static final void onClicks$lambda$5(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
try {
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String string = spinWheelGameActivity.getString(2131952496);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.recha…e_message_to_unlock_game)");
String format = String.format(string, Arrays.copyOf(new Object[]{Integer.valueOf(spinWheelGameActivity.userLevelToUnlockGames)}, 1));
Intrinsics.checkNotNullExpressionValue(format, "format(format, *args)");
RechargeDialog rechargeDialog = new RechargeDialog(null, null, null, format, null, new Function0<Unit>() {
public final void m2414invoke() {
}
public Object invoke() {
m2414invoke();
return Unit.INSTANCE;
}
}, new Function0<Unit>() {
public final void m2415invoke() {
}
public Object invoke() {
m2415invoke();
return Unit.INSTANCE;
}
});
rechargeDialog.setCancelable(true);
if (!rechargeDialog.isAdded() && !rechargeDialog.isVisible()) {
rechargeDialog.show(spinWheelGameActivity.getSupportFragmentManager(), "RechargeDialog");
}
} catch (Exception unused) {
Activity activity = (Activity) spinWheelGameActivity;
String string2 = spinWheelGameActivity.getString(2131951993);
Intrinsics.checkNotNullExpressionValue(string2, "getString(R.string.error_unknown)");
ActivityExtKt.toast(activity, string2);
}
}
public static final void onClicks$lambda$6(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).play.setClickable(false);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.clearFocus();
try {
Utils.hideKeyboard((Activity) spinWheelGameActivity);
} catch (Exception e) {
Timber.e(e);
}
spinWheelGameActivity.getRandomIndex();
try {
if (spinWheelGameActivity.currentSelectedColor.length() > 0) {
if (((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.getText().toString().length() == 0) {
ActivityExtKt.toast((Activity) spinWheelGameActivity, "Please fill an amount");
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).play.setClickable(true);
return;
}
if (Integer.parseInt(((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.getText().toString()) == 0) {
ActivityExtKt.toast((Activity) spinWheelGameActivity, "Invalid input");
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).play.setClickable(true);
return;
}
if (Integer.parseInt(((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.getText().toString()) > spinWheelGameActivity.maxBetAmount) {
ActivityExtKt.toast((Activity) spinWheelGameActivity, "Max amount limit is ₹" + spinWheelGameActivity.maxBetAmount);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).play.setClickable(true);
return;
}
if (spinWheelGameActivity.getViewModel().getBalance() != null) {
double parseDouble = Double.parseDouble(((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.getText().toString());
if (spinWheelGameActivity.getViewModel().getBalance() != null) {
Double balance = spinWheelGameActivity.getViewModel().getBalance();
Intrinsics.checkNotNull(balance);
if (balance.doubleValue() < parseDouble) {
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).play.setClickable(true);
try {
String string = spinWheelGameActivity.getString(2131952495);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.recharge_message_for_spin)");
RechargeDialog rechargeDialog = new RechargeDialog(null, null, null, string, Double.valueOf(parseDouble), new Function0<Unit>() {
public final void m2416invoke() {
}
public Object invoke() {
m2416invoke();
return Unit.INSTANCE;
}
}, new Function0<Unit>() {
public final void m2417invoke() {
}
public Object invoke() {
m2417invoke();
return Unit.INSTANCE;
}
});
rechargeDialog.setCancelable(true);
if (!rechargeDialog.isAdded() && !rechargeDialog.isVisible()) {
rechargeDialog.show(spinWheelGameActivity.getSupportFragmentManager(), "RechargeDialog");
return;
}
return;
} catch (Exception unused) {
Activity activity = (Activity) spinWheelGameActivity;
String string2 = spinWheelGameActivity.getString(2131951993);
Intrinsics.checkNotNullExpressionValue(string2, "getString(R.string.error_unknown)");
ActivityExtKt.toast(activity, string2);
return;
}
}
}
spinWheelGameActivity.getViewModel().getSpinWheelGameResponse(spinWheelGameActivity.currentSelectedColor, (long) parseDouble);
return;
}
return;
}
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).play.setClickable(true);
ActivityExtKt.toast((Activity) spinWheelGameActivity, "Please choose a color.");
} catch (Exception e2) {
e2.printStackTrace();
}
}
private final void handleRedWhiteButtonClicks() {
getBinding().whiteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.handleRedWhiteButtonClicks$lambda$7(SpinWheelGameActivity.this, view);
}
});
getBinding().redBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.handleRedWhiteButtonClicks$lambda$8(SpinWheelGameActivity.this, view);
}
});
}
public static final void handleRedWhiteButtonClicks$lambda$7(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).whiteBtn.setStrokeWidth(5);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).redBtn.setStrokeWidth(1);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).whiteBtn.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, AppCompatResources.getDrawable((Context) spinWheelGameActivity, 2131231561), (Drawable) null);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).redBtn.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, (Drawable) null, (Drawable) null);
spinWheelGameActivity.currentSelectedColor = "WHITE";
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.clearFocus();
}
public static final void handleRedWhiteButtonClicks$lambda$8(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
if (spinWheelGameActivity.isSpinning) {
return;
}
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).redBtn.setStrokeWidth(5);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).whiteBtn.setStrokeWidth(1);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).redBtn.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, AppCompatResources.getDrawable((Context) spinWheelGameActivity, 2131231561), (Drawable) null);
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).whiteBtn.setCompoundDrawablesWithIntrinsicBounds((Drawable) null, (Drawable) null, (Drawable) null, (Drawable) null);
spinWheelGameActivity.currentSelectedColor = "RED";
((ActivitySpinwheelGameBinding) spinWheelGameActivity.getBinding()).amountEt.clearFocus();
}
private final void observeEvent() {
BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new SpinWheelGameActivity$observeEvent$1(this, null), 3, (Object) null);
}
public final void showSnackbar() {
Snackbar make = Snackbar.make(getBinding().scrollView, "Something went wrong", -2);
Intrinsics.checkNotNullExpressionValue(make, "make(\n bindin…NGTH_INDEFINITE\n )");
make.setAction("Exit Game", new View.OnClickListener() {
@Override
public final void onClick(View view) {
SpinWheelGameActivity.showSnackbar$lambda$9(SpinWheelGameActivity.this, view);
}
});
make.show();
}
public static final void showSnackbar$lambda$9(SpinWheelGameActivity spinWheelGameActivity, View view) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
spinWheelGameActivity.finish();
}
public final void checkForUserLevel() {
if (getViewModel().getUserLevel() != null) {
Integer userLevel = getViewModel().getUserLevel();
Intrinsics.checkNotNull(userLevel);
if (userLevel.intValue() < this.userLevelToUnlockGames) {
getBinding().unlocksOnRechargeTxt.setText("Unlocks @ Lvl " + this.userLevelToUnlockGames);
this.userHasLowLevel = true;
View view = getBinding().play;
Intrinsics.checkNotNullExpressionValue(view, "binding.play");
view.setVisibility(8);
View view2 = getBinding().unlocksOnRecharge;
Intrinsics.checkNotNullExpressionValue(view2, "binding.unlocksOnRecharge");
view2.setVisibility(0);
return;
}
this.userHasLowLevel = false;
View view3 = getBinding().play;
Intrinsics.checkNotNullExpressionValue(view3, "binding.play");
view3.setVisibility(0);
View view4 = getBinding().unlocksOnRecharge;
Intrinsics.checkNotNullExpressionValue(view4, "binding.unlocksOnRecharge");
view4.setVisibility(8);
return;
}
refresh();
}
public final void handleSpinWheelResults(final SpinWheelGameModel gameResult) {
this.isSpinning = true;
getBinding().amountEt.setFocusable(false);
getBinding().amountEt.setFocusableInTouchMode(false);
String result = gameResult.getResult();
if (result == null) {
result = "BLACK";
}
this.indexWon = getTargetIndex(result);
getBinding().luckyWheel.startLuckyWheelWithTargetIndex(this.indexWon);
getBinding().luckyWheel.setLuckyRoundItemSelectedListener(new LuckyWheelView.LuckyRoundItemSelectedListener() {
@Override
public final void LuckyRoundItemSelected(int i) {
SpinWheelGameActivity.handleSpinWheelResults$lambda$10(SpinWheelGameActivity.this, gameResult, i);
}
});
}
public static final void handleSpinWheelResults$lambda$10(SpinWheelGameActivity spinWheelGameActivity, SpinWheelGameModel spinWheelGameModel, int i) {
Intrinsics.checkNotNullParameter(spinWheelGameActivity, "this$0");
Intrinsics.checkNotNullParameter(spinWheelGameModel, "$gameResult");
spinWheelGameActivity.getBinding().play.setClickable(true);
spinWheelGameActivity.isSpinning = false;
spinWheelGameActivity.getBinding().amountEt.setFocusable(true);
spinWheelGameActivity.getBinding().amountEt.setFocusableInTouchMode(true);
spinWheelGameActivity.handleWinLoose(spinWheelGameActivity.indexWon, spinWheelGameModel);
spinWheelGameActivity.getViewModel().getSpinWheelGameHistory(10);
}
private final void showWinLoseDialog(long winAmount, boolean isWinner) {
try {
BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new SpinWheelGameActivity$showWinLoseDialog$1(this, winAmount, isWinner, null), 3, (Object) null);
} catch (Exception e) {
Timber.e(e);
}
}
private final void handleWinLoose(int indexWon, SpinWheelGameModel gameResult) {
if (gameResult.getWinAmount() > 0) {
showWinLoseDialog(gameResult.getNetWin(), true);
refresh();
} else if (gameResult.getWinAmount() <= 0) {
showWinLoseDialog(gameResult.getWinAmount(), false);
refresh();
}
}
private final int getTargetIndex(String resultColor) {
int randomIndex = getRandomIndex();
try {
int hashCode = resultColor.hashCode();
if (hashCode != 81009) {
if (hashCode == 63281119) {
resultColor.equals("BLACK");
return 0;
}
if (hashCode == 82564105 && resultColor.equals("WHITE")) {
return randomIndex % 2 == 0 ? randomIndex - 1 : randomIndex;
}
} else if (resultColor.equals("RED")) {
return randomIndex % 2 != 0 ? randomIndex - 1 : randomIndex;
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
private final void setSpinnerWheel() {
try {
LuckyWheelView luckyWheelView = getBinding().luckyWheel;
Intrinsics.checkNotNullExpressionValue(luckyWheelView, "binding.luckyWheel");
List listOf = CollectionsKt.listOf(new String[]{"#FFFFFF", "#D32F2F"});
for (int i = 1; i < 19; i++) {
LuckyItem luckyItem = new LuckyItem();
luckyItem.topText = "";
int i2 = i % 2;
luckyItem.secondaryText = "";
luckyItem.color = Color.parseColor((String) listOf.get(i % 2));
this.data.add(luckyItem);
}
luckyWheelView.setData(this.data);
luckyWheelView.setRound(3);
} catch (Exception e) {
e.printStackTrace();
}
}
private final int getRandomIndex() {
return Random.Default.nextInt(this.data.size() - 1) + 0;
}
private final void setUpToolbar() {
try {
Toolbar toolbar = this.toolbar;
if (toolbar == null) {
Intrinsics.throwUninitializedPropertyAccessException("toolbar");
toolbar = null;
}
setSupportActionBar(toolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
} catch (Exception e) {
Timber.e(e, "setUpToolbar: Error ", new Object[0]);
}
}
private final void initViews() {
Toolbar toolbar = getBinding().toolbar;
Intrinsics.checkNotNullExpressionValue(toolbar, "binding.toolbar");
this.toolbar = toolbar;
}
protected void onResume() {
super.onResume();
refresh();
}
public boolean onOptionsItemSelected(MenuItem item) {
Intrinsics.checkNotNullParameter(item, "item");
if (item.getItemId() != 16908332 || this.isSpinning) {
return true;
}
finish();
return true;
}
protected void onStop() {
super.onStop();
}
public void onBackPressed() {
if (this.isSpinning) {
Toast.makeText((Context) this, "Cannot exit while spinning", 0).show();
} else {
super.onBackPressed();
}
}
}