use of net.iGap.api.ChargeApi in project iGap-Android by KianIranian-STDG.
the class InternetFragment method initForm.
private void initForm() {
DbManager.getInstance().doRealmTask(realm -> {
RealmRegisteredInfo userInfo = realm.where(RealmRegisteredInfo.class).findFirst();
if (userInfo != null) {
userNumber = userInfo.getPhoneNumber();
if (phoneNumber != null && !phoneNumber.isEmpty() && !phoneNumber.equals("0")) {
setPhoneNumberEditText(phoneNumber);
if (peerId != 0) {
avatarHandler.getAvatar(new ParamWithAvatarType(avatar, peerId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
}
}
if (phoneNumber != null && phoneNumber.equals("0")) {
avatar.setVisibility(View.GONE);
editTextNumber.setHint(getActivity().getString(R.string.please_enter_phone_number));
removeButton.setText(R.string.icon_edit);
} else {
avatar.setVisibility(View.GONE);
setPhoneNumberEditText(userNumber);
}
if (editTextNumber.getText() != null && editTextNumber.getText().length() == 11) {
hideKeyboard();
}
editTextNumber.setSelection(editTextNumber.getText() == null ? 0 : editTextNumber.getText().length());
}
});
operatorAdapter = new OperatorAdapter(getContext(), operators, operatorName -> {
if (currentConfigData != null) {
changeOperator(currentConfigData.getOperator());
} else {
operatorAdapter.setCheckedRadioButton(null);
HelperError.showSnackMessage(getActivity().getString(R.string.please_enter_phone_number), false);
}
});
lstOperator.setAdapter(operatorAdapter);
detectOperatorByNumber(editTextNumber.getText().toString());
chargeApi = new RetrofitFactory().getChargeRetrofit();
editTextNumber.addTextChangedListener(editTextNumberWatcher());
removeButton.setOnClickListener(removeNumberClicked());
frameContact.setOnClickListener(v -> onContactNumberButtonClick());
frameHistory.setOnClickListener(v -> onHistoryNumberButtonClick());
radioGroup.setOnCheckedChangeListener((group, checkedId) -> InternetFragment.this.changeSimType());
goNextButton.setOnClickListener(v -> {
RadioButton radioButton = radioGroup.findViewById(radioGroup.getCheckedRadioButtonId());
if (radioButton != null) {
if (currentSimType == null) {
showError(getActivity().getString(R.string.invalid_sim_type));
return;
}
if (editTextNumber.getText() == null) {
editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
return;
}
String rechargeableNumber = editTextNumber.getText().toString().trim();
if (!isNumeric(rechargeableNumber) || rechargeableNumber.length() < 11) {
editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
return;
}
if (!isNumberFromIran(rechargeableNumber)) {
editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
return;
}
int packageType = historyNumber != null ? Integer.parseInt(historyNumber.getPackageType()) : -1;
new HelperFragment(getActivity().getSupportFragmentManager(), PaymentInternetFragment.newInstance(userNumber, rechargeableNumber, currentOperator.getKey(), currentSimType, packageType)).setAnimated(false).setReplace(false).load();
} else {
showError(getActivity().getString(R.string.sim_type_not_choosed));
}
});
progressBar.setVisibility(View.GONE);
scrollView.setVisibility(View.VISIBLE);
}
Aggregations