Skip to content

Instantly share code, notes, and snippets.

@varundwarkani
Created June 13, 2021 08:40
Show Gist options
  • Save varundwarkani/dbf41187883dc98ff5823b68225b4a73 to your computer and use it in GitHub Desktop.
Save varundwarkani/dbf41187883dc98ff5823b68225b4a73 to your computer and use it in GitHub Desktop.
public class CallingFragment extends Fragment {
private UPIViewModel upiViewModel;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
upiViewModel = new ViewModelProvider(requireActivity()).get(UPIViewModel.class);
setObservers();
}
private void setObservers() {
upiViewModel.canSaveData.observer(getViewLifecycleOwner(), canSaveData -> {
if (canSaveData) {
String upiID = upiViewModel.upiID.getValue();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment