Search in sources :

Example 26 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class ParentChatMoneyTransferFragment method loadInternetPayment.

public void loadInternetPayment() {
    Fragment fragment = InternetFragment.newInstance();
    Bundle bundle = new Bundle();
    bundle.putString("phoneNumber", phoneNumber);
    bundle.putLong("peerId", peerId);
    fragment.setArguments(bundle);
    new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load();
    dismiss();
}
Also used : Bundle(android.os.Bundle) HelperFragment(net.iGap.helper.HelperFragment) ChargeFragment(net.iGap.fragments.payment.ChargeFragment) InternetFragment(net.iGap.fragments.payment.InternetFragment) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment)

Example 27 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class ElectricityBillListFrag method initRecycler.

private void initRecycler(Map<BillList.Bill, Debit> bills) {
    adapter = new ElectricityBillListAdapter(getContext(), bills, (item, btnAction) -> {
        // ServiceDebit temp = viewModel.getmMapData().getValue().get(item);
        switch(btnAction) {
            case PAY:
                ServiceDebit tempService = (ServiceDebit) bills.get(item).getData();
                viewModel.payServiceBill(tempService.getBillID(), tempService.getPaymentID(), tempService.getTotalElectricityBillDebt() != null ? tempService.getTotalElectricityBillDebt() : tempService.getTotalGasBillDebt(), ProtoMplGetBillToken.MplGetBillToken.Type.NONE_VALUE);
                break;
            case EDIT:
                if (item.getBillTitle() == null) {
                    showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
                    return;
                }
                ElectricityBillAddFrag frag = ElectricityBillAddFrag.newInstance(viewModel.getBillInfo(item), true);
                frag.setCompleteListener(new ElectricityBillAddFrag.CompleteListener() {

                    @Override
                    public void loadAgain() {
                        viewModel.getBillsList();
                    }
                });
                frag.show(getFragmentManager(), "BillAddEdit");
                break;
            case DELETE:
                final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteBill_title).content(R.string.elecBill_deleteBill_desc).positiveText(R.string.elecBill_deleteBill_pos).negativeText(R.string.elecBill_deleteBill_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> {
                    viewModel.deleteItem(item);
                    Toast.makeText(getContext(), "Deleted", Toast.LENGTH_SHORT).show();
                }).build();
                dialog.show();
                break;
            case SHOW_DETAIL:
                if (item.getBillTitle() == null) {
                    showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
                    return;
                }
                BillInfo temp = viewModel.getBillInfo(item);
                new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(temp.getBillType(), temp.getBillID(), temp.getTitle(), true)).setReplace(false).load();
                break;
            case MID_PAY:
                MobileDebit tempMid = (MobileDebit) bills.get(item).getData();
                viewModel.payServiceBill(tempMid.getMidTerm().getBillID(), tempMid.getMidTerm().getPayID(), tempMid.getMidTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.MID_TERM_VALUE);
                break;
            case LAST_PAY:
                MobileDebit tempLast = (MobileDebit) bills.get(item).getData();
                viewModel.payServiceBill(tempLast.getLastTerm().getBillID(), tempLast.getLastTerm().getPayID(), tempLast.getLastTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.LAST_TERM_VALUE);
                break;
            case RELOAD:
                viewModel.reloadData(item);
        }
    });
    binding.billRecycler.setAdapter(adapter);
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) NonNull(androidx.annotation.NonNull) ProtoMplGetBillToken(net.iGap.proto.ProtoMplGetBillToken) Theme(net.iGap.module.Theme) ElectricityBillListVM(net.iGap.viewmodel.electricity_bill.ElectricityBillListVM) ArrayList(java.util.ArrayList) MobileDebit(net.iGap.model.bill.MobileDebit) FragmentElecBillListBinding(net.iGap.databinding.FragmentElecBillListBinding) Toast(android.widget.Toast) Map(java.util.Map) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) HelperError(net.iGap.helper.HelperError) HelperFragment(net.iGap.helper.HelperFragment) BillList(net.iGap.model.bill.BillList) DataBindingUtil(androidx.databinding.DataBindingUtil) Debit(net.iGap.model.bill.Debit) LayoutInflater(android.view.LayoutInflater) TopSheetDialog(net.iGap.module.dialog.topsheet.TopSheetDialog) ViewGroup(android.view.ViewGroup) BaseAPIViewFrag(net.iGap.api.apiService.BaseAPIViewFrag) BillInfo(net.iGap.model.bill.BillInfo) ElectricityBillListAdapter(net.iGap.adapter.electricity_bill.ElectricityBillListAdapter) List(java.util.List) Nullable(androidx.annotation.Nullable) R(net.iGap.R) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Snackbar(com.google.android.material.snackbar.Snackbar) HelperToolbar(net.iGap.helper.HelperToolbar) ServiceDebit(net.iGap.model.bill.ServiceDebit) ElectricityBillListAdapter(net.iGap.adapter.electricity_bill.ElectricityBillListAdapter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ServiceDebit(net.iGap.model.bill.ServiceDebit) Theme(net.iGap.module.Theme) BillInfo(net.iGap.model.bill.BillInfo) HelperFragment(net.iGap.helper.HelperFragment) MobileDebit(net.iGap.model.bill.MobileDebit)

Example 28 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class ElectricityBillMainFrag method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    HelperTracker.sendTracker(HelperTracker.TRACKER_BILL_PAGE);
    HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).setLogoShown(true);
    LinearLayout toolbarLayout = binding.Toolbar;
    toolbarLayout.addView(mHelperToolbar.getView());
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.billsOptions, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    binding.billSpinner.setAdapter(adapter);
    binding.billSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch(position) {
                case 0:
                    viewModel.setType(BillInfo.BillType.ELECTRICITY);
                    binding.billIdHolder.setHint(getResources().getString(R.string.elecBill_main_billIDHint));
                    binding.billIdHolder.setCounterMaxLength(13);
                    binding.billQRscan.setEnabled(true);
                    binding.billQRscan.setTextColor(getResources().getColor(R.color.gray));
                    break;
                case 1:
                    viewModel.setType(BillInfo.BillType.GAS);
                    binding.billIdHolder.setHint(getResources().getString(R.string.elecBill_main_billIDHint3));
                    binding.billIdHolder.setCounterMaxLength(12);
                    binding.billQRscan.setEnabled(false);
                    binding.billQRscan.setTextColor(getResources().getColor(R.color.gray_300));
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    binding.modeGroup.setOnCheckedChangeListener((group, checkedId) -> onModeChangeView(checkedId));
    binding.billIdET.addTextChangedListener(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) {
            viewModel.getBillIDErrorEnable().set(false);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    viewModel.getGoToBillDetailFrag().observe(getViewLifecycleOwner(), aBoolean -> {
        if (aBoolean) {
            viewModel.getProgressVisibility().set(View.GONE);
            new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(viewModel.getType(), viewModel.getBillID().get(), null, false)).setReplace(false).load();
        }
    });
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) AdapterView(android.widget.AdapterView) HelperToolbar(net.iGap.helper.HelperToolbar) HelperFragment(net.iGap.helper.HelperFragment) LinearLayout(android.widget.LinearLayout)

Example 29 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class ElectricityBillSearchListFrag method initRecycler.

private void initRecycler(List<ElectricityBranchData> bills) {
    ElectricityBillSearchListAdapter adapter = new ElectricityBillSearchListAdapter(getContext(), bills, position -> new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(viewModel.getmBranchData().getValue().get(position).getBillID(), false)).setReplace(false).load());
    binding.billRecycler.setAdapter(adapter);
}
Also used : ElectricityBillSearchListAdapter(net.iGap.adapter.electricity_bill.ElectricityBillSearchListAdapter) HelperFragment(net.iGap.helper.HelperFragment)

Example 30 with HelperFragment

use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.

the class FragmentSecurity method onViewCreated.

@Override
public void onViewCreated(@NotNull final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    securityToolbar = new Toolbar(getContext());
    securityToolbar.setBackIcon(new BackDrawable(false));
    securityToolbar.setTitle(getString(R.string.two_step_pass_code));
    ToolbarItem toolbarItem;
    toolbarItem = securityToolbar.addItem(rippleOkTag, R.string.icon_sent, Color.WHITE);
    securityToolbar.setListener(i -> {
        switch(i) {
            case -1:
                fragmentSecurityViewModel.onClickRippleBack(view);
                break;
            case rippleOkTag:
                fragmentSecurityViewModel.onClickRippleOk(view);
                break;
        }
    });
    fragmentSecurityBinding.ffsLayoutToolbar.addView(securityToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
    toolbarItem.setVisibility(View.GONE);
    fragmentSecurityViewModel.titleToolbar.observe(G.fragmentActivity, s -> securityToolbar.setTitle(s));
    fragmentSecurityViewModel.rippleOkVisibility.observe(G.fragmentActivity, visibility -> toolbarItem.setVisibility(visibility));
    fragmentSecurityViewModel.goToSetSecurityPassword.observe(getViewLifecycleOwner(), password -> {
        if (getActivity() != null && password != null) {
            FragmentSetSecurityPassword fragmentSetSecurityPassword = new FragmentSetSecurityPassword();
            Bundle bundle = new Bundle();
            bundle.putString("OLD_PASSWORD", password);
            fragmentSetSecurityPassword.setArguments(bundle);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragmentSetSecurityPassword).load();
        }
    });
    fragmentSecurityViewModel.showForgetPasswordDialog.observe(getViewLifecycleOwner(), listRes -> {
        if (getActivity() != null && listRes != null) {
            new MaterialDialog.Builder(getActivity()).title(R.string.set_recovery_dialog_title).items(listRes).itemsCallback((dialog, view1, which, text) -> fragmentSecurityViewModel.forgetPassword(text.equals(getString(R.string.recovery_by_email_dialog)))).show();
        }
    });
    fragmentSecurityViewModel.goToSecurityRecoveryPage.observe(getViewLifecycleOwner(), data -> {
        if (getActivity() != null && data != null) {
            FragmentSecurityRecovery fragmentSecurityRecovery = new FragmentSecurityRecovery();
            Bundle bundle = new Bundle();
            bundle.putSerializable("PAGE", data.getSecurity());
            bundle.putString("QUESTION_ONE", data.getQuestionOne());
            bundle.putString("QUESTION_TWO", data.getQuestionTwo());
            bundle.putString("PATERN_EMAIL", data.getEmailPattern());
            bundle.putBoolean("IS_EMAIL", data.isEmail());
            bundle.putBoolean("IS_CONFIRM_EMAIL", data.isConfirmEmail());
            fragmentSecurityRecovery.setArguments(bundle);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragmentSecurityRecovery).load();
        }
    });
    onPopBackStackFragment = this::popBackStackFragment;
}
Also used : Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) LayoutInflater(android.view.LayoutInflater) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) ViewGroup(android.view.ViewGroup) G(net.iGap.G) Color(android.graphics.Color) Gravity(android.view.Gravity) Nullable(androidx.annotation.Nullable) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) FragmentSecurityViewModel(net.iGap.viewmodel.FragmentSecurityViewModel) Fragment(androidx.fragment.app.Fragment) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) R(net.iGap.R) LayoutCreator(net.iGap.helper.LayoutCreator) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) NotNull(org.jetbrains.annotations.NotNull) FragmentFragmentSecurityBinding(net.iGap.databinding.FragmentFragmentSecurityBinding) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar) DataBindingUtil(androidx.databinding.DataBindingUtil) ToolbarItem(net.iGap.messenger.ui.toolBar.ToolbarItem) Bundle(android.os.Bundle) BackDrawable(net.iGap.messenger.ui.toolBar.BackDrawable) HelperFragment(net.iGap.helper.HelperFragment) Toolbar(net.iGap.messenger.ui.toolBar.Toolbar)

Aggregations

HelperFragment (net.iGap.helper.HelperFragment)93 Bundle (android.os.Bundle)32 View (android.view.View)31 Fragment (androidx.fragment.app.Fragment)25 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)15 RecyclerView (androidx.recyclerview.widget.RecyclerView)14 ToolbarListener (net.iGap.observers.interfaces.ToolbarListener)14 ViewGroup (android.view.ViewGroup)13 NonNull (androidx.annotation.NonNull)13 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)13 Theme (net.iGap.module.Theme)13 R (net.iGap.R)12 OnGetPermission (net.iGap.observers.interfaces.OnGetPermission)12 LayoutInflater (android.view.LayoutInflater)11 TextView (android.widget.TextView)11 Nullable (androidx.annotation.Nullable)11 HelperString (net.iGap.helper.HelperString)10 BackDrawable (net.iGap.messenger.ui.toolBar.BackDrawable)10