I have two ObservableList which one of them contains some song and other one has the directory that related to songs.
I want when remove a directory from its ObservableList, all of the songs those contain that directory be removed from their ObservableList. but when I do that, just songs with odd id removed and ones with even id remained !!!
my ObservableLists are in a different class and "controller" is the object of the class that contains the ObservableLists. here is my code :
private static ObservableList<SongModel> songModelObservableList = FXCollections.observableArrayList();
private static ObservableList<Directory_Model> directoryModelObservableList = FXCollections.observableArrayList();
and now my code that remove directory :
for (int j = 0 ; j < controller.getSongModelObservableList().size() ; j++)
if (controller.getSongModelObservableList().get(j).getPath().contains(controller.getDirectoryModelObservableList().get(i).getPath())){
controller.getSongModelObservableList().remove(controller.getSongModelObservableList().get(j));
}
controller.getDirectoryModelObservableList().remove(controller.getDirectoryModelObservableList().get(i));
here. in the first if, I check which songModel(my class for songs) has the directory's path to remove it from songObservableList.
have any idea to fix that? I want to remove all of directory's songs not ones with odd id.