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();
}
});
});
}
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);
}
});
}
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);
}
});
}
Aggregations