1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-21 22:27:29 +00:00
This commit is contained in:
Austin Huang 2021-04-04 10:59:24 -04:00 committed by GitHub
parent d569e718a9
commit 917e4f3fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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