正在查看: Hyouka private v5.8.9 应用的 BuyCreditActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Hyouka private v5.8.9 应用的 BuyCreditActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.beint.project;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.beint.project.adapter.BuyCreditAdapter;
import com.beint.project.adapter.StripeCreditAdapter;
import com.beint.project.billing.utils.Base64;
import com.beint.project.billing.utils.IabHelper;
import com.beint.project.billing.utils.IabResult;
import com.beint.project.billing.utils.Inventory;
import com.beint.project.billing.utils.Purchase;
import com.beint.project.billing.utils.SkuDetails;
import com.beint.project.core.configfile.UrlConfigType;
import com.beint.project.core.events.RegistrationEventArgs;
import com.beint.project.core.events.RegistrationEventTypes;
import com.beint.project.core.model.http.ServiceResult;
import com.beint.project.core.model.http.VirtualNetwork;
import com.beint.project.core.model.http.ZangiUserBalance;
import com.beint.project.core.services.impl.SignalingService;
import com.beint.project.core.services.impl.StorageService;
import com.beint.project.core.services.impl.ZangiConfigurationService;
import com.beint.project.core.services.impl.ZangiHTTPServices;
import com.beint.project.core.services.impl.ZangiNetworkService;
import com.beint.project.core.utils.Constants;
import com.beint.project.core.utils.Log;
import com.beint.project.core.utils.NotificationCenter;
import com.beint.project.core.utils.VirtualNetworkManager;
import com.beint.project.core.utils.ZangiConfigurationEntry;
import com.beint.project.core.utils.ZangiEngineUtils;
import com.beint.project.core.utils.ZangiStringUtils;
import com.beint.project.core.wrapper.ProjectWrapperHolder;
import com.beint.project.screens.BaseScreen;
import com.beint.project.screens.PaidAndCreditFragment;
import com.beint.project.screens.RatesFragmentActivity;
import com.beint.project.screens.settings.free.minutes.ScreenMyFreeMinutes;
import com.beint.project.screens.settings.more.settings.AboutCreditFragment;
import com.beint.project.screens.settings.more.settings.PromoCodeFragment;
import com.beint.project.screens.settings.transfer.BalanceTransferActivity;
import com.beint.project.screens.sms.AppModeNotifierActivity;
import com.beint.project.stripe.StripeCreditActivity;
import com.beint.project.utils.AlertDialogUtils;
import fb.r;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class BuyCreditActivity extends AppModeNotifierActivity {
private static String TAG = "com.beint.project.BuyCreditActivity";
private TextView balanceCount;
private ProgressBar balanceProgress;
private Button buyCreditButton;
private RecyclerView buyCreditListView;
IabHelper.OnConsumeFinishedListener consumeFinishedListener;
private BroadcastReceiver getBalanceReceiver;
private LinearLayout googlePurchesLayout;
private IabHelper iabHelper;
private LinearLayout iabInfoLayout;
private TextView iabInfoText;
private TextView iabInfoTitle;
private boolean isPromoCode;
LinearLayoutManager layoutManager;
private LinearLayout linkPurchesLayout;
private BaseScreen mBaseScreen;
IabHelper.OnIabPurchaseFinishedListener mPurchaseListener;
private RelativeLayout pairCreditLayout;
private RelativeLayout progressBar;
private TextView purchaseCreditText;
private LinearLayout purchaseUnavailableLayout;
IabHelper.QueryInventoryFinishedListener queryInventoryFinishedListener;
private RecyclerView stripeCreditListView;
private Toolbar toolbar;
private String userNumber;
private String userNumberBase64;
private static WeakReference<BuyCreditActivity> thisWeak = new WeakReference<>(null);
private static double balancePrice = -1.0d;
private final Integer tempid = 18766;
private boolean iabStarted = false;
List<String> skus = new ArrayList();
List<SkuDetails> skudLst = new ArrayList();
private Handler handler = new Handler(Looper.getMainLooper());
private List<VirtualNetwork> networkList = new ArrayList();
private View.OnClickListener balanceTransferClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!ZangiNetworkService.INSTANCE.isOnline() || !SignalingService.INSTANCE.isRegistered() || BuyCreditActivity.this.balanceProgress.isShown()) {
BuyCreditActivity.this.showInfoMessage(2131886694);
} else if (BuyCreditActivity.balancePrice <= 0.0d) {
AlertDialogUtils.showAlertWithMessage(BuyCreditActivity.this, 2131887014, 2131887012, true);
} else {
BuyCreditActivity.this.startActivityForResult(new Intent((Context) BuyCreditActivity.this, (Class<?>) BalanceTransferActivity.class), 20000);
}
}
};
private View.OnClickListener aboutCreditClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
BaseScreen.getScreenService().showFragment(AboutCreditFragment.class);
}
};
private View.OnClickListener pairCreditClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ZangiNetworkService.INSTANCE.isOnline()) {
BuyCreditActivity.this.showPairAndCredit();
} else {
BaseScreen.showCustomToast(BuyCreditActivity.this, 2131887403);
}
}
};
private View.OnClickListener seeOurRatesOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ZangiNetworkService.INSTANCE.isOnline()) {
BuyCreditActivity.this.showZangiRates(Locale.getDefault().getLanguage());
} else {
BaseScreen.showCustomToast(BuyCreditActivity.this, 2131887403);
}
}
};
private View.OnClickListener freeMinutesClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
BaseScreen.getScreenService().showFragment(ScreenMyFreeMinutes.class);
}
};
static class AnonymousClass18 {
static final int[] $SwitchMap$com$beint$project$BuyCreditActivity$PurchRequestCase;
static final int[] $SwitchMap$com$beint$project$core$events$RegistrationEventTypes;
static {
int[] iArr = new int[RegistrationEventTypes.values().length];
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes = iArr;
try {
iArr[RegistrationEventTypes.UNREGISTRATION_OK.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.REGISTRATION_INPROGRESS.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.UNREGISTRATION_INPROGRESS.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.UNREGISTRATION_NOK.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.CONNECTION_NOK.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.REGISTRATION_NOK.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.REGISTRATION_OK.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
int[] iArr2 = new int[PurchRequestCase.values().length];
$SwitchMap$com$beint$project$BuyCreditActivity$PurchRequestCase = iArr2;
try {
iArr2[PurchRequestCase.NO_CONNECTION.ordinal()] = 1;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$com$beint$project$BuyCreditActivity$PurchRequestCase[PurchRequestCase.NO_SERVER.ordinal()] = 2;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$com$beint$project$BuyCreditActivity$PurchRequestCase[PurchRequestCase.NO_PLAY_MARKET.ordinal()] = 3;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$com$beint$project$BuyCreditActivity$PurchRequestCase[PurchRequestCase.LIMIT_REACHED.ordinal()] = 4;
} catch (NoSuchFieldError unused11) {
}
}
}
public interface CheckLimitCallback {
void finishedSuccessful();
}
public enum PurchRequestCase {
NO_CONNECTION,
NO_SERVER,
NO_PLAY_MARKET,
LIMIT_REACHED
}
private void addObservers() {
NotificationCenter.INSTANCE.addObserver(this, NotificationCenter.NotificationType.REGISTRATION_EVENT, new qb.l() {
public final Object invoke(Object obj) {
r lambda$addObservers$2;
lambda$addObservers$2 = BuyCreditActivity.this.lambda$addObservers$2(obj);
return lambda$addObservers$2;
}
});
}
public void balanceShow(final TextView textView, final View view) {
if (ZangiNetworkService.INSTANCE.isOnline()) {
new Thread("get balance thread") {
@Override
public void run() {
ServiceResult<ZangiUserBalance> serviceResult;
super.run();
Log.i(BuyCreditActivity.TAG, "Balance request!!!!!!!!!!");
if (BuyCreditActivity.this.handler != null) {
BuyCreditActivity.this.handler.post(new Runnable() {
@Override
public void run() {
textView.setText("");
if (view.getVisibility() != 0) {
view.setVisibility(0);
}
}
});
}
final String str = null;
try {
serviceResult = ZangiHTTPServices.getInstance().getBalance(true);
} catch (Exception e2) {
Log.e(BuyCreditActivity.TAG, "Error" + e2.getMessage());
serviceResult = null;
}
if (serviceResult != null && serviceResult.isOk() && serviceResult.getBody() != null && serviceResult.getBody().getBalance() != null) {
double unused = BuyCreditActivity.balancePrice = serviceResult.getBody().getBalance().doubleValue();
StorageService storageService = StorageService.INSTANCE;
if (storageService.getStringSetting(Constants.CURRENCY_CODE_VALUE, "").length() < 1) {
storageService.setSettings(Constants.CURRENCY_CODE_VALUE, serviceResult.getBody().getCurrencyCode());
}
str = String.format(Locale.getDefault(), "%.2f %s", Double.valueOf(BuyCreditActivity.balancePrice), serviceResult.getBody().getCurrencyCode());
}
if (BuyCreditActivity.this.handler != null) {
BuyCreditActivity.this.handler.post(new Runnable() {
@Override
public void run() {
Log.d(BuyCreditActivity.TAG, "BALANCE = " + str);
String str2 = str;
if (str2 != null) {
textView.setText(str2);
view.setVisibility(4);
}
}
});
}
}
}.start();
} else {
textView.setText("");
}
}
public void checkPurchaseLimit(final CheckLimitCallback checkLimitCallback) {
showProgressBar();
new Thread(new Runnable() {
@Override
public void run() {
ServiceResult<Boolean> serviceResult;
try {
serviceResult = ZangiHTTPServices.getInstance().checkPurchasesLimit();
} catch (IOException e2) {
Log.e(BuyCreditActivity.TAG, "unable to make checkPurchases limit request" + e2.toString());
serviceResult = null;
}
Activity activity = this;
if (activity == null) {
return;
}
if (serviceResult == null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
BuyCreditActivity.this.showIabInfo(PurchRequestCase.NO_CONNECTION);
}
});
return;
}
if (!serviceResult.isOk()) {
this.runOnUiThread(new Runnable() {
@Override
public void run() {
BuyCreditActivity.this.showIabInfo(PurchRequestCase.NO_SERVER);
}
});
return;
}
final boolean booleanValue = serviceResult.getBody().booleanValue();
Activity activity2 = this;
if (activity2 == null) {
return;
}
activity2.runOnUiThread(new Runnable() {
@Override
public void run() {
if (booleanValue) {
checkLimitCallback.finishedSuccessful();
} else {
BuyCreditActivity.this.showIabInfo(PurchRequestCase.LIMIT_REACHED);
}
}
});
}
}).start();
}
private void destroyIab() throws IabHelper.IabAsyncInProgressException {
IabHelper iabHelper = this.iabHelper;
if (iabHelper != null && this.iabStarted) {
this.iabStarted = false;
iabHelper.dispose();
}
this.iabHelper = null;
}
public static synchronized BuyCreditActivity getInstance() {
BuyCreditActivity buyCreditActivity;
synchronized (BuyCreditActivity.class) {
buyCreditActivity = thisWeak.get();
}
return buyCreditActivity;
}
private void initIab() {
if (this.iabStarted) {
return;
}
this.skus.clear();
this.skus.add(Constants.SKU_2);
this.skus.add(Constants.SKU_3);
String currentRegisteredUserId = ZangiEngineUtils.getCurrentRegisteredUserId(null);
this.userNumber = currentRegisteredUserId;
if (currentRegisteredUserId == null) {
finish();
return;
}
String str = Constants.G_A_K;
initIabListeners();
this.userNumberBase64 = Base64.encode(this.userNumber.getBytes());
IabHelper iabHelper = new IabHelper(this, str);
this.iabHelper = iabHelper;
iabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult iabResult) {
if (iabResult.isSuccess()) {
BuyCreditActivity.this.iabStarted = true;
BuyCreditActivity.this.checkPurchaseLimit(new CheckLimitCallback() {
@Override
public void finishedSuccessful() {
BuyCreditActivity.this.queryIab();
}
});
Log.i(BuyCreditActivity.TAG, "Iab setup successful");
return;
}
Log.e(BuyCreditActivity.TAG, "Problem setting up In-app Billing: " + iabResult);
BuyCreditActivity.this.iabStarted = false;
BuyCreditActivity.this.showIabInfo(PurchRequestCase.NO_PLAY_MARKET);
}
});
}
private void initIabListeners() {
this.mPurchaseListener = new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult iabResult, Purchase purchase) {
if (iabResult.isFailure()) {
Log.e(BuyCreditActivity.TAG, "Purchase error: " + iabResult);
return;
}
if (purchase != null) {
try {
BuyCreditActivity.this.validatePurchase(purchase, true);
} catch (IabHelper.IabAsyncInProgressException e2) {
e2.printStackTrace();
}
Log.i(BuyCreditActivity.TAG, "trying to validate purchased prod");
}
}
};
this.consumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
@Override
public void onConsumeFinished(Purchase purchase, IabResult iabResult) {
if (!iabResult.isFailure()) {
Log.i(BuyCreditActivity.TAG, "consume succesful");
return;
}
Log.e(BuyCreditActivity.TAG, "Consume error: " + iabResult);
}
};
this.queryInventoryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult iabResult, Inventory inventory) {
if (iabResult.isFailure()) {
Log.e(BuyCreditActivity.TAG, "Query inventory error: " + iabResult);
BuyCreditActivity.this.showIabInfo(PurchRequestCase.NO_PLAY_MARKET);
return;
}
BuyCreditActivity.this.showPurchaseList();
BuyCreditActivity.this.skudLst.clear();
for (int i2 = 0; i2 < BuyCreditActivity.this.skus.size(); i2++) {
SkuDetails skuDetails = inventory.getSkuDetails(BuyCreditActivity.this.skus.get(i2));
if (skuDetails != null) {
BuyCreditActivity.this.skudLst.add(skuDetails);
}
if (inventory.hasPurchase(BuyCreditActivity.this.skus.get(i2))) {
try {
BuyCreditActivity.this.validatePurchase(inventory.getPurchase(BuyCreditActivity.this.skus.get(i2)), false);
} catch (IabHelper.IabAsyncInProgressException e2) {
e2.printStackTrace();
}
Log.i(BuyCreditActivity.TAG, "has not consumed prods");
}
}
BuyCreditActivity buyCreditActivity = BuyCreditActivity.this;
BuyCreditAdapter buyCreditAdapter = new BuyCreditAdapter(buyCreditActivity, buyCreditActivity.skudLst);
BuyCreditActivity.this.buyCreditListView.setLayoutManager(BuyCreditActivity.this.layoutManager);
BuyCreditActivity.this.buyCreditListView.setAdapter(buyCreditAdapter);
}
};
}
public r lambda$addObservers$2(Object obj) {
switch (AnonymousClass18.$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[((RegistrationEventArgs) obj).getEventType().ordinal()]) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
this.balanceCount.setText("");
if (this.balanceProgress.getVisibility() != 0) {
this.balanceProgress.setVisibility(0);
break;
}
break;
case 7:
balanceShow(this.balanceCount, this.balanceProgress);
checkPurchaseLimit(new CheckLimitCallback() {
@Override
public void finishedSuccessful() {
if (Constants.IS_GOOG_PLAY_PURCHASE_ENABLED) {
BuyCreditActivity.this.queryIab();
} else if (Constants.IS_STRIPE_PURCHASE_ENABLED) {
BuyCreditActivity.this.showStripePurchaseList();
}
}
});
break;
}
return r.a;
}
public void lambda$onCreate$0(String str, String str2, String str3) {
TextView textView = this.purchaseCreditText;
Object[] objArr = new Object[1];
if (!TextUtils.isEmpty(str3)) {
str2 = str3;
}
objArr[0] = str2;
textView.setText(String.format(str, objArr));
}
public void lambda$onCreate$1(View view) {
List<VirtualNetwork> list = this.networkList;
if (list != null && !list.isEmpty()) {
AlertDialogUtils.showAlertWithMessage(this, 2131886238, 2131886237, false);
} else if (ZangiNetworkService.INSTANCE.isOnline()) {
BaseScreen.getScreenService().showFragment(WebViewFragment.class);
} else {
BaseScreen.showCustomToast(this, 2131887051);
}
}
public void queryIab() {
if (this.iabStarted) {
Log.i(TAG, "Iab querying");
try {
this.iabHelper.queryInventoryAsync(true, this.skus, null, this.queryInventoryFinishedListener);
} catch (IabHelper.IabAsyncInProgressException e2) {
e2.printStackTrace();
}
}
}
private void redirectToZangiWab() {
ZangiConfigurationService zangiConfigurationService = ZangiConfigurationService.INSTANCE;
String string = zangiConfigurationService.getString(ZangiConfigurationEntry.IDENTITY_USERNAME, null);
String string2 = zangiConfigurationService.getString(ZangiConfigurationEntry.IDENTITY_PASSWORD, null);
if (ZangiStringUtils.isNullOrEmpty(string) || ZangiStringUtils.isNullOrEmpty(string2)) {
return;
}
try {
String encodeToString = android.util.Base64.encodeToString((string + ":" + string2).getBytes("UTF-8"), 2);
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(ProjectWrapperHolder.INSTANCE.getUrlByType(UrlConfigType.WEB_TOPUP.ordinal())));
Bundle bundle = new Bundle();
bundle.putString("credentials", encodeToString);
intent.putExtra("com.android.browser.headers", bundle);
startActivity(intent);
} catch (Exception e2) {
e2.printStackTrace();
}
}
private void removerObservers() {
NotificationCenter.INSTANCE.removeObserver(this);
}
public static synchronized void setInstance(BuyCreditActivity buyCreditActivity) {
synchronized (BuyCreditActivity.class) {
thisWeak = new WeakReference<>(buyCreditActivity);
}
}
public void showIabInfo(PurchRequestCase purchRequestCase) {
if (this.iabInfoLayout == null || this.buyCreditListView == null) {
return;
}
int i2 = AnonymousClass18.$SwitchMap$com$beint$project$BuyCreditActivity$PurchRequestCase[purchRequestCase.ordinal()];
if (i2 == 1) {
this.iabInfoTitle.setText(getResources().getText(2131886694));
this.iabInfoText.setText(getResources().getText(2131887051));
} else if (i2 == 2) {
this.iabInfoTitle.setText(getResources().getText(2131886694));
this.iabInfoText.setText(getResources().getText(2131887052));
} else if (i2 == 3) {
this.iabInfoTitle.setVisibility(8);
this.iabInfoText.setText(getResources().getText(2131886695));
} else if (i2 == 4) {
this.iabInfoTitle.setVisibility(8);
this.iabInfoText.setText(getResources().getText(2131886385));
}
this.iabInfoLayout.setVisibility(0);
this.buyCreditListView.setVisibility(8);
this.purchaseCreditText.setVisibility(8);
this.progressBar.setVisibility(8);
}
public void showInfoMessage(int i2) {
Context mainContext = MainApplication.Companion.getMainContext();
View inflate = LayoutInflater.from(mainContext).inflate(R.layout.toast_layout, (ViewGroup) null);
((TextView) inflate.findViewById(R.id.toast_layout_text)).setText(i2);
Toast toast = BaseScreen.toast;
if (toast != null) {
toast.cancel();
}
Toast toast2 = new Toast(mainContext);
BaseScreen.toast = toast2;
toast2.setView(inflate);
BaseScreen.toast.setDuration(1);
BaseScreen.toast.show();
}
public void showPairAndCredit() {
Fragment paidAndCreditFragment = new PaidAndCreditFragment();
Bundle bundle = new Bundle();
bundle.putString("balance", String.valueOf(balancePrice));
paidAndCreditFragment.setArguments(bundle);
getSupportFragmentManager().n().g(PaidAndCreditFragment.Companion.getTAG()).q(R.id.fr_layout, paidAndCreditFragment).j();
}
private void showProgressBar() {
RelativeLayout relativeLayout = this.progressBar;
if (relativeLayout != null) {
relativeLayout.setVisibility(0);
this.iabInfoLayout.setVisibility(8);
this.buyCreditListView.setVisibility(8);
this.stripeCreditListView.setVisibility(8);
}
}
public void showPurchaseList() {
if (this.iabInfoText == null || this.buyCreditListView == null) {
return;
}
this.iabInfoLayout.setVisibility(8);
this.buyCreditListView.setVisibility(0);
this.purchaseCreditText.setVisibility(0);
this.progressBar.setVisibility(8);
}
public void showStripePurchaseList() {
if (this.iabInfoText == null || this.stripeCreditListView == null) {
return;
}
this.iabInfoLayout.setVisibility(8);
this.buyCreditListView.setVisibility(8);
this.stripeCreditListView.setVisibility(0);
this.purchaseCreditText.setVisibility(0);
this.progressBar.setVisibility(8);
}
public void showZangiRates(String str) {
Intent intent = new Intent((Context) this, (Class<?>) RatesFragmentActivity.class);
intent.addFlags(268435456);
startActivity(intent);
}
public void validatePurchase(Purchase purchase, boolean z2) throws IabHelper.IabAsyncInProgressException {
ServiceResult<Boolean> serviceResult;
SkuDetails skuDetails;
String str;
String str2;
if (purchase != null) {
int i2 = 0;
while (true) {
serviceResult = null;
if (i2 >= this.skudLst.size()) {
skuDetails = null;
break;
} else {
if (purchase.getSku().equals(this.skudLst.get(i2).getSku())) {
skuDetails = this.skudLst.get(i2);
break;
}
i2++;
}
}
if (skuDetails != null) {
String valueOf = String.valueOf(skuDetails.getPriceAmountMicros());
str2 = skuDetails.getPriceCurrencyCode();
str = valueOf;
} else {
str = null;
str2 = null;
}
String packageName = getPackageName();
String sku = purchase.getSku();
String token = purchase.getToken();
showProgressBar();
try {
serviceResult = ZangiHTTPServices.getInstance().validatePurchase(packageName, sku, token, str, str2);
} catch (Exception e2) {
Log.e(TAG, "Error" + e2.getMessage());
}
if (serviceResult == null) {
BaseScreen.showCustomToast(this, 2131887051);
Log.i(TAG, "no connection");
} else if (serviceResult.isOk()) {
this.iabHelper.consumeAsync(purchase, this.consumeFinishedListener);
Log.i(TAG, "purchase validated successfully");
} else {
BaseScreen.showCustomToast(this, 2131886698);
Log.i(TAG, "!!!! purchase NOT validated successfully");
}
checkPurchaseLimit(new CheckLimitCallback() {
@Override
public void finishedSuccessful() {
BuyCreditActivity.this.showPurchaseList();
}
});
if (z2 && serviceResult != null) {
balanceShow(this.balanceCount, this.balanceProgress);
} else {
if (serviceResult == null || !serviceResult.isOk()) {
return;
}
BaseScreen.showCustomToast(this, 2131886696);
}
}
}
protected void onActivityResult(int i2, int i3, Intent intent) {
IabHelper iabHelper = this.iabHelper;
if (iabHelper != null && i2 != 20000) {
iabHelper.handleActivityResult(i2, i3, intent);
}
if (i2 == 20000 && i3 == -1) {
finish();
}
}
public void onButtonClick(final Object obj) {
if (obj != null) {
this.progressBar.setVisibility(0);
checkPurchaseLimit(new CheckLimitCallback() {
@Override
public void finishedSuccessful() {
BuyCreditActivity.this.progressBar.setVisibility(8);
Object obj2 = obj;
if (!(obj2 instanceof SkuDetails)) {
if (obj2 instanceof String) {
Intent intent = new Intent((Context) BuyCreditActivity.this, (Class<?>) StripeCreditActivity.class);
intent.putExtra("credit", (String) obj);
BuyCreditActivity.this.startActivity(intent);
BuyCreditActivity.this.showStripePurchaseList();
return;
}
return;
}
BuyCreditActivity.this.showPurchaseList();
try {
IabHelper iabHelper = BuyCreditActivity.this.iabHelper;
AppModeNotifierActivity appModeNotifierActivity = BuyCreditActivity.this;
String sku = ((SkuDetails) obj).getSku();
int intValue = BuyCreditActivity.this.tempid.intValue();
BuyCreditActivity buyCreditActivity = BuyCreditActivity.this;
iabHelper.launchPurchaseFlow(appModeNotifierActivity, sku, intValue, buyCreditActivity.mPurchaseListener, buyCreditActivity.userNumberBase64);
} catch (IabHelper.IabAsyncInProgressException e2) {
e2.printStackTrace();
}
}
});
}
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.buy_credit_activity);
View findViewById = findViewById(R.id.toolbar_shadow);
if (findViewById != null) {
findViewById.setVisibility(8);
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
this.toolbar = toolbar;
toolbar.setTitle(2131886778);
this.isPromoCode = Constants.IS_PROMO_CODE;
setSupportActionBar(this.toolbar);
getSupportActionBar().v(false);
getSupportActionBar().q(true);
getSupportActionBar().r(true);
this.layoutManager = new LinearLayoutManager(this, 0, false);
this.buyCreditListView = (RecyclerView) findViewById(R.id.buy_credit_list);
this.stripeCreditListView = (RecyclerView) findViewById(R.id.stripe_credit_list);
this.progressBar = (RelativeLayout) findViewById(R.id.progress_bar);
this.balanceProgress = (ProgressBar) findViewById(R.id.balance_loader);
this.balanceCount = (TextView) findViewById(R.id.balance);
this.iabInfoText = (TextView) findViewById(R.id.iab_info_text);
this.iabInfoTitle = (TextView) findViewById(R.id.iab_info_title);
this.iabInfoLayout = (LinearLayout) findViewById(R.id.iab_info_layout);
this.purchaseCreditText = (TextView) findViewById(R.id.purchase_credit_text);
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.paid_credit_layout);
this.pairCreditLayout = relativeLayout;
relativeLayout.setOnClickListener(this.pairCreditClickListener);
VirtualNetworkManager virtualNetworkManager = VirtualNetworkManager.INSTANCE;
String f2 = virtualNetworkManager.getNetworkCallName().f();
final String string = getResources().getString(2131887525);
final String string2 = getResources().getString(2131887096);
TextView textView = this.purchaseCreditText;
Object[] objArr = new Object[1];
if (TextUtils.isEmpty(f2)) {
f2 = string2;
}
objArr[0] = f2;
textView.setText(String.format(string, objArr));
virtualNetworkManager.getNetworkCallName().i(this, new androidx.lifecycle.u() {
@Override
public final void a(Object obj) {
BuyCreditActivity.this.lambda$onCreate$0(string, string2, (String) obj);
}
});
this.googlePurchesLayout = (LinearLayout) findViewById(R.id.google_purchess_layout);
this.linkPurchesLayout = (LinearLayout) findViewById(R.id.link_purches_layout);
this.buyCreditButton = (Button) findViewById(R.id.buy_credit_layout);
this.purchaseUnavailableLayout = (LinearLayout) findViewById(R.id.payments_unavailable_layout);
if (Constants.IS_GOOG_PLAY_PURCHASE_ENABLED) {
this.googlePurchesLayout.setVisibility(0);
this.linkPurchesLayout.setVisibility(8);
this.purchaseUnavailableLayout.setVisibility(8);
} else if (Constants.IS_STRIPE_PURCHASE_ENABLED) {
this.googlePurchesLayout.setVisibility(0);
this.linkPurchesLayout.setVisibility(8);
this.purchaseUnavailableLayout.setVisibility(8);
ArrayList arrayList = new ArrayList();
arrayList.add("$4.99");
arrayList.add("$9.99");
StripeCreditAdapter stripeCreditAdapter = new StripeCreditAdapter(this, arrayList);
this.stripeCreditListView.setLayoutManager(this.layoutManager);
this.stripeCreditListView.setAdapter(stripeCreditAdapter);
checkPurchaseLimit(new CheckLimitCallback() {
@Override
public void finishedSuccessful() {
BuyCreditActivity.this.showStripePurchaseList();
}
});
} else if (Constants.IS_WEB_PURCHASE_ENABLED) {
this.googlePurchesLayout.setVisibility(8);
this.linkPurchesLayout.setVisibility(0);
this.purchaseCreditText.setVisibility(0);
this.purchaseUnavailableLayout.setVisibility(8);
} else {
this.googlePurchesLayout.setVisibility(8);
this.linkPurchesLayout.setVisibility(8);
this.purchaseCreditText.setVisibility(8);
this.purchaseUnavailableLayout.setVisibility(0);
}
this.buyCreditButton.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
BuyCreditActivity.this.lambda$onCreate$1(view);
}
});
RelativeLayout relativeLayout2 = (RelativeLayout) findViewById(R.id.promo_code);
View findViewById2 = findViewById(R.id.see_our_rates);
View findViewById3 = findViewById(R.id.my_free_minutes);
View findViewById4 = findViewById(R.id.about_credit);
findViewById(R.id.balance_transfer).setVisibility(8);
if (this.isPromoCode) {
relativeLayout2.setVisibility(0);
relativeLayout2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ZangiNetworkService.INSTANCE.isOnline()) {
BaseScreen.getScreenService().showFragment(PromoCodeFragment.class);
} else {
BaseScreen.showCustomToast(BuyCreditActivity.this, 2131887403);
}
}
});
} else {
relativeLayout2.setVisibility(8);
}
if (Constants.IS_RATES_INFO) {
findViewById2.setVisibility(0);
findViewById2.setOnClickListener(this.seeOurRatesOnClickListener);
} else {
findViewById2.setVisibility(8);
}
if (Constants.IS_MY_FREE_MINUTES_ENABLED) {
findViewById3.setVisibility(0);
findViewById3.setOnClickListener(this.freeMinutesClickListener);
} else {
findViewById3.setVisibility(8);
}
if (Constants.IS_ABOUT_CREDIT) {
findViewById4.setVisibility(0);
findViewById4.setOnClickListener(this.aboutCreditClickListener);
} else {
findViewById4.setVisibility(8);
}
this.networkList = StorageService.INSTANCE.getVirtualNetworkList();
setInstance(this);
addObservers();
}
protected void onDestroy() {
setInstance(null);
super.onDestroy();
removerObservers();
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
onBackPressed();
}
return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
}
protected void onPause() {
super.onPause();
unregisterReceiver(this.getBalanceReceiver);
}
protected void onRestart() {
super/*android.app.Activity*/.onRestart();
}
protected void onResume() {
super.onResume();
balanceShow(this.balanceCount, this.balanceProgress);
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
BuyCreditActivity buyCreditActivity = BuyCreditActivity.this;
buyCreditActivity.balanceShow(buyCreditActivity.balanceCount, BuyCreditActivity.this.balanceProgress);
}
};
this.getBalanceReceiver = broadcastReceiver;
registerReceiver(broadcastReceiver, new IntentFilter(Constants.GET_BALANCE_REQUEST));
}
protected void onStart() {
super.onStart();
if (Constants.IS_GOOG_PLAY_PURCHASE_ENABLED) {
try {
initIab();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
protected void onStop() {
super.onStop();
try {
destroyIab();
} catch (IabHelper.IabAsyncInProgressException e2) {
e2.printStackTrace();
}
}
}