Search in sources :

Example 1 with ChargeHistoryNumberAdapter

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

the class ChargeFragment method historyButtonClicked.

private View.OnClickListener historyButtonClicked() {
    return v -> {
        ChargeFragment.this.hideKeyboard();
        progressBar.setVisibility(View.VISIBLE);
        historyButton.setEnabled(false);
        closeKeyboard(editTextNumber);
        favoriteNumberCall.enqueue(new Callback<GetFavoriteNumber>() {

            @Override
            public void onResponse(@NonNull Call<GetFavoriteNumber> call, @NonNull Response<GetFavoriteNumber> response) {
                progressBar.setVisibility(View.GONE);
                historyButton.setEnabled(true);
                if (response.isSuccessful() && response.body() != null && response.body().getData() != null) {
                    if (response.body().getData().size() > 0) {
                        MaterialDialog dialog = new MaterialDialog.Builder(getContext()).customView(R.layout.popup_paymet_history, false).build();
                        View historyDialogView = dialog.getCustomView();
                        if (historyDialogView != null) {
                            RecyclerViewHistory = historyDialogView.findViewById(R.id.rv_history);
                            setDialogBackground(RecyclerViewHistory);
                            RecyclerViewHistory.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
                            ChargeHistoryNumberAdapter adapter = new ChargeHistoryNumberAdapter(response.body().getData());
                            RecyclerViewHistory.setAdapter(adapter);
                            adapter.setOnItemClickListener(position -> {
                                historyItemClicked = position;
                                onHistoryItemClicked();
                                isHistorySelected(true);
                                dialog.dismiss();
                            });
                            historyDialogView.findViewById(R.id.iv_close2).setOnClickListener(v12 -> dialog.dismiss());
                        }
                        dialog.show();
                    } else {
                        HelperError.showSnackMessage(getResources().getString(R.string.error), false);
                    }
                }
            }

            @Override
            public void onFailure(@NonNull Call<GetFavoriteNumber> call, @NonNull Throwable t) {
                historyButton.setEnabled(true);
                progressBar.setVisibility(View.GONE);
                showError(getContext().getResources().getString(R.string.there_is_no_connection_to_server));
            }
        });
    };
}
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) MciPurchaseResponse(net.iGap.model.paymentPackage.MciPurchaseResponse) Response(retrofit2.Response) Call(retrofit2.Call) Callback(retrofit2.Callback) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NonNull(androidx.annotation.NonNull) 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) ChargeHistoryNumberAdapter(net.iGap.adapter.payment.ChargeHistoryNumberAdapter)

Example 2 with ChargeHistoryNumberAdapter

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

the class ChargeFragment method onHistoryItemClicked.

private void onHistoryItemClicked() {
    ChargeHistoryNumberAdapter adapterHistory = (ChargeHistoryNumberAdapter) RecyclerViewHistory.getAdapter();
    if (adapterHistory != null) {
        if (historyItemClicked == -1) {
            return;
        }
        String historyNumberPhone = adapterHistory.getHistoryNumberList().get(historyItemClicked).getPhoneNumber();
        adapterHistory.getHistoryNumberList().get(historyItemClicked).getChargeType();
        setPhoneNumberEditText(historyNumberPhone);
        currentAmount = new Amount(adapterHistory.getHistoryNumberList().get(historyItemClicked).getAmount());
        buttonAmount.setText(currentAmount.getTextAmount());
        detectOperatorByNumber(editTextNumber.getText().toString());
    }
}
Also used : AdapterChargeAmount(net.iGap.adapter.payment.AdapterChargeAmount) Amount(net.iGap.adapter.payment.Amount) ChargeHistoryNumberAdapter(net.iGap.adapter.payment.ChargeHistoryNumberAdapter)

Aggregations

AdapterChargeAmount (net.iGap.adapter.payment.AdapterChargeAmount)2 Amount (net.iGap.adapter.payment.Amount)2 ChargeHistoryNumberAdapter (net.iGap.adapter.payment.ChargeHistoryNumberAdapter)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