Skip to content

Add non-null check for activity in Gutenberg fragment#10860

Merged
malinajirka merged 2 commits intodevelopfrom
fix/crash_in_gutenberg_fragment
Nov 28, 2019
Merged

Add non-null check for activity in Gutenberg fragment#10860
malinajirka merged 2 commits intodevelopfrom
fix/crash_in_gutenberg_fragment

Conversation

@planarvoid
Copy link
Copy Markdown
Contributor

Fixes #10829

This PR adds a non-null check for activity to the onGetOtherMediaImageOptions callback from Gutenberg.

To test:

  • I don't know how to reproduce this issue but the fix should be straightforward

PR submission checklist:

  • I have considered adding unit tests where possible.

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Nov 27, 2019

You can test the changes on this Pull Request by downloading the APK here.


private ArrayList<MediaOption> initOtherMediaImageOptions() {
ArrayList<MediaOption> otherMediaOptions = new ArrayList<>();
FragmentActivity activity = getActivity();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU the surrounded code, the editor will be opened, but the "stock photos" option will be missing. I think we might want to log this into a log (maybe even sentry). Wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it will be opened if the activity is null though but I can add tracking in case something else crashes after it passes this check 👍

Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @planarvoid! LGTM - feel free to merge it if you decide adding a log isn't worth it/doesn't make sense.

@malinajirka
Copy link
Copy Markdown
Contributor

LGTM, thanks!

@malinajirka malinajirka merged commit 0972e84 into develop Nov 28, 2019
@malinajirka malinajirka deleted the fix/crash_in_gutenberg_fragment branch November 28, 2019 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullPointerException: Attempt to invoke virtual method 'android.app.Application android.app.Activity.getApplication()' ...

2 participants