use of retrospector.util.MediaComparator in project Retrospector by NonlinearFruit.
the class ListsTabController method updateListTab.
private void updateListTab() {
listTableData.clear();
if (!listGroupCreator.isSelected())
return;
boolean creator = listGroupCreator.isSelected();
boolean title = listGroupTitle.isSelected();
boolean season = listGroupSeason.isSelected();
boolean episode = listGroupEpisode.isSelected();
Chartagories chartagory = episode ? Chartagories.CURRENT_MEDIA : season ? Chartagories.SEASON : title ? Chartagories.TITLE : Chartagories.CREATOR;
Integer top = listTop10.isSelected() ? 10 : listTop25.isSelected() ? 25 : listTop50.isSelected() ? 50 : listTop100.isSelected() ? 100 : listTop500.isSelected() ? 500 : 1000;
LocalDate start = listCustomDateRange.isSelected() ? listStartDate.getValue().minus(1, ChronoUnit.DAYS) : LocalDate.of(Integer.parseInt(listYear.getText()) - 1, 12, 31);
start = listUseAllTime.isSelected() ? LocalDate.MIN : start;
LocalDate end = listCustomDateRange.isSelected() ? listEndDate.getValue().plus(1, ChronoUnit.DAYS) : LocalDate.of(Integer.parseInt(listYear.getText()) + 1, 1, 1);
end = listUseAllTime.isSelected() ? LocalDate.MAX : end;
String user = listUser.getText();
for (Media media : DataManager.getMedia()) {
for (Stroolean stroolean : strooleans) {
if (stroolean.isBoolean() && media.getCategory().equals(stroolean.getString())) {
boolean homeless = true;
for (Media data : listTableData) {
Media temp = new Media();
temp.clone(media);
temp.setCategory(data.getCategory());
temp.setType(data.getType());
if (UtilityCloset.isSameMedia(chartagory, data, temp)) {
homeless = false;
for (Review review : media.getReviews()) {
if (review.getDate().isBefore(end) && review.getDate().isAfter(start) && review.getUser().equals(user)) {
data.getReviews().add(review);
}
}
break;
}
}
if (homeless) {
Media m = new Media();
if (creator)
m.setCreator(media.getCreator());
if (title)
m.setTitle(media.getTitle());
if (season)
m.setSeasonId(media.getSeasonId());
if (episode)
m.setEpisodeId(media.getEpisodeId());
m.setCategory(media.getCategory());
for (Review review : media.getReviews()) {
if (review.getUser().equals(user)) {
if (review.getDate().isBefore(end) && review.getDate().isAfter(start)) {
m.getReviews().add(review);
}
}
}
listTableData.add(m);
}
}
}
}
List rankedResults = listTableData.stream().sorted(new MediaComparator()).limit(top).collect(Collectors.toList());
listTable.setItems(FXCollections.observableArrayList(rankedResults));
listRankColumn.setCellValueFactory(p -> new ReadOnlyObjectWrapper(1 + rankedResults.indexOf(p.getValue())));
listTable.refresh();
}
Aggregations