Skip to content

Commit

Permalink
- move common functions to super class
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Aug 22, 2024
1 parent dc3d283 commit 6bd50cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,37 +33,6 @@ public GuiFilmeModelHelper(@NotNull FilterActionPanel filterActionPanel,
this.searchFieldData = searchFieldData;
}

private String getFilterThema() {
String filterThema = filterActionPanel.getViewSettingsPane().themaComboBox.getSelectionModel().getSelectedItem();
if (filterThema == null) {
filterThema = "";
}

return filterThema;
}

@Override
protected boolean noFiltersAreSet() {
var filmLengthSlider = filterActionPanel.getFilmLengthSlider();

return filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().isEmpty()
&& getFilterThema().isEmpty()
&& searchFieldData.isEmpty()
&& ((int) filmLengthSlider.getLowValue() == 0)
&& ((int) filmLengthSlider.getHighValue() == FilmLengthSlider.UNLIMITED_VALUE)
&& !filterActionPanel.isDontShowAbos()
&& !filterActionPanel.isShowUnseenOnly()
&& !filterActionPanel.isShowOnlyHighQuality()
&& !filterActionPanel.isShowSubtitlesOnly()
&& !filterActionPanel.isShowLivestreamsOnly()
&& !filterActionPanel.isShowNewOnly()
&& !filterActionPanel.isShowBookMarkedOnly()
&& !filterActionPanel.isDontShowTrailers()
&& !filterActionPanel.isDontShowSignLanguage()
&& !filterActionPanel.isDontShowAudioVersions();
}


private void performTableFiltering() {
arrIrgendwo = searchFieldData.evaluateThemaTitel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import mediathek.controller.history.SeenHistoryController;
import mediathek.daten.DatenFilm;
import mediathek.gui.tabs.tab_film.SearchFieldData;
import mediathek.javafx.filterpanel.FilmLengthSlider;
import mediathek.javafx.filterpanel.FilterActionPanel;
import mediathek.javafx.filterpanel.ZeitraumSpinner;

import javax.swing.table.TableModel;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -34,7 +36,26 @@ protected boolean minLengthCheck(DatenFilm film) {
return filmLength >= sliderRange.minLengthInSeconds();
}

protected abstract boolean noFiltersAreSet();
protected boolean noFiltersAreSet() {
var filmLengthSlider = filterActionPanel.getFilmLengthSlider();

return filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().isEmpty()
&& getFilterThema().isEmpty()
&& searchFieldData.isEmpty()
&& ((int) filmLengthSlider.getLowValue() == 0)
&& ((int) filmLengthSlider.getHighValue() == FilmLengthSlider.UNLIMITED_VALUE)
&& !filterActionPanel.isDontShowAbos()
&& !filterActionPanel.isShowUnseenOnly()
&& !filterActionPanel.isShowOnlyHighQuality()
&& !filterActionPanel.isShowSubtitlesOnly()
&& !filterActionPanel.isShowLivestreamsOnly()
&& !filterActionPanel.isShowNewOnly()
&& !filterActionPanel.isShowBookMarkedOnly()
&& !filterActionPanel.isDontShowTrailers()
&& !filterActionPanel.isDontShowSignLanguage()
&& !filterActionPanel.isDontShowAudioVersions()
&& filterActionPanel.zeitraumProperty().get().equalsIgnoreCase(ZeitraumSpinner.UNLIMITED_VALUE);
}

protected boolean seenCheck(DatenFilm film) {
return !historyController.hasBeenSeenFromCache(film);
Expand All @@ -47,4 +68,10 @@ protected void calculateFilmLengthSliderValues() {
var maxLengthInSeconds = TimeUnit.SECONDS.convert(maxLength, TimeUnit.MINUTES);
sliderRange = new SliderRange(minLengthInSeconds, maxLengthInSeconds);
}

protected String getFilterThema() {
String filterThema = filterActionPanel.getViewSettingsPane().themaComboBox.getSelectionModel().getSelectedItem();

return filterThema == null ? "" : filterThema;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,6 @@ public LuceneGuiFilmeModelHelper(@NotNull FilterActionPanel filterActionPanel,
this.searchFieldData = searchFieldData;
}

private String getFilterThema() {
String filterThema = filterActionPanel.getViewSettingsPane().themaComboBox.getSelectionModel().getSelectedItem();
if (filterThema == null) {
filterThema = "";
}

return filterThema;
}

@Override
protected boolean noFiltersAreSet() {
var filmLengthSlider = filterActionPanel.getFilmLengthSlider();

return filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().isEmpty()
&& getFilterThema().isEmpty()
&& searchFieldData.isEmpty()
&& ((int) filmLengthSlider.getLowValue() == 0)
&& ((int) filmLengthSlider.getHighValue() == FilmLengthSlider.UNLIMITED_VALUE)
&& !filterActionPanel.isDontShowAbos()
&& !filterActionPanel.isShowUnseenOnly()
&& !filterActionPanel.isShowOnlyHighQuality()
&& !filterActionPanel.isShowSubtitlesOnly()
&& !filterActionPanel.isShowLivestreamsOnly()
&& !filterActionPanel.isShowNewOnly()
&& !filterActionPanel.isShowBookMarkedOnly()
&& !filterActionPanel.isDontShowTrailers()
&& !filterActionPanel.isDontShowSignLanguage()
&& !filterActionPanel.isDontShowAudioVersions()
&& filterActionPanel.zeitraumProperty().get().equalsIgnoreCase(ZeitraumSpinner.UNLIMITED_VALUE);
}


private TModelFilm performTableFiltering() {
var listeFilme = (IndexedFilmList) Daten.getInstance().getListeFilmeNachBlackList();
try {
Expand Down

0 comments on commit 6bd50cf

Please sign in to comment.