use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class IGashtLocationListFragment 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).setRightIcons(R.string.icon_time).setLogoShown(true).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
@Override
public void onRightIconClickListener(View view) {
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtHistoryPlaceListFragment()).setReplace(false).load(true);
}
}
}).getView());
binding.locationListView.addItemDecoration(new DividerItemDecoration(binding.locationListView.getContext(), DividerItemDecoration.VERTICAL));
binding.locationListView.setAdapter(new IGashtLocationListAdapter(viewModel.getSelectedProvinceName(), new IGashtLocationListAdapter.onLocationItemClickListener() {
@Override
public void buyTicket(int position) {
viewModel.buyTicket(position);
}
@Override
public void onItem(int position) {
viewModel.buyTicket(position);
}
}));
viewModel.getLocationList().observe(getViewLifecycleOwner(), data -> {
if (binding.locationListView.getAdapter() instanceof IGashtLocationListAdapter && data != null) {
((IGashtLocationListAdapter) binding.locationListView.getAdapter()).setItems(data);
}
});
viewModel.getGoToLocationDetail().observe(getViewLifecycleOwner(), isGo -> {
if (getActivity() != null && isGo != null) {
if (isGo) {
new HelperFragment(getActivity().getSupportFragmentManager()).setFragment(new IGashtLocationDetailFragment()).setReplace(false).load(true);
} else {
Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
}
}
});
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class IGashtProvinceFragment 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).setLeftIcon(R.string.icon_back).setRightIcons(R.string.icon_time).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
}
@Override
public void onRightIconClickListener(View view) {
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtHistoryPlaceListFragment()).setReplace(false).load(true);
}
}
}).getView());
binding.provinceSearchText.setOnItemClickListener((parent, view1, position, id) -> viewModel.setSelectedLocation(position));
viewModel.getGoToShowLocationListPage().observe(getViewLifecycleOwner(), isGo -> {
((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(), 0);
if (getActivity() != null && isGo != null) {
if (isGo) {
new HelperFragment(getActivity().getSupportFragmentManager(), new IGashtLocationListFragment()).setReplace(false).load(true);
} else {
Toast.makeText(getContext(), R.string.select_province, Toast.LENGTH_SHORT).show();
}
}
});
viewModel.getProvinceListResult().observe(getViewLifecycleOwner(), data -> {
if (data != null) {
binding.provinceSearchText.setAdapter(new ProvinceSuggestionListAdapter(getContext(), data));
}
});
viewModel.getClearEditText().observe(getViewLifecycleOwner(), isClear -> {
if (isClear != null && isClear) {
binding.provinceSearchText.requestFocus();
binding.provinceSearchText.setText("");
}
});
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class InternetFragment method initForm.
private void initForm() {
DbManager.getInstance().doRealmTask(realm -> {
RealmRegisteredInfo userInfo = realm.where(RealmRegisteredInfo.class).findFirst();
if (userInfo != null) {
userNumber = userInfo.getPhoneNumber();
if (phoneNumber != null && !phoneNumber.isEmpty() && !phoneNumber.equals("0")) {
setPhoneNumberEditText(phoneNumber);
if (peerId != 0) {
avatarHandler.getAvatar(new ParamWithAvatarType(avatar, peerId).avatarType(AvatarHandler.AvatarType.ROOM).showMain());
}
}
if (phoneNumber != null && phoneNumber.equals("0")) {
avatar.setVisibility(View.GONE);
editTextNumber.setHint(getActivity().getString(R.string.please_enter_phone_number));
removeButton.setText(R.string.icon_edit);
} else {
avatar.setVisibility(View.GONE);
setPhoneNumberEditText(userNumber);
}
if (editTextNumber.getText() != null && editTextNumber.getText().length() == 11) {
hideKeyboard();
}
editTextNumber.setSelection(editTextNumber.getText() == null ? 0 : editTextNumber.getText().length());
}
});
operatorAdapter = new OperatorAdapter(getContext(), operators, operatorName -> {
if (currentConfigData != null) {
changeOperator(currentConfigData.getOperator());
} else {
operatorAdapter.setCheckedRadioButton(null);
HelperError.showSnackMessage(getActivity().getString(R.string.please_enter_phone_number), false);
}
});
lstOperator.setAdapter(operatorAdapter);
detectOperatorByNumber(editTextNumber.getText().toString());
chargeApi = new RetrofitFactory().getChargeRetrofit();
editTextNumber.addTextChangedListener(editTextNumberWatcher());
removeButton.setOnClickListener(removeNumberClicked());
frameContact.setOnClickListener(v -> onContactNumberButtonClick());
frameHistory.setOnClickListener(v -> onHistoryNumberButtonClick());
radioGroup.setOnCheckedChangeListener((group, checkedId) -> InternetFragment.this.changeSimType());
goNextButton.setOnClickListener(v -> {
RadioButton radioButton = radioGroup.findViewById(radioGroup.getCheckedRadioButtonId());
if (radioButton != null) {
if (currentSimType == null) {
showError(getActivity().getString(R.string.invalid_sim_type));
return;
}
if (editTextNumber.getText() == null) {
editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
return;
}
String rechargeableNumber = editTextNumber.getText().toString().trim();
if (!isNumeric(rechargeableNumber) || rechargeableNumber.length() < 11) {
editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
return;
}
if (!isNumberFromIran(rechargeableNumber)) {
editTextNumber.setError(getString(R.string.phone_number_is_not_valid));
return;
}
int packageType = historyNumber != null ? Integer.parseInt(historyNumber.getPackageType()) : -1;
new HelperFragment(getActivity().getSupportFragmentManager(), PaymentInternetFragment.newInstance(userNumber, rechargeableNumber, currentOperator.getKey(), currentSimType, packageType)).setAnimated(false).setReplace(false).load();
} else {
showError(getActivity().getString(R.string.sim_type_not_choosed));
}
});
progressBar.setVisibility(View.GONE);
scrollView.setVisibility(View.VISIBLE);
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class MplTransactionFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setUpViews();
viewModel.getMplTransactionLiveData().observe(getViewLifecycleOwner(), mplTransaction -> {
if (mplTransaction != null) {
if (mplTransaction.size() > 0) {
adapter.setTransAction(mplTransaction);
start = adapter.getItemCount();
end = start + MplTransactionViewModel.PAGINATION_LIMIT;
page++;
}
}
});
viewModel.getProgressMutableLiveData().observe(getViewLifecycleOwner(), progress -> {
if (progress != null)
swipeRefreshLayout.setRefreshing(progress);
});
recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(layoutManager) {
@Override
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
viewModel.getMorePageOffset(start, end);
}
});
swipeRefreshLayout.setOnRefreshListener(() -> {
viewModel.getFirstPageMplTransactionList(viewModel.getType());
});
adapter.setCallBack(token -> {
if (token != null)
new HelperFragment(getFragmentManager(), MplTransactionInfoFragment.getInstance(token)).setReplace(false).load();
});
typeAllTv.setOnClickListener(v -> {
setEnableButton(typeAllTv, typeBillTv, typeCardToCardTv, typeSalesTv, typeTopUpTv);
viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.NONE);
});
typeBillTv.setOnClickListener(v -> {
setEnableButton(typeBillTv, typeAllTv, typeCardToCardTv, typeSalesTv, typeTopUpTv);
viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.BILL);
});
typeCardToCardTv.setOnClickListener(v -> {
setEnableButton(typeCardToCardTv, typeAllTv, typeBillTv, typeSalesTv, typeTopUpTv);
viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.CARD_TO_CARD);
});
typeSalesTv.setOnClickListener(v -> {
setEnableButton(typeSalesTv, typeAllTv, typeBillTv, typeCardToCardTv, typeTopUpTv);
viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.SALES);
});
typeTopUpTv.setOnClickListener(v -> {
setEnableButton(typeTopUpTv, typeAllTv, typeBillTv, typeCardToCardTv, typeSalesTv);
viewModel.getFirstPageMplTransactionList(ProtoGlobal.MplTransaction.Type.TOPUP);
});
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class BaseViewHolder method actionPage.
private static void actionPage(String value, FragmentActivity activity, boolean haveNext) {
try {
// this is because in some times not set correct value in server when change or add new item
DiscoveryFragment discoveryFragment = DiscoveryFragment.newInstance(Integer.valueOf(value));
discoveryFragment.setNeedToCrawl(haveNext);
new HelperFragment(activity.getSupportFragmentManager(), discoveryFragment).setReplace(false).load(false);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations