Search in sources :

Example 1 with ConfigData

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);
}
Also used : JsonObject(com.google.gson.JsonObject) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) FrameLayout(android.widget.FrameLayout) ConfigData(net.iGap.model.paymentPackage.ConfigData) Theme(net.iGap.module.Theme) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) G(net.iGap.G) MciPurchaseResponse(net.iGap.model.paymentPackage.MciPurchaseResponse) AdapterChargeType(net.iGap.adapter.payment.AdapterChargeType) 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) Schedulers(io.reactivex.schedulers.Schedulers) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) ResponseBody(okhttp3.ResponseBody) AdapterChargeAmount(net.iGap.adapter.payment.AdapterChargeAmount) IGSingleObserver(net.iGap.observers.rx.IGSingleObserver) OperatorAdapter(net.iGap.adapter.OperatorAdapter) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) FaceValue(net.iGap.model.paymentPackage.FaceValue) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) BaseFragment(net.iGap.fragments.BaseFragment) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) PaymentRepository(net.iGap.repository.PaymentRepository) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Call(retrofit2.Call) TextWatcher(android.text.TextWatcher) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) AndroidUtils(net.iGap.module.AndroidUtils) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) GravityEnum(com.afollestad.materialdialogs.GravityEnum) Response(retrofit2.Response) 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) Amount(net.iGap.adapter.payment.Amount) Operator(net.iGap.model.paymentPackage.Operator) DialogAction(com.afollestad.materialdialogs.DialogAction) IOException(java.io.IOException) ChargeHistoryNumberAdapter(net.iGap.adapter.payment.ChargeHistoryNumberAdapter) TopupChargeType(net.iGap.model.paymentPackage.TopupChargeType) 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) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ConfigData(net.iGap.model.paymentPackage.ConfigData) AdapterChargeAmount(net.iGap.adapter.payment.AdapterChargeAmount) Amount(net.iGap.adapter.payment.Amount) OperatorAdapter(net.iGap.adapter.OperatorAdapter) ParamWithAvatarType(net.iGap.helper.avatar.ParamWithAvatarType) RealmRegisteredInfo(net.iGap.realm.RealmRegisteredInfo)

Example 2 with ConfigData

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;
}
Also used : ConfigData(net.iGap.model.paymentPackage.ConfigData)

Example 3 with ConfigData

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();
    }
}
Also used : FaceValue(net.iGap.model.paymentPackage.FaceValue) ConfigData(net.iGap.model.paymentPackage.ConfigData) AdapterChargeAmount(net.iGap.adapter.payment.AdapterChargeAmount) Amount(net.iGap.adapter.payment.Amount)

Example 4 with ConfigData

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;
}
Also used : ConfigData(net.iGap.model.paymentPackage.ConfigData)

Example 5 with ConfigData

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();
    }
}
Also used : ConfigData(net.iGap.model.paymentPackage.ConfigData)

Aggregations

ConfigData (net.iGap.model.paymentPackage.ConfigData)5 AdapterChargeAmount (net.iGap.adapter.payment.AdapterChargeAmount)2 Amount (net.iGap.adapter.payment.Amount)2 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 ScrollView (android.widget.ScrollView)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 AppCompatEditText (androidx.appcompat.widget.AppCompatEditText)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1 AppCompatTextView (androidx.appcompat.widget.AppCompatTextView)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1