Skip to content

Commit

Permalink
clean isChildrenSorted and isSortable
Browse files Browse the repository at this point in the history
  • Loading branch information
SurfaceS committed Jul 16, 2024
1 parent 782df88 commit 9102a62
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private static JsonObject getBrowsePage(WebGuiRenderer renderer, String id, Stri
resources.get(0).getParent() != null &&
resources.get(0).getParent().isFolder()) {
StoreContainer thisResourceFromResources = resources.get(0).getParent();
if (thisResourceFromResources.isSorted()) {
if (thisResourceFromResources.isChildrenSorted()) {
StoreResourceSorter.sortResourcesByDefault(resources, lang);
}

Expand Down
20 changes: 16 additions & 4 deletions src/main/java/net/pms/store/StoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class StoreContainer extends StoreResource {

protected String name;
protected String thumbnailIcon;
protected boolean isSorted = false;
private boolean isChildrenSorted = false;

private boolean allChildrenAreContainers = true;
private boolean discovered = false;
Expand Down Expand Up @@ -467,7 +467,7 @@ private void addGlobalRepo(StoreResource resource) {
}

protected void sortChildrenIfNeeded() {
if (isSorted) {
if (isChildrenSorted()) {
StoreResourceSorter.sortResourcesByDefault(children);
}
}
Expand Down Expand Up @@ -518,6 +518,14 @@ public String getName() {
return name;
}

/**
* @param name the name to set
* @since 1.50
*/
protected void setName(String name) {
this.name = name;
}

/**
* Returns true in this case, as this is a folder.
*
Expand Down Expand Up @@ -816,8 +824,12 @@ public void setDiscovered(boolean discovered) {
this.discovered = discovered;
}

public boolean isSorted() {
return isSorted;
protected void setChildrenSorted(boolean isChildrenSorted) {
this.isChildrenSorted = isChildrenSorted;
}

public boolean isChildrenSorted() {
return isChildrenSorted;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pms/store/StoreItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected StoreItem(Renderer renderer) {
protected StoreItem(Renderer renderer, int specificType) {
super(renderer);
setSpecificType(specificType);
this.isSortable = true;
setSortable(true);
}

@Override
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/net/pms/store/container/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void parse() throws Exception {
byte[] b = HTTPResource.downloadAndSendBinary(url);
if (b != null) {
SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(b)));
name = feed.getTitle();
setName(feed.getTitle());
if (feed.getCategories() != null && !feed.getCategories().isEmpty()) {
SyndCategory category = feed.getCategories().get(0);
tempCategory = category.getName();
Expand Down Expand Up @@ -209,14 +209,6 @@ protected void setTempItemThumbURL(String tempItemThumbURL) {
this.tempItemThumbURL = tempItemThumbURL;
}

/**
* @param name the name to set
* @since 1.50
*/
protected void setName(String name) {
this.name = name;
}

@Override
protected void resolveOnce() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public LocalizedStoreContainer(Renderer renderer, String i18nName, String thumbn
this.formatStrings = null;
}
if (i18nName != null) {
this.name = String.format(Messages.getString(i18nName), (Object[]) this.formatStrings);
setName(String.format(Messages.getString(i18nName), (Object[]) this.formatStrings));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public MediaLibraryFolder(Renderer renderer, String i18nName, String[] sql, int[
super(renderer, i18nName, null, formatString);
this.sqls = sql;
this.expectedOutputs = expectedOutput;
isSorted = (expectedOutput == null || expectedOutput.length < 1 || isSortableOutputExpected(expectedOutput[0]));
setChildrenSorted((expectedOutput == null || expectedOutput.length < 1 || isSortableOutputExpected(expectedOutput[0])));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MediaLibraryFolderNamed extends MediaLibraryFolder {

public MediaLibraryFolderNamed(Renderer renderer, String virtualFolderName, String[] sql, int[] expectedOutput, String formatString) {
super(renderer, null, sql, expectedOutput, null);
this.name = virtualFolderName;
setName(virtualFolderName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public class MediaLibraryMovieFolder extends MediaLibraryFolder {

public MediaLibraryMovieFolder(Renderer renderer, String name, String filename, String[] sql, int[] expectedOutput) {
super(renderer, null, sql, expectedOutput);
this.name = name;
setName(name);
this.filename = filename;
}

@Override
public String getSystemName() {
return "movie_" + this.name;
return "movie_" + getName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class MediaLibraryTvSeries extends MediaLibraryFolder {

public MediaLibraryTvSeries(Renderer renderer, Long tvSeriesId, String[] sql, int[] expectedOutput) {
super(renderer, null, sql, expectedOutput);
this.name = tvSeriesId.toString();
setName(tvSeriesId.toString());
this.tvSeriesId = tvSeriesId;
this.isSortable = true;
setSortable(true);
}

@Override
public String getSystemName() {
return "tv_series_" + this.name;
return "tv_series_" + getName();
}

/**
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/net/pms/store/container/RealFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public RealFolder(Renderer renderer, File directory) {
public RealFolder(Renderer renderer, File directory, String name) {
super(renderer);
this.directory = directory;
this.name = name;
setName(name);
addFile(directory);
setLastModified(directory.lastModified());
setSortable(true);
}

@Override
Expand Down Expand Up @@ -96,25 +97,25 @@ public String write() {

@Override
public String getName() {
if (name == null) {
if (super.getName() == null) {
if (directory == null) {
return null;
}

if (directory.getName().trim().isEmpty()) {
if (Platform.isWindows()) {
name = PlatformUtils.INSTANCE.getDiskLabel(directory);
setName(PlatformUtils.INSTANCE.getDiskLabel(directory));
}
if (name != null && name.length() > 0) {
name = directory.getAbsolutePath().substring(0, 1) + ":\\ [" + name + "]";
if (super.getName() != null && super.getName().length() > 0) {
setName(directory.getAbsolutePath().substring(0, 1) + ":\\ [" + super.getName() + "]");
} else {
name = directory.getAbsolutePath().substring(0, 1);
setName(directory.getAbsolutePath().substring(0, 1));
}
} else {
name = directory.getName();
setName(directory.getName());
}
}
return name.replaceAll("_imdb([^_]+)_", "");
return super.getName().replaceAll("_imdb([^_]+)_", "");
}

@Override
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/net/pms/store/container/SearchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SearchAction(Renderer renderer, Search sobj, char ch, String name) {
super(renderer, name, "images/Play1Hot_120.jpg");
this.sobj = sobj;
this.ch = ch;
this.name = name;
setName(name);
}

@Override
Expand All @@ -53,11 +53,6 @@ public void discoverChildren() {
setDiscovered(false);
}

@Override
public String getName() {
return name;
}

@Override
public long length() {
return -1; //DLNAMediaInfo.TRANS_SIZE;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/pms/store/container/VirtualFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class VirtualFolder extends StoreContainer {

public VirtualFolder(Renderer renderer) {
super(renderer, null, null);
isSorted = true;
setChildrenSorted(true);
this.files = new ArrayList<>();
this.virtualFolders = new ArrayList<>();
this.forcedName = null;
Expand All @@ -64,7 +64,7 @@ public VirtualFolder(Renderer renderer) {

public VirtualFolder(Renderer renderer, VirtualFolderContent virtualFolder) {
super(renderer, virtualFolder.getName(), null);
isSorted = true;
setChildrenSorted(true);
this.addToMediaLibrary = virtualFolder.isAddToMediaLibrary();
this.files = virtualFolder.getFiles();
this.virtualFolders = virtualFolder.getVirtualFolders();
Expand All @@ -74,7 +74,7 @@ public VirtualFolder(Renderer renderer, VirtualFolderContent virtualFolder) {

public VirtualFolder(Renderer renderer, VirtualFolder virtualFile, List<File> files, String forcedName) {
super(renderer, null, null);
isSorted = true;
setChildrenSorted(true);
this.addToMediaLibrary = virtualFile.isAddToMediaLibrary();
this.files = virtualFile.getFiles();
this.virtualFolders = new ArrayList<>();
Expand Down Expand Up @@ -382,7 +382,7 @@ public boolean isAddToMediaLibrary() {
@Override
public String getName() {
if (StringUtils.isEmpty(forcedName)) {
return name;
return super.getName();
}
return forcedName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void doRefreshChildren() {
while (resultSet.next()) {
// Find "best track" logic should be
// optimized !!
name = resultSet.getString(MediaTableAudioMetadata.TABLE_COL_ALBUM);
setName(resultSet.getString(MediaTableAudioMetadata.TABLE_COL_ALBUM));
String currentUuidTrack = resultSet.getString("MBID_TRACK");
if (!currentUuidTrack.equals(lastUuidTrack)) {
lastUuidTrack = currentUuidTrack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class VirtualFolderDbIdNamed extends VirtualFolderDbId {

public VirtualFolderDbIdNamed(Renderer renderer, String folderName, DbIdTypeAndIdent typeIdent) {
super(renderer, null, typeIdent);
this.name = folderName;
setName(folderName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MediaLibraryTvEpisode extends RealFile {
public MediaLibraryTvEpisode(Renderer renderer, File file, boolean isWithinSeasonFolder) {
super(renderer, file);
isEpisodeWithinSeasonFolder = isWithinSeasonFolder;
this.isSortable = false;
setSortable(false);
}

@Override
Expand Down

0 comments on commit 9102a62

Please sign in to comment.