Skip to content

Commit

Permalink
Fix invalid image json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Samoxive committed Jan 9, 2018
1 parent 6717b85 commit 84dd4db
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/main/java/com/imgurisnotimgur/api/ImgurApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,16 @@ class ImgurApi {
val jsonResponse = body.string()
val gson = Gson()
val imgurJson = getJsonData(jsonResponse)
val imgurImage = gson.fromJson(imgurJson, Image::class.java)
return Image(imgurImage.id, id, SecretUtils.getSecrets(context).second.accountUsername, imgurImage.points, imgurImage.createdAt, imgurImage.albumId, imgurImage.isAlbum)
val imgurImage = gson.fromJson(imgurJson, ImgurGalleryAlbum::class.java)
return Image (
if (imgurImage.is_album) { imgurImage.cover } else { imgurImage.id },
if (imgurImage.title != null) { imgurImage.title } else { imgurImage.id },
SecretUtils.getSecrets(context).second.accountUsername,
imgurImage.points,
imgurImage.datetime,
if (imgurImage.is_album) { imgurImage.id } else { "" },
imgurImage.is_album
)
}
}
}

0 comments on commit 84dd4db

Please sign in to comment.