Now remembers the last library display mode that was selected.
This commit is contained in:
parent
35c953f473
commit
f97a302c79
@ -15,6 +15,7 @@ public final class ConfigManager {
|
|||||||
// Config Keys
|
// Config Keys
|
||||||
static final String foldersKey = "libraryFolders";
|
static final String foldersKey = "libraryFolders";
|
||||||
static final String databaseKey = "databaseDir";
|
static final String databaseKey = "databaseDir";
|
||||||
|
static final String libraryDisplayKey = "libraryDisplayKey";
|
||||||
|
|
||||||
public static List<File> getLibraryDirectories(){
|
public static List<File> getLibraryDirectories(){
|
||||||
try(FileInputStream inputStream = new FileInputStream(propertiesFile)){
|
try(FileInputStream inputStream = new FileInputStream(propertiesFile)){
|
||||||
@ -60,4 +61,24 @@ public final class ConfigManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getLastDisplayTypeIndex(){
|
||||||
|
try (FileInputStream inputStream = new FileInputStream(propertiesFile)) {
|
||||||
|
librarySettings.load(inputStream);
|
||||||
|
if (librarySettings.containsKey(libraryDisplayKey)) {
|
||||||
|
return Integer.parseInt(librarySettings.getProperty(libraryDisplayKey));
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLastDisplayTypeIndex(Integer index){
|
||||||
|
librarySettings.setProperty(libraryDisplayKey, index.toString());
|
||||||
|
try(FileWriter fileWriter = new FileWriter(settingsFilename)){
|
||||||
|
librarySettings.store(fileWriter, "");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,12 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
private static DefaultMutableTreeNode updatingNode = new DefaultMutableTreeNode();
|
private static DefaultMutableTreeNode updatingNode = new DefaultMutableTreeNode();
|
||||||
private boolean libraryUpdating = false;
|
private boolean libraryUpdating = false;
|
||||||
|
|
||||||
private Map<String, Runnable> libraryDisplayVariants;
|
private Map<String, Runnable> libraryDisplayVariants = createDisplayVariantMap();
|
||||||
|
|
||||||
public PlayerGUI() {
|
public PlayerGUI() {
|
||||||
createUI();
|
createUI();
|
||||||
DatabaseManager.init();
|
DatabaseManager.init();
|
||||||
resetTree();
|
resetTree();
|
||||||
libraryDisplayVariants = createDisplayVariantMap();
|
|
||||||
libraryDisplayVariants.keySet().forEach(libraryDisplayType::addItem);
|
|
||||||
Thread seekBarUpdater = new Thread(() -> {
|
Thread seekBarUpdater = new Thread(() -> {
|
||||||
boolean running = true;
|
boolean running = true;
|
||||||
while (running) {
|
while (running) {
|
||||||
@ -53,7 +51,6 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
seekBarUpdater.start();
|
seekBarUpdater.start();
|
||||||
createMenuBar();
|
|
||||||
refreshLibrary();
|
refreshLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,9 +253,14 @@ public class PlayerGUI implements PlayerCallbackInterface, LibraryCallbackInterf
|
|||||||
final JPanel libraryAndComboboxPane = new JPanel();
|
final JPanel libraryAndComboboxPane = new JPanel();
|
||||||
libraryAndComboboxPane.setLayout(new BorderLayout(0, 0));
|
libraryAndComboboxPane.setLayout(new BorderLayout(0, 0));
|
||||||
libraryAndPlaylistPane.setLeftComponent(libraryAndComboboxPane);
|
libraryAndPlaylistPane.setLeftComponent(libraryAndComboboxPane);
|
||||||
|
libraryDisplayVariants.keySet().forEach(libraryDisplayType::addItem);
|
||||||
|
libraryDisplayType.setSelectedIndex(ConfigManager.getLastDisplayTypeIndex());
|
||||||
libraryDisplayType.addItemListener(e -> {
|
libraryDisplayType.addItemListener(e -> {
|
||||||
if (!libraryUpdating && e.getStateChange() == ItemEvent.SELECTED)
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
libraryDisplayVariants.get(libraryDisplayType.getSelectedItem().toString()).run();
|
ConfigManager.setLastDisplayTypeIndex(libraryDisplayType.getSelectedIndex());
|
||||||
|
if(!libraryUpdating)
|
||||||
|
libraryDisplayVariants.get(libraryDisplayType.getSelectedItem().toString()).run();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
libraryAndComboboxPane.add(libraryDisplayType, BorderLayout.NORTH);
|
libraryAndComboboxPane.add(libraryDisplayType, BorderLayout.NORTH);
|
||||||
final JScrollPane libraryPane = new JScrollPane();
|
final JScrollPane libraryPane = new JScrollPane();
|
||||||
|
Loading…
Reference in New Issue
Block a user