Skip to content

Commit

Permalink
Wrap Android dismiss methods in try-catch blocks (#449)
Browse files Browse the repository at this point in the history
* Wrap Android dismiss methods in try-catch blocks

* Move try-catch block to dismissDialog method
  • Loading branch information
juanamd authored May 20, 2021
1 parent f9238ab commit 08072ae
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ public static void dismissDialog(FragmentActivity activity, String fragmentTag,
return;
}

FragmentManager fragmentManager = activity.getSupportFragmentManager();
final DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(fragmentTag);
try {
FragmentManager fragmentManager = activity.getSupportFragmentManager();
final DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(fragmentTag);

boolean fragmentFound = oldFragment != null;
if (fragmentFound) {
oldFragment.dismiss();
}
boolean fragmentFound = oldFragment != null;
if (fragmentFound) {
oldFragment.dismiss();
}

promise.resolve(fragmentFound);
promise.resolve(fragmentFound);
} catch (Exception e) {
promise.reject(e);
}
}
}

0 comments on commit 08072ae

Please sign in to comment.