Search in sources :

Example 91 with HelperFragment

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

the class FragmentCPayCharge method initCallback.

private void initCallback() {
    viewModel.getEditTextVisibilityListener().observe(getViewLifecycleOwner(), isVisible -> {
        if (isVisible == null)
            return;
        binding.edtAmount.setVisibility(isVisible ? View.VISIBLE : View.GONE);
    });
    viewModel.getLoaderListener().observe(getViewLifecycleOwner(), isVisible -> {
        if (isVisible == null)
            return;
        binding.loaderAmount.setVisibility(isVisible ? View.VISIBLE : View.GONE);
        binding.txtCredit.setVisibility(isVisible ? View.INVISIBLE : View.VISIBLE);
    });
    viewModel.getMessageToUser().observe(getViewLifecycleOwner(), resID -> {
        if (resID == null)
            return;
        Toast.makeText(getActivity(), getString(resID), Toast.LENGTH_LONG).show();
    });
    viewModel.getMessageToUserText().observe(getViewLifecycleOwner(), s -> {
        if (s == null)
            return;
        Toast.makeText(getActivity(), s, Toast.LENGTH_LONG).show();
    });
    viewModel.getChargePaymentStateListener().observe(getViewLifecycleOwner(), token -> {
        if (getActivity() == null)
            return;
        if (token == null) {
            Toast.makeText(getContext(), getString(R.string.wallet_error_server), Toast.LENGTH_LONG).show();
            return;
        }
        new HelperFragment(getActivity().getSupportFragmentManager()).loadPayment(getString(R.string.cpay_title), token, result -> {
            if (result.isSuccess()) {
                Toast.makeText(getActivity(), getString(R.string.successful_payment), Toast.LENGTH_LONG).show();
                popBackStackFragment();
            } else {
                Toast.makeText(getActivity(), getString(R.string.unsuccessful_payment), Toast.LENGTH_LONG).show();
            }
        });
    });
}
Also used : HelperFragment(net.iGap.helper.HelperFragment)

Example 92 with HelperFragment

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

the class IGashtHistoryPlaceListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    binding.toolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLeftIcon(R.string.icon_back).setLogoShown(true).setDefaultTitle(getString(R.string.order_history)).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            if (getActivity() != null) {
                getActivity().onBackPressed();
            }
        }
    }).getView());
    binding.favoriteList.setAdapter(new PlaceHistoryAdapter(position -> viewModel.onClickHistoryItem(position)));
    binding.favoriteList.addItemDecoration(new DividerItemDecoration(binding.favoriteList.getContext(), DividerItemDecoration.VERTICAL));
    binding.favoriteList.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (recyclerView.getLayoutManager() != null) {
                viewModel.loadMoreItems(recyclerView.getLayoutManager().getItemCount(), ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition());
            }
        }
    });
    viewModel.getHistoryList().observe(getViewLifecycleOwner(), data -> {
        if (data != null && binding.favoriteList.getAdapter() instanceof PlaceHistoryAdapter) {
            ((PlaceHistoryAdapter) binding.favoriteList.getAdapter()).setItems(data);
        }
    });
    viewModel.getGoToTicketDetail().observe(getViewLifecycleOwner(), voucherNumber -> {
        if (getActivity() != null && voucherNumber != null) {
            Fragment fragment = new FragmentIgashtBarcodeScan();
            Bundle bundle = new Bundle();
            bundle.putString("voucher_number", voucherNumber);
            fragment.setArguments(bundle);
            new HelperFragment(getActivity().getSupportFragmentManager(), fragment).setReplace(false).load(true);
        }
    });
}
Also used : DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Bundle(android.os.Bundle) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) IGashtHistoryPlaceViewModel(net.iGap.viewmodel.igasht.IGashtHistoryPlaceViewModel) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) ViewGroup(android.view.ViewGroup) FragmentIgashtHistoryPlaceBinding(net.iGap.databinding.FragmentIgashtHistoryPlaceBinding) Nullable(androidx.annotation.Nullable) Fragment(androidx.fragment.app.Fragment) PlaceHistoryAdapter(net.iGap.adapter.igahst.PlaceHistoryAdapter) View(android.view.View) ViewModelProviders(androidx.lifecycle.ViewModelProviders) R(net.iGap.R) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment) DataBindingUtil(androidx.databinding.DataBindingUtil) HelperToolbar(net.iGap.helper.HelperToolbar) Bundle(android.os.Bundle) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Fragment(androidx.fragment.app.Fragment) HelperFragment(net.iGap.helper.HelperFragment) PlaceHistoryAdapter(net.iGap.adapter.igahst.PlaceHistoryAdapter) ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) RecyclerView(androidx.recyclerview.widget.RecyclerView) HelperFragment(net.iGap.helper.HelperFragment)

Example 93 with HelperFragment

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

the class FragmentPaymentInquiryMobile method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    binding.toolbar.addView(HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setLogoShown(true).setDefaultTitle(getString(R.string.bills_inquiry_mci)).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {

        @Override
        public void onLeftIconClickListener(View view) {
            popBackStackFragment();
        }
    }).getView());
    viewModel.getShowErrorMessage().observe(getViewLifecycleOwner(), errorMessageId -> {
        if (errorMessageId != null) {
            HelperError.showSnackMessage(getString(errorMessageId), false);
        }
    });
    viewModel.getGoToShowInquiryBillPage().observe(getViewLifecycleOwner(), data -> {
        if (getActivity() != null && data != null) {
            new HelperFragment(getActivity().getSupportFragmentManager(), ShowBillInquiryFragment.getInstance(data, R.string.bills_inquiry_mci)).setReplace(false).load(true);
        }
    });
}
Also used : ToolbarListener(net.iGap.observers.interfaces.ToolbarListener) HelperFragment(net.iGap.helper.HelperFragment) View(android.view.View)

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