diff --git a/iNaturalist/src/main/java/org/inaturalist/android/ObservationViewerFragment.java b/iNaturalist/src/main/java/org/inaturalist/android/ObservationViewerFragment.java index ceb992a8..ae7deec6 100644 --- a/iNaturalist/src/main/java/org/inaturalist/android/ObservationViewerFragment.java +++ b/iNaturalist/src/main/java/org/inaturalist/android/ObservationViewerFragment.java @@ -507,9 +507,11 @@ public Object instantiateItem(ViewGroup container, final int position) { // Show sound sound = mObservation.sounds.get(position - mObservation.photos.size()); try { - BetterJSONObject obsSound = new BetterJSONObject(new JSONObject(mObsJson).getJSONArray("observation_sounds").getJSONObject(position - mObservation.photos.size())); - item = new BetterJSONObject(obsSound.getJSONObject("sound")); - isHidden = new ObservationSound(obsSound).hidden; + if (mObsJson != null) { + BetterJSONObject obsSound = new BetterJSONObject(new JSONObject(mObsJson).getJSONArray("observation_sounds").getJSONObject(position - mObservation.photos.size())); + item = new BetterJSONObject(obsSound.getJSONObject("sound")); + isHidden = new ObservationSound(obsSound).hidden; + } } catch (JSONException e) { throw new RuntimeException(e); } @@ -517,9 +519,11 @@ public Object instantiateItem(ViewGroup container, final int position) { imageUrl = mObservation.photos.get(position).photo_url; try { - BetterJSONObject obsPhoto = new BetterJSONObject(new JSONObject(mObsJson).getJSONArray("observation_photos").getJSONObject(position)); - item = new BetterJSONObject(obsPhoto.getJSONObject("photo")); - isHidden = new ObservationPhoto(obsPhoto).hidden; + if (mObsJson != null) { + BetterJSONObject obsPhoto = new BetterJSONObject(new JSONObject(mObsJson).getJSONArray("observation_photos").getJSONObject(position)); + item = new BetterJSONObject(obsPhoto.getJSONObject("photo")); + isHidden = new ObservationPhoto(obsPhoto).hidden; + } } catch (JSONException e) { throw new RuntimeException(e); }