Removed code duplication.
This commit is contained in:
parent
322896bc31
commit
8f68b2f61a
@ -26,7 +26,7 @@ public class LibraryListModel extends AbstractListModel {
|
|||||||
public void addFolder(File folder){
|
public void addFolder(File folder){
|
||||||
if(folder.exists() && folder.isDirectory()) {
|
if(folder.exists() && folder.isDirectory()) {
|
||||||
libraryFolders.add(folder);
|
libraryFolders.add(folder);
|
||||||
fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1);
|
fireAllContentsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class LibraryListModel extends AbstractListModel {
|
|||||||
libraryFolders = new ArrayList<>(folderList);
|
libraryFolders = new ArrayList<>(folderList);
|
||||||
else
|
else
|
||||||
libraryFolders = new ArrayList<>();
|
libraryFolders = new ArrayList<>();
|
||||||
fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1);
|
fireAllContentsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,6 +64,13 @@ public class LibraryListModel extends AbstractListModel {
|
|||||||
*/
|
*/
|
||||||
public void removeFile(File file){
|
public void removeFile(File file){
|
||||||
libraryFolders.remove(file);
|
libraryFolders.remove(file);
|
||||||
|
fireAllContentsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fire that libraryFolders contents has changed.
|
||||||
|
*/
|
||||||
|
private void fireAllContentsChanged(){
|
||||||
fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1);
|
fireContentsChanged(this, 0, libraryFolders.size() == 0 ? 0 : libraryFolders.size() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user