Skip to content

Commit

Permalink
Handle missing thumbnails in RedditAlbumService
Browse files Browse the repository at this point in the history
If an image/gif is too small, reddit won't generate thumbnails for them,
see https://redd.it/tejlvr and https://redd.it/teju6i
  • Loading branch information
the-blank-x committed Mar 15, 2022
1 parent 06b0d67 commit 86d7c33
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ public void onRequestSuccess( Context context, String resp )
img = Html.fromHtml( mediaObj.getJSONObject( "s" ).getString( "u" ) ).toString();
}

thumb = Html.fromHtml( mediaObj.getJSONArray( "p" ).getJSONObject( 0 ).getString( "u" ) ).toString();
if ( mediaObj.getJSONArray( "p" ).length() > 0 )
{
thumb = Html.fromHtml( mediaObj.getJSONArray( "p" ).getJSONObject( 0 ).getString( "u" ) ).toString();
}
else
{
thumb = img;
}

images[ i ] = new ImgurImage( mediaId, img, Uri.parse( thumb ), null != videoUri ? Uri.parse( videoUri ) : null, 0 == i && null != title && !title.isEmpty() ? title : "" );
}
Expand Down

0 comments on commit 86d7c33

Please sign in to comment.