Make sure that Artwork is always sorted by rating

This commit is contained in:
Reinhard Pointner 2016-05-08 01:53:36 +08:00
parent 935c01a6ed
commit ac5e77ed4e
4 changed files with 6 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import static java.util.Collections.*;
import java.io.Serializable; import java.io.Serializable;
import java.net.URL; import java.net.URL;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
@ -82,4 +83,6 @@ public class Artwork implements Serializable {
return asList(String.join("/", tags), language, new DecimalFormat("0.##").format(rating), url).toString(); return asList(String.join("/", tags), language, new DecimalFormat("0.##").format(rating), url).toString();
} }
public static final Comparator<Artwork> RATING_ORDER = Comparator.comparing(Artwork::getRating, reverseOrder());
} }

View File

@ -59,7 +59,7 @@ public class FanartTVClient implements Datasource, ArtworkProvider {
return null; return null;
} }
}); });
}).filter(Objects::nonNull).collect(toList()); }).filter(Objects::nonNull).sorted(Artwork.RATING_ORDER).collect(toList());
} }
} }

View File

@ -288,7 +288,7 @@ public class TMDbClient implements MovieIdentificationService, ArtworkProvider {
debug.log(Level.WARNING, e, e::getMessage); debug.log(Level.WARNING, e, e::getMessage);
return null; return null;
} }
}).filter(Objects::nonNull).collect(toList()); }).filter(Objects::nonNull).sorted(Artwork.RATING_ORDER).collect(toList());
} }
protected Object request(String resource, Map<String, Object> parameters, Locale locale, final FloodLimit limit) throws Exception { protected Object request(String resource, Map<String, Object> parameters, Locale locale, final FloodLimit limit) throws Exception {

View File

@ -258,7 +258,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider implements Artwor
debug.log(Level.WARNING, e, e::getMessage); debug.log(Level.WARNING, e, e::getMessage);
return null; return null;
} }
}).filter(Objects::nonNull).collect(toList()); }).filter(Objects::nonNull).sorted(Artwork.RATING_ORDER).collect(toList());
} }
protected URL resolveBanner(String path) { protected URL resolveBanner(String path) {