Skip to content

Commit

Permalink
#1320 - crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
budowski committed Dec 31, 2023
1 parent 4d1ea8b commit a5e85ab
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,15 @@ public Object instantiateItem(ViewGroup container, final int position) {

if (mObsJson != null) {
try {
BetterJSONObject obsPhoto = new BetterJSONObject(new JSONObject(mObsJson).getJSONArray("observation_photos").getJSONObject(position));
item = new BetterJSONObject(obsPhoto.getJSONObject("photo"));
isHidden = new ObservationPhoto(obsPhoto).hidden;
JSONArray obsPhotos = new JSONObject(mObsJson).getJSONArray("observation_photos");

if (position < obsPhotos.length()) {
BetterJSONObject obsPhoto = new BetterJSONObject(obsPhotos.getJSONObject(position));
item = new BetterJSONObject(obsPhoto.getJSONObject("photo"));
isHidden = new ObservationPhoto(obsPhoto).hidden;
}
} catch (JSONException e) {
throw new RuntimeException(e);
Logger.error(e);
}
} else if (mObservation.photos != null && mObservation.photos.size() > position) {
isHidden = mObservation.photos.get(position).hidden;
Expand Down

0 comments on commit a5e85ab

Please sign in to comment.