Skip to content

Commit

Permalink
[Refactor] Fix NPE related to ViewModels
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <[email protected]>
  • Loading branch information
MuntashirAkon committed Oct 2, 2023
1 parent d1830bb commit c73f40c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ private void handleMigrationAndModeOfOp() {
// Authentication was successful
Log.d(TAG, "Authenticated");
// Set mode of operation
Objects.requireNonNull(mViewModel).setModeOfOps();
if (mViewModel != null) {
mViewModel.setModeOfOps();
}
}

private void initPermissionChecks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public class MainActivity extends BaseActivity implements AdvancedSearchView.OnQ
// Back button pressed.
return;
}
if (mModel == null) {
// Invalid state
return;
}
RulesTypeSelectionDialogFragment dialogFragment = new RulesTypeSelectionDialogFragment();
Bundle args = new Bundle();
args.putInt(RulesTypeSelectionDialogFragment.ARG_MODE, RulesTypeSelectionDialogFragment.MODE_EXPORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ private void handleMigrationAndModeOfOp() {
mStateNameView.setText(R.string.initializing);
}
// Set mode of operation
mViewModel.setModeOfOps();
if (mViewModel != null) {
mViewModel.setModeOfOps();
}
}
}

0 comments on commit c73f40c

Please sign in to comment.