use of net.iGap.adapter.igahst.IGashtLocationListAdapter 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();
}
}
});
}
Aggregations