Search in sources :

Example 1 with AdapterChargeType

use of net.iGap.adapter.payment.AdapterChargeType in project iGap-Android by KianIranian-STDG.

the class ChargeFragment method chooseChargeTypeClicked.

private void chooseChargeTypeClicked() {
    if (currentOperator != null) {
        MaterialDialog dialog = new MaterialDialog.Builder(getContext()).customView(R.layout.popup_paymet_type, false).build();
        View typeDialogView = dialog.getCustomView();
        if (typeDialogView != null) {
            typeDialogView.findViewById(R.id.close_view4).setOnClickListener(v1 -> dialog.dismiss());
            RecyclerViewAmount = typeDialogView.findViewById(R.id.rv_type);
            RecyclerViewAmount.setAdapter(new AdapterChargeType(chargeTypesList, chargeTypeSelectedIndex != -1 ? chargeTypeSelectedIndex : chargeTypeDefaultIndex));
            RecyclerViewAmount.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
            typeDialogView.findViewById(R.id.btn_dialog4).setOnClickListener(v16 -> {
                AdapterChargeType adapterChargeType = (AdapterChargeType) RecyclerViewAmount.getAdapter();
                if (adapterChargeType != null) {
                    if (adapterChargeType.getSelectedPosition() == -1) {
                        return;
                    }
                    chargeTypeSelectedIndex = chargeTypeDefaultIndex = adapterChargeType.getSelectedPosition();
                    buttonChargeType.setText(chargeTypesList.get(chargeTypeDefaultIndex).getTitle());
                    dialog.dismiss();
                }
            });
        }
        dialog.show();
    } else {
        showError(getContext().getResources().getString(R.string.please_select_operator));
    }
}
Also used : AdapterChargeType(net.iGap.adapter.payment.AdapterChargeType) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) AppCompatTextView(androidx.appcompat.widget.AppCompatTextView) CircleImageView(net.iGap.module.CircleImageView) ScrollView(android.widget.ScrollView)

Aggregations

View (android.view.View)1 ScrollView (android.widget.ScrollView)1 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)1 AppCompatTextView (androidx.appcompat.widget.AppCompatTextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 AdapterChargeType (net.iGap.adapter.payment.AdapterChargeType)1 CircleImageView (net.iGap.module.CircleImageView)1