Skip to content

Commit

Permalink
#1328 - crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
budowski committed Jan 19, 2024
1 parent c7c88cd commit 508e14c
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,19 +507,23 @@ 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);
}
} else {
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);
}
Expand Down

0 comments on commit 508e14c

Please sign in to comment.