正在查看: Clash Legends v0.0.1 应用的 CardActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 CardActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package co.paystack.android.ui;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import co.paystack.android.R;
import co.paystack.android.model.Card;
import co.paystack.android.utils.StringUtils;
public class CardActivity extends AppCompatActivity {
Card card;
EditText mEditCVC;
EditText mEditCardNum;
EditText mEditExpiryMonth;
EditText mEditExpiryYear;
final CardSingleton si = CardSingleton.getInstance();
private View.OnFocusChangeListener revalidate = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
CardActivity.this.validateCardForm();
}
};
private boolean submitted = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
Card card;
super.onCreate(savedInstanceState);
setContentView(R.layout.co_paystack_android____activity_card);
getWindow().addFlags(128);
setTitle("ENTER CARD DETAILS");
this.mEditCardNum = (EditText) findViewById(R.id.edit_card_number);
this.mEditCVC = (EditText) findViewById(R.id.edit_cvc);
this.mEditExpiryMonth = (EditText) findViewById(R.id.edit_expiry_month);
this.mEditExpiryYear = (EditText) findViewById(R.id.edit_expiry_year);
synchronized (this.si) {
card = this.si.getCard();
this.card = card;
}
if (card != null) {
this.mEditCardNum.setText(card.getNumber());
this.mEditCVC.setText(this.card.getCvc());
this.mEditExpiryMonth.setText(this.card.getExpiryMonth().intValue() == 0 ? "" : this.card.getExpiryMonth().toString());
this.mEditExpiryYear.setText(this.card.getExpiryYear().intValue() == 0 ? "" : this.card.getExpiryYear().toString());
}
Button mButtonPerformTransaction = (Button) findViewById(R.id.button_perform_transaction);
mButtonPerformTransaction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (CardActivity.this.validateCardForm()) {
CardActivity cardActivity = CardActivity.this;
cardActivity.handleSubmit(cardActivity.card);
}
}
});
this.mEditCardNum.setOnFocusChangeListener(this.revalidate);
this.mEditCVC.setOnFocusChangeListener(this.revalidate);
this.mEditExpiryMonth.setOnFocusChangeListener(this.revalidate);
this.mEditExpiryYear.setOnFocusChangeListener(this.revalidate);
this.mEditCardNum.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
CardActivity.this.mEditCVC.requestFocus();
return true;
}
});
this.mEditCVC.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
CardActivity.this.mEditExpiryMonth.requestFocus();
return true;
}
});
this.mEditExpiryMonth.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
CardActivity.this.mEditExpiryYear.requestFocus();
return true;
}
});
}
public boolean validateCardForm() {
String cardNum = this.mEditCardNum.getText().toString().trim();
if (StringUtils.isEmpty(cardNum)) {
this.mEditCardNum.setError("Empty card number");
return false;
}
Card build = new Card.Builder(cardNum, 0, 0, "").build();
this.card = build;
if (!build.validNumber()) {
this.mEditCardNum.setError("Invalid card number");
return false;
}
String cvc = this.mEditCVC.getText().toString().trim();
if (StringUtils.isEmpty(cvc)) {
this.mEditCVC.setError("Empty cvc");
return false;
}
this.card.setCvc(cvc);
if (!this.card.validCVC()) {
this.mEditCVC.setError("Invalid cvc");
return false;
}
String sMonth = this.mEditExpiryMonth.getText().toString().trim();
try {
int month = Integer.parseInt(sMonth);
if (month < 1 || month > 12) {
this.mEditExpiryMonth.setError("Invalid month");
return false;
}
this.card.setExpiryMonth(Integer.valueOf(month));
String sYear = this.mEditExpiryYear.getText().toString().trim();
try {
int year = Integer.parseInt(sYear);
if (year < 1) {
this.mEditExpiryYear.setError("Invalid year");
return false;
}
this.card.setExpiryYear(Integer.valueOf(year));
if (this.card.validExpiryDate()) {
return true;
}
this.mEditExpiryMonth.setError("Invalid expiry");
this.mEditExpiryYear.setError("Invalid expiry");
return false;
} catch (Exception e) {
return false;
}
} catch (Exception e2) {
return false;
}
}
void handleSubmit(Card card) {
if (this.submitted) {
return;
}
synchronized (this.si) {
this.si.setCard(card);
this.si.notify();
}
finish();
this.submitted = true;
}
@Override
public void onDestroy() {
super.onDestroy();
handleSubmit(null);
}
}