Skip to content

Commit

Permalink
Merge pull request #20838 from wordpress-mobile/andy/sentry-issue-444…
Browse files Browse the repository at this point in the history
…5203744

[Bug] Fix crash caused by requireContext in GutenbergEditorFragment.
  • Loading branch information
aditi-bhatia committed May 17, 2024
2 parents a4845bb + 5313b83 commit a32269a
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ private ArrayList<MediaOption> initOtherMediaImageOptions() {

Bundle arguments = getArguments();
FragmentActivity activity = getActivity();
if (activity == null || arguments == null) {
final Context context = getContext();
if (activity == null || context == null || arguments == null) {
AppLog.e(T.EDITOR,
"Failed to initialize other media options because the activity or getArguments() is null");
return otherMediaOptions;
Expand All @@ -710,13 +711,13 @@ private ArrayList<MediaOption> initOtherMediaImageOptions() {
String packageName = activity.getApplication().getPackageName();
if (supportStockPhotos) {
int stockMediaResourceId =
getResources().getIdentifier("photo_picker_stock_media", "string", packageName);
context.getResources().getIdentifier("photo_picker_stock_media", "string", packageName);

otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_STOCK_MEDIA, getString(stockMediaResourceId)));
}
if (supportsTenor) {
int gifMediaResourceId =
getResources().getIdentifier("photo_picker_gif", "string", packageName);
context.getResources().getIdentifier("photo_picker_gif", "string", packageName);
otherMediaOptions.add(new MediaOption(GIF_MEDIA, getString(gifMediaResourceId)));
}

Expand Down

0 comments on commit a32269a

Please sign in to comment.