| | |
| | | import com.google.gson.Gson; |
| | | import com.sun.net.httpserver.Headers; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import de.uhilger.tango.PlaylistListener; |
| | | import de.uhilger.tango.Server; |
| | | import de.uhilger.tango.entity.Abspielliste; |
| | | import de.uhilger.tango.entity.Entity; |
| | | import de.uhilger.tango.entity.Titel; |
| | | import de.uhilger.tango.store.FileStorage; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.logging.Logger; |
| | | |
| | |
| | | |
| | | private String conf; |
| | | |
| | | private List<PlaylistListener> listeners; |
| | | |
| | | public ListHandler(String conf) { |
| | | this.conf = conf; |
| | | listeners = new ArrayList(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(titelStr.equalsIgnoreCase(ALLE_TITEL)) { |
| | | liste.getTitel().clear(); |
| | | } else { |
| | | liste.getTitel().remove(Integer.parseInt(elems[elems.length-1])); |
| | | int idx = Integer.parseInt(elems[elems.length-1]); |
| | | liste.getTitel().remove(idx); |
| | | sendRemovalInfo(liste.getName(), idx); |
| | | } |
| | | fs.write(liste, true); |
| | | return true; |
| | |
| | | } |
| | | } |
| | | |
| | | private void sendRemovalInfo(String listName, int titleIndex) { |
| | | Iterator<PlaylistListener> i = listeners.iterator(); |
| | | while(i.hasNext()) { |
| | | PlaylistListener l = i.next(); |
| | | l.titleRemoved(listName, titleIndex); |
| | | } |
| | | } |
| | | |
| | | public void addPlaylistListener(PlaylistListener listener) { |
| | | this.listeners.add(listener); |
| | | } |
| | | |
| | | public void removePlaylistListener(PlaylistListener listener) { |
| | | this.listeners.remove(listener); |
| | | } |
| | | } |