use of xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.FeedbackBottomSheet in project grocy-android by patzly.
the class OverviewStartFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
activity = (MainActivity) requireActivity();
viewModel = new ViewModelProvider(this).get(OverviewStartViewModel.class);
viewModel.setOfflineLive(!activity.isOnline());
binding.setViewModel(viewModel);
binding.setFragment(this);
binding.setActivity(activity);
binding.setLifecycleOwner(getViewLifecycleOwner());
clickUtil = new ClickUtil(1000);
viewModel.getIsLoadingLive().observe(getViewLifecycleOwner(), state -> {
if (!state) {
viewModel.setCurrentQueueLoading(null);
}
});
viewModel.getEventHandler().observeEvent(getViewLifecycleOwner(), event -> {
if (event.getType() == Event.SNACKBAR_MESSAGE) {
activity.showSnackbar(((SnackbarMessage) event).getSnackbar(activity, activity.binding.frameMainContainer));
}
});
infoFullscreenHelper = new InfoFullscreenHelper(binding.frameContainer);
viewModel.getInfoFullscreenLive().observe(getViewLifecycleOwner(), infoFullscreen -> infoFullscreenHelper.setInfo(infoFullscreen));
viewModel.getOfflineLive().observe(getViewLifecycleOwner(), this::appBarOfflineInfo);
binding.toolbar.setOnMenuItemClickListener(item -> {
int id = item.getItemId();
if (id == R.id.action_settings) {
navigateDeepLink(getString(R.string.deep_link_settingsFragment));
} else if (id == R.id.action_about) {
navigateDeepLink(getString(R.string.deep_link_aboutFragment));
} else if (id == R.id.action_feedback) {
activity.showBottomSheet(new FeedbackBottomSheet());
} else if (id == R.id.action_changelog) {
activity.showBottomSheet(new ChangelogBottomSheet());
}
return false;
});
// for offline info in app bar
binding.swipe.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
if (savedInstanceState == null) {
viewModel.loadFromDatabase(true);
}
// UPDATE UI
updateUI((getArguments() == null || getArguments().getBoolean(Constants.ARGUMENT.ANIMATED, true)) && savedInstanceState == null);
}
Aggregations