use of net.iGap.model.paymentPackage.ConfigData in project iGap-Android by KianIranian-STDG.
the class ChargeFragment method initForm.
private void initForm() {
// init number from dataBase
DbManager.getInstance().doRealmTask(realm -> {
RealmRegisteredInfo userInfo = realm.where(RealmRegisteredInfo.class).findFirst();
if (userInfo != null && editTextNumber.getText() != null) {
userNumber = userInfo.getPhoneNumber();
if (phoneNumber != null && !phoneNumber.isEmpty() && !phoneNumber.equals("0")) {
setPhoneNumberEditText(phoneNumber);
if (peerId != 0) {
avatarHandler.getAvatar(new ParamWithAvatarType(imageViewAvatar, peerId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
}
} else if (phoneNumber != null && phoneNumber.equals("0")) {
imageViewAvatar.setVisibility(View.GONE);
editTextNumber.setHint(getResources().getString(R.string.please_enter_phone_number));
iconRemove.setText(R.string.icon_edit);
} else {
imageViewAvatar.setVisibility(View.GONE);
setPhoneNumberEditText(userNumber);
}
}
});
// init RecyclerViewOperator
recyclerViewOperator.setLayoutManager(new GridLayoutManager(context, 3, RecyclerView.VERTICAL, false));
adapterOperator = new OperatorAdapter(getContext(), operators, operatorName -> {
if (currentConfigData != null) {
for (ConfigData configData : config.getData()) {
if (configData.getOperator().getKey().equals(operatorName)) {
currentConfigData = configData;
changeOperator(currentConfigData.getOperator());
break;
}
}
} else {
adapterOperator.setCheckedRadioButton(null);
HelperError.showSnackMessage(getResources().getString(R.string.please_enter_phone_number), false);
}
});
recyclerViewOperator.setAdapter(adapterOperator);
detectOperatorByNumber(editTextNumber.getText().toString());
editTextNumber.addTextChangedListener(editTextNumberWatcher());
iconRemove.setOnClickListener(removeNumberClicked());
historyButton.setOnClickListener(historyButtonClicked());
contactButton.setOnClickListener(contactButtonClicked());
buttonAmount.setOnClickListener(v -> {
choosePriceButtonClicked();
});
amountPlusButton.setOnClickListener(v -> {
if (currentAmount != null) {
isHistorySelected(false);
currentAmount = new Amount(currentAmount, true);
buttonAmount.setText(currentAmount.getTextAmount());
} else {
HelperError.showSnackMessage(getResources().getString(R.string.please_enter_desired_amount), false);
}
});
amountMinesButton.setOnClickListener(v -> {
if (currentAmount != null) {
if (currentAmount.getAmount() > 10000) {
isHistorySelected(false);
currentAmount = new Amount(currentAmount, false);
buttonAmount.setText(currentAmount.getTextAmount());
} else {
HelperError.showSnackMessage(getResources().getString(R.string.minimizeAmount), false);
}
} else {
HelperError.showSnackMessage(getResources().getString(R.string.please_enter_desired_amount), false);
}
});
buttonChargeType.setOnClickListener(v -> {
chooseChargeTypeClicked();
});
buttonEnter.setOnClickListener(v -> onSaveBtnClicked());
scrollView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
use of net.iGap.model.paymentPackage.ConfigData in project iGap-Android by KianIranian-STDG.
the class InternetFragment method isNumberFromIran.
private boolean isNumberFromIran(String phoneNumber) {
boolean isValid = false;
String phonePreNumber;
if (phoneNumber.trim().charAt(0) == '0') {
phonePreNumber = phoneNumber.substring(0, 4);
} else {
String standardize = phoneNumber.replace("+98", "0").replace("0098", "0");
phonePreNumber = standardize.substring(0, 4);
}
for (ConfigData configData : config.getData()) {
for (String preNumber : configData.getPreNumbers()) {
if (phonePreNumber.equals(preNumber)) {
isValid = true;
break;
}
}
}
return isValid;
}
use of net.iGap.model.paymentPackage.ConfigData in project iGap-Android by KianIranian-STDG.
the class ChargeFragment method detectOperatorByNumber.
private void detectOperatorByNumber(String editText) {
if (editText.length() == 10 && editText.charAt(0) != '0')
editTextNumber.setText("0".concat(Objects.requireNonNull(editTextNumber.getText()).toString()));
if (editText.length() == 11 || iconRemove.getText().toString().equals(getResources().getString(R.string.icon_edit))) {
operators.clear();
for (ConfigData configData : config.getData()) {
operators.add(configData.getOperator());
if (iconRemove.getText().toString().equals(getResources().getString(R.string.icon_edit))) {
currentConfigData = null;
} else {
for (String preNumber : configData.getPreNumbers()) {
if (preNumber.equals(editText.substring(0, 4))) {
currentConfigData = configData;
break;
}
}
}
}
}
if (currentConfigData != null) {
faceValueList.clear();
for (FaceValue faceValue : currentConfigData.getFaceValues()) {
faceValueList.add(new Amount(faceValue.getKey()));
if (faceValue.getSelected())
amountDefaultIndex = faceValueList.size() - 1;
}
chargeTypesList.clear();
chargeTypesList.addAll(currentConfigData.getTopupChargeTypes());
if (currentConfigData != null)
changeOperator(currentConfigData.getOperator());
} else {
faceValueList.clear();
chargeTypesList.clear();
}
}
use of net.iGap.model.paymentPackage.ConfigData in project iGap-Android by KianIranian-STDG.
the class ChargeFragment method isNumberFromIran.
private boolean isNumberFromIran(String phoneNumber) {
boolean isValid = false;
String phonePreNumber;
if (phoneNumber.trim().charAt(0) == '0') {
phonePreNumber = phoneNumber.substring(0, 4);
} else {
String standardize = phoneNumber.replace("+98", "0").replace("0098", "0");
phonePreNumber = standardize.substring(0, 4);
}
for (ConfigData configData : config.getData()) {
for (String preNumber : configData.getPreNumbers()) {
if (phonePreNumber.equals(preNumber)) {
isValid = true;
break;
}
}
}
return isValid;
}
use of net.iGap.model.paymentPackage.ConfigData in project iGap-Android by KianIranian-STDG.
the class InternetFragment method detectOperatorByNumber.
private void detectOperatorByNumber(String editText) {
if (editText.length() == 10 && editText.charAt(0) != '0')
editTextNumber.setText("0".concat(editTextNumber.getText().toString()));
if (editText.length() == 11 || removeButton.getText().toString().equals(getActivity().getString(R.string.icon_edit))) {
operators.clear();
packageChargeTypes.clear();
for (ConfigData configData : config.getData()) {
operators.add(configData.getOperator());
if (removeButton.getText().toString().equals(getActivity().getString(R.string.icon_edit))) {
currentConfigData = null;
} else {
for (int j = 0; j < configData.getPreNumbers().size(); j++) {
if (editText.substring(0, 4).equals(configData.getPreNumbers().get(j))) {
currentConfigData = configData;
}
}
}
}
}
if (currentConfigData != null) {
packageChargeTypes.addAll(currentConfigData.getPackageChargeTypes());
changeOperator(currentConfigData.getOperator());
} else {
packageChargeTypes.clear();
}
}
Aggregations