use of net.iGap.adapter.OperatorAdapter 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.adapter.OperatorAdapter 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