Skip to content

Commit 963072e

Browse files
ashishkumar468maskaravivek
authored andcommitted
BugFix issue #2711 (#2712)
* Added null checks in OkHttpJsonApiClient$searchImages MwQueryResponse
1 parent 01f6c99 commit 963072e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

app/src/main/java/fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ public Single<List<Media>> searchImages(String query, int offset) {
242242
return mediaList;
243243
}
244244
MwQueryResponse mwQueryResponse = gson.fromJson(json, MwQueryResponse.class);
245+
246+
if (null == mwQueryResponse
247+
|| null == mwQueryResponse.query()
248+
|| null == mwQueryResponse.query().pages()) {
249+
return mediaList;
250+
}
251+
245252
List<MwQueryPage> pages = mwQueryResponse.query().pages();
246253
for (MwQueryPage page : pages) {
247254
mediaList.add(Media.from(page));

0 commit comments

Comments
 (0)