use of xyz.zedler.patrick.grocy.viewmodel.SettingsViewModel in project grocy-android by patzly.
the class SettingsCatDebuggingFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
activity = (MainActivity) requireActivity();
SettingsViewModel viewModel = new ViewModelProvider(this).get(SettingsViewModel.class);
binding.setActivity(activity);
binding.setFragment(this);
binding.setViewModel(viewModel);
binding.setSharedPrefs(PreferenceManager.getDefaultSharedPreferences(activity));
binding.setClickUtil(new ClickUtil());
binding.setLifecycleOwner(getViewLifecycleOwner());
viewModel.getEventHandler().observe(getViewLifecycleOwner(), event -> {
if (event.getType() == Event.SNACKBAR_MESSAGE) {
activity.showSnackbar(((SnackbarMessage) event).getSnackbar(activity, activity.binding.frameMainContainer));
} else if (event.getType() == Event.BOTTOM_SHEET) {
BottomSheetEvent bottomSheetEvent = (BottomSheetEvent) event;
activity.showBottomSheet(bottomSheetEvent.getBottomSheet(), event.getBundle());
}
});
if (activity.binding.bottomAppBar.getVisibility() == View.VISIBLE) {
activity.getScrollBehavior().setUpScroll(binding.scroll);
activity.getScrollBehavior().setHideOnScroll(true);
activity.updateBottomAppBar(Constants.FAB.POSITION.GONE, R.menu.menu_empty, false, () -> {
});
activity.binding.fabMain.hide();
}
setForPreviousDestination(Constants.ARGUMENT.ANIMATED, false);
}
use of xyz.zedler.patrick.grocy.viewmodel.SettingsViewModel in project grocy-android by patzly.
the class SettingsCatScannerFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
activity = (MainActivity) requireActivity();
SettingsViewModel viewModel = new ViewModelProvider(this).get(SettingsViewModel.class);
binding.setActivity(activity);
binding.setFragment(this);
binding.setViewModel(viewModel);
binding.setSharedPrefs(PreferenceManager.getDefaultSharedPreferences(activity));
binding.setClickUtil(new ClickUtil());
binding.setLifecycleOwner(getViewLifecycleOwner());
viewModel.getEventHandler().observe(getViewLifecycleOwner(), event -> {
if (event.getType() == Event.SNACKBAR_MESSAGE) {
activity.showSnackbar(((SnackbarMessage) event).getSnackbar(activity, activity.binding.frameMainContainer));
} else if (event.getType() == Event.BOTTOM_SHEET) {
BottomSheetEvent bottomSheetEvent = (BottomSheetEvent) event;
activity.showBottomSheet(bottomSheetEvent.getBottomSheet(), event.getBundle());
}
});
updateBarcodeFormats();
if (activity.binding.bottomAppBar.getVisibility() == View.VISIBLE) {
activity.getScrollBehavior().setUpScroll(binding.scroll);
activity.getScrollBehavior().setHideOnScroll(true);
activity.updateBottomAppBar(Constants.FAB.POSITION.GONE, R.menu.menu_empty, false, () -> {
});
activity.binding.fabMain.hide();
}
setForPreviousDestination(Constants.ARGUMENT.ANIMATED, false);
}
Aggregations