Search in sources :

Example 1 with ChargeApi

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);
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) HandShakeCallback(net.iGap.observers.interfaces.HandShakeCallback) FrameLayout(android.widget.FrameLayout) RadioButton(android.widget.RadioButton) FavoriteNumber(net.iGap.model.paymentPackage.FavoriteNumber) ConfigData(net.iGap.model.paymentPackage.ConfigData) Theme(net.iGap.module.Theme) G(net.iGap.G) HelperPermission(net.iGap.helper.HelperPermission) HelperPermission.showDeniedPermissionMessage(net.iGap.helper.HelperPermission.showDeniedPermissionMessage) View(android.view.View) ChargeContactNumberAdapter(net.iGap.adapter.payment.ChargeContactNumberAdapter) HelperError(net.iGap.helper.HelperError) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) OperatorAdapter(net.iGap.adapter.OperatorAdapter) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) HelperString.isNumeric(net.iGap.helper.HelperString.isNumeric) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) BaseFragment(net.iGap.fragments.BaseFragment) ViewGroup(android.view.ViewGroup) PaymentRepository(net.iGap.repository.PaymentRepository) List(java.util.List) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) InternetHistoryPackageAdapter(net.iGap.adapter.payment.InternetHistoryPackageAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) PackageChargeType(net.iGap.model.paymentPackage.PackageChargeType) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) Call(retrofit2.Call) TextWatcher(android.text.TextWatcher) AndroidUtils(net.iGap.module.AndroidUtils) ResourcesCompat(androidx.core.content.res.ResourcesCompat) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Response(retrofit2.Response) RadioGroup(android.widget.RadioGroup) Editable(android.text.Editable) ArrayList(java.util.ArrayList) MaterialButton(com.google.android.material.button.MaterialButton) LayoutCreator(net.iGap.helper.LayoutCreator) TokenContainer(net.iGap.api.apiService.TokenContainer) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) Config(net.iGap.model.paymentPackage.Config) AvatarHandler(net.iGap.helper.avatar.AvatarHandler) ContactNumber(net.iGap.adapter.payment.ContactNumber) LayoutInflater(android.view.LayoutInflater) Operator(net.iGap.model.paymentPackage.Operator) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) IOException(java.io.IOException) CircleImageView(net.iGap.module.CircleImageView) PhoneContactProvider(net.iGap.controllers.PhoneContactProvider) Gravity(android.view.Gravity) GetFavoriteNumber(net.iGap.model.paymentPackage.GetFavoriteNumber) ChargeApi(net.iGap.api.ChargeApi) RetrofitFactory(net.iGap.api.apiService.RetrofitFactory) Callback(retrofit2.Callback) ScrollView(android.widget.ScrollView) R(net.iGap.R) DbManager(net.iGap.module.accountManager.DbManager) EditText(android.widget.EditText) OperatorAdapter(net.iGap.adapter.OperatorAdapter) RetrofitFactory(net.iGap.api.apiService.RetrofitFactory) RadioButton(android.widget.RadioButton) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) HelperFragment(net.iGap.helper.HelperFragment) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Aggregations

Bundle (android.os.Bundle)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 Gravity (android.view.Gravity)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 EditText (android.widget.EditText)1 FrameLayout (android.widget.FrameLayout)1 RadioButton (android.widget.RadioButton)1 RadioGroup (android.widget.RadioGroup)1 ScrollView (android.widget.ScrollView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 AppCompatEditText (androidx.appcompat.widget.AppCompatEditText)1 ResourcesCompat (androidx.core.content.res.ResourcesCompat)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1