|
@ -1094,7 +1094,6 @@ public final class ResponseBodyUtils { |
|
|
final List<MediaCandidate> sortedCandidates = candidates.stream() |
|
|
final List<MediaCandidate> sortedCandidates = candidates.stream() |
|
|
.sorted((c1, c2) -> Integer.compare(c2.getWidth(), c1.getWidth())) |
|
|
.sorted((c1, c2) -> Integer.compare(c2.getWidth(), c1.getWidth())) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
if (sortedCandidates.size() == 1) return sortedCandidates.get(0).getUrl(); |
|
|
|
|
|
final List<MediaCandidate> filteredCandidates = sortedCandidates.stream() |
|
|
final List<MediaCandidate> filteredCandidates = sortedCandidates.stream() |
|
|
.filter(c -> |
|
|
.filter(c -> |
|
|
c.getWidth() <= media.getOriginalWidth() |
|
|
c.getWidth() <= media.getOriginalWidth() |
|
@ -1102,6 +1101,7 @@ public final class ResponseBodyUtils { |
|
|
&& (isSquare || Integer.compare(c.getWidth(), c.getHeight()) != 0) |
|
|
&& (isSquare || Integer.compare(c.getWidth(), c.getHeight()) != 0) |
|
|
) |
|
|
) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (filteredCandidates.size() == 0) return sortedCandidates.get(0).getUrl(); |
|
|
final MediaCandidate candidate = filteredCandidates.get(0); |
|
|
final MediaCandidate candidate = filteredCandidates.get(0); |
|
|
if (candidate == null) return null; |
|
|
if (candidate == null) return null; |
|
|
return candidate.getUrl(); |
|
|
return candidate.getUrl(); |
|
|