use of net.iGap.observers.interfaces.ToolbarListener 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.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class ShowBillInquiryFragment 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(getArguments() != null ? getArguments().getInt("titleRes") : R.string.bills_inquiry)).setLeftIcon(R.string.icon_back).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
}).getView());
viewModel.getShowErrorMessage().observe(getViewLifecycleOwner(), errorMessageResId -> {
if (errorMessageResId != null) {
HelperError.showSnackMessage(getString(errorMessageResId), false);
}
});
viewModel.getGoBack().observe(getViewLifecycleOwner(), isGoBack -> {
if (isGoBack != null && isGoBack) {
popBackStackFragment();
}
});
}
use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class StickerSettingFragment method setupViews.
@Override
public void setupViews() {
RecyclerView recyclerView = rootView.findViewById(R.id.rv_removeSticker);
LinearLayout linearLayout = rootView.findViewById(R.id.ll_stickerSetting_toolBar);
HelperToolbar helperToolbar = HelperToolbar.create().setLeftIcon(R.string.icon_back).setLogoShown(true).setDefaultTitle(getResources().getString(R.string.sticker_setting)).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
finish();
}
}).setContext(getContext());
linearLayout.addView(helperToolbar.getView());
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
viewModel.getStickersLiveData().observe(getViewLifecycleOwner(), structIGStickerGroups -> adapter.updateAdapter(structIGStickerGroups));
adapter.setListener(new RemoveStickerAdapter.RemoveStickerDialogListener() {
@Override
public void onStickerClick(StructIGStickerGroup stickerGroup) {
openFragmentAddStickerToFavorite(stickerGroup);
}
@Override
public void onRemoveStickerClick(StructIGStickerGroup stickerGroup, int pos, RemoveStickerAdapter.ProgressStatus progressStatus) {
if (getContext() != null) {
new MaterialDialog.Builder(getContext()).title(getResources().getString(R.string.remove_sticker)).content(getResources().getString(R.string.remove_sticker_text)).positiveText(getString(R.string.yes)).negativeText(getString(R.string.no)).onPositive((dialog, which) -> {
progressStatus.setVisibility(true);
viewModel.removeStickerFromMySticker(stickerGroup, (response, error) -> {
if (error == null) {
adapter.removeItem(pos);
} else {
progressStatus.setVisibility(false);
}
});
dialog.dismiss();
}).show();
}
}
});
viewModel.getRemoveStickerLiveData().observe(getViewLifecycleOwner(), removedItemPosition -> adapter.removeItem(removedItemPosition));
TextView removeRecentTv = rootView.findViewById(R.id.tv_stickerSetting_clearRecent);
removeRecentTv.setOnClickListener(v -> onClearRecentStickerClicked());
ProgressBar progressBar = rootView.findViewById(R.id.pb_stickerSetting_clearRecent);
viewModel.getClearRecentStickerLiveData().observe(getViewLifecycleOwner(), progressBar::setVisibility);
TextView clearInternalStorage = rootView.findViewById(R.id.tv_stickerSetting_clearStorage);
clearInternalStorage.setOnClickListener(v -> viewModel.clearStickerFromInternalStorage());
TextView storageSize = rootView.findViewById(R.id.tv_stickerSetting_clearStorageSize);
viewModel.getStickerFileSizeLiveData().observe(getViewLifecycleOwner(), storageSize::setText);
TextView clearFavoriteStickerTv = rootView.findViewById(R.id.tv_stickerSetting_clearFavorite);
clearFavoriteStickerTv.setOnClickListener(v -> onClearFavoriteStickerClicked());
ProgressBar clearFavoriteStickerPb = rootView.findViewById(R.id.pb_stickerSetting_clearFavorite);
TextView clearRecentEmojiTv = rootView.findViewById(R.id.tv_stickerSetting_clearEmoji);
clearRecentEmojiTv.setOnClickListener(v -> onClearRecentEmojiClicked());
ImageView emptyIv = rootView.findViewById(R.id.iv_stickerSetting_empty);
TextView emptyTv = rootView.findViewById(R.id.tv_stickerSetting_empty);
TextView headerTv = rootView.findViewById(R.id.tv_stickerSetting_header);
viewModel.getEmptyRecentStickerLiveData().observe(getViewLifecycleOwner(), visibility -> {
emptyIv.setVisibility(visibility);
emptyTv.setVisibility(visibility);
});
viewModel.getRecyclerVisibilityRecentStickerLiveData().observe(getViewLifecycleOwner(), visibility -> {
recyclerView.setVisibility(visibility);
headerTv.setVisibility(visibility);
});
}
use of net.iGap.observers.interfaces.ToolbarListener in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListFrag method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperToolbar mHelperToolbar = HelperToolbar.create().setContext(getContext()).setLeftIcon(R.string.icon_back).setLifecycleOwner(getViewLifecycleOwner()).setListener(new ToolbarListener() {
@Override
public void onLeftIconClickListener(View view) {
popBackStackFragment();
}
@Override
public void onRightIconClickListener(View view) {
List<Integer> items = new ArrayList<>();
items.add(R.string.elecBill_cell_deleteAccount);
new TopSheetDialog(getContext()).setListDataWithResourceId(items, -1, position -> {
if (position == 0) {
final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteAccount_title).content(R.string.elecBill_deleteAccount_desc).positiveText(R.string.elecBill_deleteAccount_pos).negativeText(R.string.elecBill_deleteAccount_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> viewModel.deleteAccount()).build();
dialog.show();
}
}).show();
}
}).setLogoShown(true);
LinearLayout toolbarLayout = binding.Toolbar;
toolbarLayout.addView(mHelperToolbar.getView());
binding.billRecycler.setHasFixedSize(true);
onDataChangedListener();
viewModel.getBillsList();
}
use of net.iGap.observers.interfaces.ToolbarListener 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();
}
});
}
Aggregations