Search in sources :

Example 1 with ChargeContactNumberAdapter

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

the class ChargeFragment method contactButtonClicked.

private View.OnClickListener contactButtonClicked() {
    return v -> {
        hideKeyboard();
        progressBar.setVisibility(View.VISIBLE);
        closeKeyboard(editTextNumber);
        try {
            HelperPermission.getContactPermision(getActivity(), new OnGetPermission() {

                @Override
                public void Allow() {
                    ChargeContactNumberAdapter adapter = new ChargeContactNumberAdapter();
                    contactButton.setEnabled(false);
                    PhoneContactProvider.getInstance().getAllPhoneContactForPayment(contactNumbers -> {
                        if (getContext() == null) {
                            return;
                        }
                        contactButton.setEnabled(true);
                        progressBar.setVisibility(View.GONE);
                        if (contactNumbers.size() == 0) {
                            HelperError.showSnackMessage(getResources().getString(R.string.no_number_found), false);
                        } else {
                            adapter.setContactNumbers(contactNumbers);
                            MaterialDialog dialog = new MaterialDialog.Builder(getContext()).customView(R.layout.popup_paymet_contact, false).build();
                            View contactDialogView = dialog.getCustomView();
                            if (contactDialogView != null) {
                                RecyclerView contactRecyclerView = contactDialogView.findViewById(R.id.rv_contact);
                                EditText editText = contactDialogView.findViewById(R.id.etSearch);
                                setDialogBackground(contactRecyclerView);
                                setDialogBackground(editText);
                                contactRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
                                contactRecyclerView.setAdapter(adapter);
                                adapter.setOnItemClickListener(position -> {
                                    contactPositionClicked = position;
                                    onContactItemClicked(adapter);
                                    dialog.dismiss();
                                });
                                ChargeContactNumberAdapter adapterContactNumber = (ChargeContactNumberAdapter) contactRecyclerView.getAdapter();
                                if (textWatcher != null)
                                    editText.removeTextChangedListener(textWatcher);
                                textWatcher = new TextWatcher() {

                                    @Override
                                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                                    }

                                    @Override
                                    public void onTextChanged(CharSequence s, int start, int before, int count) {
                                        if (adapterContactNumber != null)
                                            adapterContactNumber.search(s.toString());
                                    }

                                    @Override
                                    public void afterTextChanged(Editable s) {
                                    }
                                };
                                editText.addTextChangedListener(textWatcher);
                                contactDialogView.findViewById(R.id.closeView).setOnClickListener(v12 -> dialog.dismiss());
                            }
                            dialog.show();
                        }
                    });
                }

                @Override
                public void deny() {
                    progressBar.setVisibility(View.GONE);
                    showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    };
}
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) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) EditText(android.widget.EditText) ChargeContactNumberAdapter(net.iGap.adapter.payment.ChargeContactNumberAdapter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IOException(java.io.IOException) 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) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 2 with ChargeContactNumberAdapter

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

the class InternetFragment method onContactNumberButtonClick.

private void onContactNumberButtonClick() {
    progressBar.setVisibility(View.VISIBLE);
    frameContact.setEnabled(false);
    closeKeyboard(editTextNumber);
    try {
        HelperPermission.getContactPermision(getActivity(), new OnGetPermission() {

            @Override
            public void Allow() {
                ChargeContactNumberAdapter adapterContact = new ChargeContactNumberAdapter();
                PhoneContactProvider.getInstance().getAllPhoneContactForPayment(contactNumbers -> {
                    if (getContext() == null) {
                        return;
                    }
                    frameContact.setEnabled(true);
                    progressBar.setVisibility(View.GONE);
                    if (contactNumbers.size() == 0) {
                        HelperError.showSnackMessage(getActivity().getString(R.string.no_number_found), false);
                    } else {
                        adapterContact.setContactNumbers(contactNumbers);
                        MaterialDialog dialog = new MaterialDialog.Builder(getContext()).customView(R.layout.popup_paymet_contact, false).build();
                        View contactDialogView = dialog.getCustomView();
                        if (contactDialogView != null) {
                            RecyclerView contactRecyclerView = contactDialogView.findViewById(R.id.rv_contact);
                            EditText editText = contactDialogView.findViewById(R.id.etSearch);
                            setDialogBackground(contactRecyclerView);
                            setDialogBackground(editText);
                            contactRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
                            adapterContact.setOnItemClickListener(position -> {
                                clickedPosition = position;
                                onContactClicked(adapterContact);
                                dialog.dismiss();
                            });
                            contactRecyclerView.setAdapter(adapterContact);
                            if (watcher != null)
                                editText.removeTextChangedListener(watcher);
                            watcher = new TextWatcher() {

                                @Override
                                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                                }

                                @Override
                                public void onTextChanged(CharSequence s, int start, int before, int count) {
                                    if (s != null)
                                        adapterContact.search(s.toString());
                                }

                                @Override
                                public void afterTextChanged(Editable s) {
                                }
                            };
                            editText.addTextChangedListener(watcher);
                            contactDialogView.findViewById(R.id.closeView).setOnClickListener(v12 -> dialog.dismiss());
                        }
                        dialog.show();
                    }
                });
            }

            @Override
            public void deny() {
                progressBar.setVisibility(View.GONE);
                showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
            }
        });
    } catch (IOException e) {
        e.printStackTrace();
    }
}
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) AppCompatEditText(androidx.appcompat.widget.AppCompatEditText) EditText(android.widget.EditText) ChargeContactNumberAdapter(net.iGap.adapter.payment.ChargeContactNumberAdapter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) IOException(java.io.IOException) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) MaterialDesignTextView(net.iGap.module.MaterialDesignTextView) CircleImageView(net.iGap.module.CircleImageView) ScrollView(android.widget.ScrollView) OnGetPermission(net.iGap.observers.interfaces.OnGetPermission) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

Bundle (android.os.Bundle)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 Gravity (android.view.Gravity)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 EditText (android.widget.EditText)2 FrameLayout (android.widget.FrameLayout)2 ScrollView (android.widget.ScrollView)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 AppCompatEditText (androidx.appcompat.widget.AppCompatEditText)2 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)2 MaterialButton (com.google.android.material.button.MaterialButton)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2