PrimeIPTV Plus v2.1.0版本的 MD5 值为:44f247a9048d0121c6011174ea55496e
以下内容为反编译后的 RenewProductActivity.java 源代码,内容仅作参考
package com.lck.lxtream;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.widget.AppCompatSpinner;
import android.text.Html;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.alihafizji.library.CreditCardEditText;
import com.github.mmin18.widget.FlexLayout;
import com.lck.lxtream.DB.MonthOne;
import com.lck.lxtream.DB.PublicKeyEntry;
import com.lck.lxtream.DB.RenewGridView;
import com.lck.lxtream.DB.RenewProducts;
import com.lck.lxtream.DB.RenewResult;
import com.lck.lxtream.Net.ApiManager;
import com.lck.lxtream.Utils.AccountUtil;
import com.lck.lxtream.Utils.Config;
import com.lck.lxtream.Utils.Constant;
import com.lck.lxtream.Utils.KeyUtils;
import com.lck.lxtream.Utils.L;
import com.lck.lxtream.widget.PaymentResultView;
import com.stripe.android.Stripe;
import com.stripe.android.TokenCallback;
import com.stripe.android.model.Card;
import com.stripe.android.model.Token;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import org.jsoup.Jsoup;
public class RenewProductActivity extends BaseActivity {
@BindView(com.aplicativox.primeiptvplus.R.id.next_step)
Button confimButton;
@BindView(com.aplicativox.primeiptvplus.R.id.credit_num)
CreditCardEditText creditCardEditText;
@BindView(com.aplicativox.primeiptvplus.R.id.credit_info)
FlexLayout creditLayout;
@BindView(com.aplicativox.primeiptvplus.R.id.csv_eidt)
EditText csvEdit;
@BindView(com.aplicativox.primeiptvplus.R.id.email_add)
EditText emailAddress;
@BindView(com.aplicativox.primeiptvplus.R.id.first_name_edit)
EditText firstName;
private Disposable mSubscription;
@BindView(com.aplicativox.primeiptvplus.R.id.product_layout)
FlexLayout productLayout;
@BindView(com.aplicativox.primeiptvplus.R.id.renew_layout)
RenewGridView renewGridView;
@BindView(com.aplicativox.primeiptvplus.R.id.currency_spin)
AppCompatSpinner spinner;
@BindView(com.aplicativox.primeiptvplus.R.id.expiry_month)
AppCompatSpinner spinnerMonth;
@BindView(com.aplicativox.primeiptvplus.R.id.expiry_year)
AppCompatSpinner spinnerYear;
String k = "01";
String l = "1990";
String m = "";
String n = "";
String o = "";
String p = "";
private String productName = "";
private String pSku = "";
private String pPcs = "";
private String cCurrency = "";
private String usrFirstname = "";
private Dialog resultDialog = null;
TextView.OnEditorActionListener q = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
int id = textView.getId();
if (id != com.aplicativox.primeiptvplus.R.id.first_name_edit) {
switch (id) {
case com.aplicativox.primeiptvplus.R.id.credit_num:
if (i == 5) {
RenewProductActivity.this.getFocuse(1);
break;
}
break;
case com.aplicativox.primeiptvplus.R.id.csv_eidt:
if (i == 5) {
KeyUtils.HideKeyboard(textView);
RenewProductActivity.this.getFocuse(2);
break;
}
break;
}
} else if (i == 5) {
RenewProductActivity.this.getFocuse(5);
}
return true;
}
};
public static boolean checkBankCardId(String str) {
int length;
if (str != null && (length = str.length()) >= 15 && length <= 19) {
int i = 0;
int i2 = 0;
while (i < length) {
int numericValue = Character.getNumericValue(str.charAt((length - 1) - i));
i++;
if (i % 2 == 0) {
int i3 = numericValue * 2;
i2 += (i3 / 10) + (i3 % 10);
} else {
i2 += numericValue;
}
}
return i2 % 10 == 0;
}
return false;
}
private boolean checkDate() {
String[] split = new SimpleDateFormat("yyyy-MM", Locale.getDefault()).format(Long.valueOf(Calendar.getInstance().getTimeInMillis())).split("-");
int parseInt = Integer.parseInt(this.k);
int parseInt2 = Integer.parseInt(this.l);
if (Integer.parseInt(split[0]) < parseInt2) {
return true;
}
return Integer.parseInt(split[0]) == parseInt2 && Integer.parseInt(split[1]) < parseInt;
}
private boolean checkEmail(String str) {
return str.matches("\\w+@\\w+(\\.\\w{2,3})*\\.\\w{2,3}");
}
public void creditStep(String str, String str2, String str3, String str4) {
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2) || TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4)) {
return;
}
String[] strArr = new String[0];
if (!TextUtils.isEmpty(str3) && str3.contains("#::&")) {
strArr = Html.fromHtml(str3).toString().split("#::&");
}
this.productName = str;
this.pSku = str2;
this.pPcs = strArr[1];
this.cCurrency = str4;
if (this.productLayout.getVisibility() == 0) {
this.productLayout.setVisibility(8);
}
if (this.creditLayout.getVisibility() == 8) {
this.creditLayout.setVisibility(0);
}
}
private void dealSendData() {
Card card = new Card(this.m, Integer.valueOf(this.k), Integer.valueOf(this.l), this.n);
card.setName(this.o);
if (card.validateCard()) {
getPublicKey(card);
return;
}
Dialog dialog = this.resultDialog;
if (dialog != null && dialog.isShowing()) {
this.resultDialog.dismiss();
}
setButtonCanClick(true);
Toast.makeText(this, (int) com.aplicativox.primeiptvplus.R.string.card_wrong, 0).show();
}
public void getFocuse(int i) {
EditText editText;
AppCompatSpinner appCompatSpinner;
switch (i) {
case 0:
this.creditCardEditText.setFocusable(true);
this.creditCardEditText.requestFocus();
return;
case 1:
this.csvEdit.setFocusable(true);
editText = this.csvEdit;
editText.requestFocus();
return;
case 2:
this.spinnerMonth.setFocusable(true);
appCompatSpinner = this.spinnerMonth;
appCompatSpinner.requestFocus();
return;
case 3:
this.spinnerYear.setFocusable(true);
appCompatSpinner = this.spinnerYear;
appCompatSpinner.requestFocus();
return;
case 4:
this.firstName.setFocusable(true);
editText = this.firstName;
editText.requestFocus();
return;
case 5:
this.emailAddress.setFocusable(true);
editText = this.emailAddress;
editText.requestFocus();
return;
default:
return;
}
}
private void getNetIp() {
this.mSubscription = Observable.just("http://checkip.amazonaws.com/").flatMap(new Function<String, ObservableSource<String>>() {
@Override
public ObservableSource<String> apply(String str) throws Exception {
return Observable.just(Jsoup.connect(str).get().body().text());
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<String>() {
@Override
public void accept(String str) {
RenewProductActivity.this.p = str;
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable th) throws Exception {
L.i("" + th, new Object[0]);
}
});
}
private String getOrderNumber() {
StringBuilder sb = new StringBuilder(new SimpleDateFormat("yyyyMMddHHmm", Locale.FRANCE).format(Long.valueOf(Calendar.getInstance(Locale.getDefault()).getTimeInMillis())));
for (int i = 0; i < 4; i++) {
sb.append((int) (Math.random() * 10.0d));
}
return sb.toString();
}
private String getOrderTime() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(Long.valueOf(Calendar.getInstance(Locale.getDefault()).getTimeInMillis()));
}
private void getProducts(int i) {
this.mSubscription = ApiManager.getRenewProducts(i, Config.RENEW_TOKEN).subscribe(new Consumer<RenewProducts>() {
@Override
public void accept(final RenewProducts renewProducts) throws Exception {
if (renewProducts.product_info == null || renewProducts.product_info.size() <= 0) {
return;
}
RenewProductActivity.this.renewGridView.setProducts(renewProducts.product_info, "USD");
final ArrayList arrayList = new ArrayList(renewProducts.product_info.get(0).products_currency.keySet());
RenewProductActivity.this.spinner.setAdapter((SpinnerAdapter) new ArrayAdapter(RenewProductActivity.this, 17367049, arrayList));
RenewProductActivity.this.spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i2, long j) {
RenewProductActivity.this.renewGridView.setProducts(renewProducts.product_info, (String) arrayList.get(i2));
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable th) throws Exception {
L.i("" + th, new Object[0]);
}
});
}
private void getPublicKey(final Card card) {
this.mSubscription = ApiManager.getKey("ah3&234N314V%$MW1").subscribe(new Consumer<PublicKeyEntry>() {
@Override
public void accept(PublicKeyEntry publicKeyEntry) throws Exception {
if (publicKeyEntry.status == 1) {
new Stripe(RenewProductActivity.this, publicKeyEntry.api_key).createToken(card, new TokenCallback() {
@Override
public void onError(Exception exc) {
L.i("current token error " + exc, new Object[0]);
if (RenewProductActivity.this.resultDialog != null && RenewProductActivity.this.resultDialog.isShowing()) {
RenewProductActivity.this.resultDialog.dismiss();
}
RenewProductActivity.this.setButtonCanClick(true);
Toast.makeText(RenewProductActivity.this, exc.getLocalizedMessage(), 0).show();
}
@Override
public void onSuccess(Token token) {
RenewProductActivity.this.postToken(token);
}
});
return;
}
if (RenewProductActivity.this.resultDialog != null && RenewProductActivity.this.resultDialog.isShowing()) {
RenewProductActivity.this.resultDialog.dismiss();
}
RenewProductActivity.this.setButtonCanClick(true);
Toast.makeText(RenewProductActivity.this, (int) com.aplicativox.primeiptvplus.R.string.check_network, 0).show();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable th) throws Exception {
if (RenewProductActivity.this.resultDialog != null && RenewProductActivity.this.resultDialog.isShowing()) {
RenewProductActivity.this.resultDialog.dismiss();
}
RenewProductActivity.this.setButtonCanClick(true);
Toast.makeText(RenewProductActivity.this, (int) com.aplicativox.primeiptvplus.R.string.check_network, 0).show();
}
});
}
private void initCodeDate() {
String type = AccountUtil.getLXtreamEntry().getType();
if (TextUtils.isEmpty(type)) {
return;
}
int i = 1;
if (!type.equals(Constant.code_qhd)) {
if (type.equals(Constant.code_qhdpro)) {
i = 4;
} else if (type.equals(Constant.code_iud)) {
i = 2;
} else if (type.equals(Constant.code_sub)) {
i = 3;
}
}
getProducts(i);
}
private void initDate() {
this.spinnerMonth.setAdapter((SpinnerAdapter) new ArrayAdapter(this, 17367049, MonthOne.month));
this.spinnerYear.setAdapter((SpinnerAdapter) new ArrayAdapter(this, 17367049, MonthOne.years));
this.spinnerMonth.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
RenewProductActivity.this.k = MonthOne.month[i];
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
this.spinnerYear.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
RenewProductActivity.this.l = MonthOne.years[i];
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
private void initListener() {
this.renewGridView.setOnAction(new RenewGridView.OnAction() {
@Override
public void onItemChange(int i) {
}
@Override
public void onItemClick(int i, String str, String str2, String str3, String str4) {
L.i("current select : " + i + "-" + str2 + "-" + str3 + "-" + str4, new Object[0]);
RenewProductActivity.this.creditStep(str, str2, str3, str4);
}
@Override
public void onItemLongClick(int i) {
}
});
this.csvEdit.setOnEditorActionListener(this.q);
this.creditCardEditText.setOnEditorActionListener(this.q);
this.firstName.setOnEditorActionListener(this.q);
}
public void postToken(Token token) {
String code = AccountUtil.getLXtreamEntry().getCode();
if (TextUtils.isEmpty(code)) {
return;
}
this.mSubscription = ApiManager.sendPaymentData(token.getId(), this.o, this.usrFirstname, Float.valueOf(this.pPcs).floatValue(), this.cCurrency, code, getOrderNumber(), this.pSku, this.productName, this.p).subscribe(new Consumer<RenewResult>() {
@Override
public void accept(RenewResult renewResult) throws Exception {
RenewProductActivity.this.showResult(1, renewResult);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable th) throws Exception {
RenewProductActivity.this.setButtonCanClick(true);
}
});
}
public void setButtonCanClick(boolean z) {
this.confimButton.setClickable(z);
}
public void showResult(int i, final RenewResult renewResult) {
Dialog dialog = this.resultDialog;
if (dialog != null && dialog.isShowing()) {
this.resultDialog.dismiss();
}
this.resultDialog = new Dialog(this, com.aplicativox.primeiptvplus.R.style.DialogTheme);
this.resultDialog.setCanceledOnTouchOutside(false);
PaymentResultView paymentResultView = new PaymentResultView(getApplicationContext());
this.resultDialog.setContentView(paymentResultView);
this.resultDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialogInterface, int i2, KeyEvent keyEvent) {
if (keyEvent.getAction() == 0 && (i2 == 23 || i2 == 4)) {
L.i("current dialog :" + RenewProductActivity.this.resultDialog, new Object[0]);
RenewResult renewResult2 = renewResult;
if (renewResult2 == null || !renewResult2.resultStatusCode.equals("EXECUTE_SUCCESS")) {
RenewResult renewResult3 = renewResult;
if (renewResult3 == null || !renewResult3.resultStatusCode.equals("CODE_FOUND")) {
RenewResult renewResult4 = renewResult;
if (renewResult4 != null && renewResult4.resultStatusCode.equals("EXECUTE_FAIL")) {
if (dialogInterface != null) {
dialogInterface.dismiss();
}
RenewProductActivity.this.setButtonCanClick(true);
}
}
}
return true;
}
return false;
}
});
this.resultDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
RenewProductActivity.this.resultDialog = null;
}
});
if (i == 1 && renewResult != null) {
paymentResultView.setPaymentResult(renewResult);
}
this.resultDialog.show();
}
@Override
public void onBackPressed() {
if (this.creditLayout.getVisibility() != 0) {
finish();
return;
}
this.creditLayout.setVisibility(8);
this.productLayout.setVisibility(0);
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(com.aplicativox.primeiptvplus.R.layout.activity_renew_product);
ButterKnife.bind(this);
initCodeDate();
initListener();
initDate();
getNetIp();
}
@Override
public void onDestroy() {
super.onDestroy();
Disposable disposable = this.mSubscription;
if (disposable != null) {
disposable.dispose();
}
}
@Override
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (keyEvent.getAction() == 0) {
if (keyEvent.getKeyCode() == 19) {
if (this.renewGridView.hasFocus() && this.spinner.getVisibility() == 0) {
this.spinner.setFocusable(true);
this.spinner.requestFocus();
return true;
} else if (this.emailAddress.isFocused()) {
getFocuse(4);
return true;
} else if (this.firstName.isFocused()) {
getFocuse(2);
return true;
} else if (this.spinnerMonth.isFocused() || this.spinnerYear.isFocused()) {
getFocuse(1);
return true;
} else if (this.csvEdit.isFocused()) {
getFocuse(0);
return true;
}
} else if (keyEvent.getKeyCode() == 20) {
if (this.spinner.isFocused() && this.renewGridView.getVisibility() == 0) {
this.renewGridView.getFocus();
return true;
} else if (this.creditCardEditText.isFocused()) {
getFocuse(1);
return true;
} else if (this.csvEdit.isFocused()) {
getFocuse(2);
return true;
} else if (this.spinnerMonth.isFocused() || this.spinnerYear.isFocused()) {
getFocuse(4);
return true;
} else if (this.firstName.isFocused()) {
getFocuse(5);
return true;
}
} else if (keyEvent.getKeyCode() != 21) {
keyEvent.getKeyCode();
}
}
return super.onKeyDown(i, keyEvent);
}
@OnClick({com.aplicativox.primeiptvplus.R.id.next_step})
public void onNextClick() {
int i;
int i2;
Toast makeText;
if (this.creditLayout.getVisibility() == 0) {
setButtonCanClick(false);
String creditCardNumber = this.creditCardEditText.getCreditCardNumber();
String obj = this.csvEdit.getText().toString();
String obj2 = this.firstName.getText().toString();
String obj3 = this.emailAddress.getText().toString();
if (!TextUtils.isEmpty(creditCardNumber) && !TextUtils.isEmpty(obj) && !TextUtils.isEmpty(this.l) && !TextUtils.isEmpty(this.k) && !TextUtils.isEmpty(obj2) && !TextUtils.isEmpty(obj3)) {
if (!checkBankCardId(creditCardNumber)) {
i2 = com.aplicativox.primeiptvplus.R.string.card_wrong;
} else if (checkDate()) {
if (!checkEmail(obj3)) {
makeText = Toast.makeText(this, getString(com.aplicativox.primeiptvplus.R.string.email_wrong), 0);
makeText.show();
setButtonCanClick(true);
return;
}
showResult(0, null);
this.m = creditCardNumber;
this.n = obj;
this.usrFirstname = obj2;
this.o = obj3;
dealSendData();
return;
} else {
i2 = com.aplicativox.primeiptvplus.R.string.card_expired;
}
makeText = Toast.makeText(this, i2, 0);
makeText.show();
setButtonCanClick(true);
return;
}
setButtonCanClick(true);
String str = "";
if (TextUtils.isEmpty(creditCardNumber)) {
i = com.aplicativox.primeiptvplus.R.string.card_number;
} else if (TextUtils.isEmpty(obj)) {
i = com.aplicativox.primeiptvplus.R.string.card_csv;
} else if (!TextUtils.isEmpty(obj2)) {
if (TextUtils.isEmpty(obj3)) {
i = com.aplicativox.primeiptvplus.R.string.email;
}
Toast.makeText(this, getString(com.aplicativox.primeiptvplus.R.string.need_enter) + " " + str, 0).show();
} else {
i = com.aplicativox.primeiptvplus.R.string.hold_name;
}
str = getString(i);
Toast.makeText(this, getString(com.aplicativox.primeiptvplus.R.string.need_enter) + " " + str, 0).show();
}
}
@OnClick({com.aplicativox.primeiptvplus.R.id.previos_step})
public void onPreviosClick() {
if (this.creditLayout.getVisibility() == 0) {
this.creditLayout.setVisibility(8);
this.productLayout.setVisibility(0);
}
}
}