removed tracklist, focused album object
This commit is contained in:
parent
65884aa7e0
commit
dcf07fa2f7
@ -5,6 +5,7 @@ import java.awt.GridLayout;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@ -13,11 +14,14 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.music.FMObj;
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
|
|
||||||
public class AlbumView extends JFrame {
|
public class AlbumView extends JFrame {
|
||||||
JPanel buttons = new JPanel();
|
JPanel buttons = new JPanel();
|
||||||
JPanel buttons2 = new JPanel();
|
JPanel buttons2 = new JPanel();
|
||||||
|
JPanel trackListPanel = new JPanel();
|
||||||
|
|
||||||
JLabel name = new JLabel();
|
JLabel name = new JLabel();
|
||||||
JLabel artist = new JLabel();
|
JLabel artist = new JLabel();
|
||||||
@ -33,13 +37,15 @@ public class AlbumView extends JFrame {
|
|||||||
public AlbumView(Album album) {
|
public AlbumView(Album album) {
|
||||||
super(album.getName());
|
super(album.getName());
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setLayout(new GridLayout(7,0));
|
setLayout(new GridLayout(8, 1));
|
||||||
setSize(300, 300);
|
setSize(300, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
|
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
buttons2.setLayout(new FlowLayout());
|
buttons2.setLayout(new FlowLayout());
|
||||||
|
// System.out.println(album.getName());
|
||||||
|
// if (album.getTrackList() != null)
|
||||||
|
// buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1));
|
||||||
|
|
||||||
buttons.add(open);
|
buttons.add(open);
|
||||||
buttons.add(viewArtist);
|
buttons.add(viewArtist);
|
||||||
@ -56,7 +62,6 @@ public class AlbumView extends JFrame {
|
|||||||
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
||||||
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + " Your Scrobbles");
|
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + " Your Scrobbles");
|
||||||
|
|
||||||
|
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(album.getUrl());
|
Network.openURL(album.getUrl());
|
||||||
@ -69,21 +74,64 @@ public class AlbumView extends JFrame {
|
|||||||
});
|
});
|
||||||
musicBrainz.addActionListener(new ActionListener() {
|
musicBrainz.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(album.getMusicBrainzURL());;
|
Network.openURL(album.getMusicBrainzURL());
|
||||||
|
;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
rym.addActionListener(new ActionListener() {
|
rym.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(album.getRymURL());;
|
Network.openURL(album.getRymURL());
|
||||||
|
;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// if (album.getTrackList() != null) {
|
||||||
|
// int counter;
|
||||||
|
// ArrayList<Track> trackList = album.getTrackList();
|
||||||
|
// for (counter = 0; counter < trackList.size(); counter++) {
|
||||||
|
// Track track = trackList.get(counter);
|
||||||
|
// JLabel name = new JLabel(track.getName());
|
||||||
|
//
|
||||||
|
// int playCountString = track.getUserPlayCount();
|
||||||
|
//
|
||||||
|
// JLabel userPlays;
|
||||||
|
// if (playCountString == 0)
|
||||||
|
// userPlays = new JLabel("0");
|
||||||
|
// else
|
||||||
|
// userPlays = new JLabel(Integer.toString(track.getUserPlayCount()));
|
||||||
|
//
|
||||||
|
// JLabel plays = new JLabel(numberFormat.format(track.getPlayCount()));
|
||||||
|
// JButton openExternal = new JButton("Open Online");
|
||||||
|
// openExternal.addActionListener(new ActionListener() {
|
||||||
|
// public void actionPerformed(ActionEvent arg0) {
|
||||||
|
// Network.openURL(track.getUrl());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// JButton openInternal = new JButton("Open " + track.getClass().getSimpleName());
|
||||||
|
// openInternal.addActionListener(new ActionListener() {
|
||||||
|
// public void actionPerformed(ActionEvent arg0) {
|
||||||
|
// track.view();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// JPanel panel = new JPanel();
|
||||||
|
// panel.setLayout(new GridLayout(1, 5));
|
||||||
|
// panel.add(name);
|
||||||
|
// panel.add(userPlays);
|
||||||
|
// panel.add(plays);
|
||||||
|
// panel.add(openInternal);
|
||||||
|
// panel.add(openExternal);
|
||||||
|
//
|
||||||
|
// trackListPanel.add(panel);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
add(name);
|
add(name);
|
||||||
add(artist);
|
add(artist);
|
||||||
add(listeners);
|
add(listeners);
|
||||||
add(playCount);
|
add(playCount);
|
||||||
add(userPlayCount);
|
add(userPlayCount);
|
||||||
|
|
||||||
|
add(trackListPanel);
|
||||||
add(buttons);
|
add(buttons);
|
||||||
add(buttons2);
|
add(buttons2);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class TrackView extends JFrame {
|
|||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setLayout(new GridLayout(8, 1));
|
setLayout(new GridLayout(8, 1));
|
||||||
// setSize(300, 300);
|
// setSize(300, 300);
|
||||||
setResizable(false);
|
// setResizable(false);
|
||||||
|
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
buttons2.setLayout(new FlowLayout());
|
buttons2.setLayout(new FlowLayout());
|
||||||
|
@ -12,7 +12,7 @@ import sarsoo.fmframework.util.Reference;
|
|||||||
public class Album extends FMObj{
|
public class Album extends FMObj{
|
||||||
protected Artist artist;
|
protected Artist artist;
|
||||||
protected ArrayList<Tag> tagList;
|
protected ArrayList<Tag> tagList;
|
||||||
protected ArrayList<Track> trackList;
|
// protected ArrayList<Track> trackList;
|
||||||
|
|
||||||
public Album(String name, String artist) {
|
public Album(String name, String artist) {
|
||||||
super(name, null, null, 0, 0, 0, null);
|
super(name, null, null, 0, 0, 0, null);
|
||||||
@ -35,14 +35,18 @@ public class Album extends FMObj{
|
|||||||
return album;
|
return album;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Track getTrack(int track) {
|
// public Track getTrack(int track) {
|
||||||
return trackList.get(track);
|
// return trackList.get(track);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public ArrayList<Track> getTrackList(){
|
// public ArrayList<Track> getTrackList(){
|
||||||
return trackList;
|
// return trackList;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// public void addTrack(Track track) {
|
||||||
|
// trackList.add(track);
|
||||||
|
// }
|
||||||
|
//
|
||||||
public ArrayList<Tag> getTags(){
|
public ArrayList<Tag> getTags(){
|
||||||
return tagList;
|
return tagList;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import javax.xml.transform.dom.DOMSource;
|
|||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
@ -26,6 +27,8 @@ public class Parser {
|
|||||||
|
|
||||||
public static Album parseAlbum(Document doc) {
|
public static Album parseAlbum(Document doc) {
|
||||||
// try {
|
// try {
|
||||||
|
// System.out.println(doc.getDocumentElement());
|
||||||
|
if (doc.getDocumentElement().getAttribute("status").equals("ok")) {
|
||||||
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
||||||
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
|
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
|
||||||
String mbid = null;
|
String mbid = null;
|
||||||
@ -58,7 +61,46 @@ public class Parser {
|
|||||||
userPlayCount = Integer.parseInt(userPlayCountNodeList.item(0).getTextContent());
|
userPlayCount = Integer.parseInt(userPlayCountNodeList.item(0).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Node trackListNode = doc.getElementsByTagName("tracks").item(0);
|
Artist artistObj = Artist.getArtist(artist, Reference.getUserName());
|
||||||
|
Wiki wiki = new Wiki();
|
||||||
|
|
||||||
|
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
||||||
|
|
||||||
|
// NodeList trackListNode = doc.getElementsByTagName("tracks");
|
||||||
|
//
|
||||||
|
// NodeList child1 = doc.getElementsByTagName("tracks");
|
||||||
|
// Node sibling = trackListNode.item(0).getFirstChild();
|
||||||
|
// int counter;
|
||||||
|
// // for(counter = 0; counter < 2; counter++) {
|
||||||
|
// while (sibling != trackListNode.item(0).getLastChild()) {
|
||||||
|
// while (!(sibling instanceof Element) && sibling != null) {
|
||||||
|
// sibling = sibling.getNextSibling();
|
||||||
|
// }
|
||||||
|
// // NamedNodeMap attributes = sibling.getAttributes();
|
||||||
|
//
|
||||||
|
// // int trackNumber =
|
||||||
|
// // Integer.parseInt(attributes.getNamedItem("rank").getNodeValue());
|
||||||
|
// NodeList trackNodeList = sibling.getChildNodes();
|
||||||
|
// String trackName = trackNodeList.item(0).getTextContent();
|
||||||
|
// String artistName = trackNodeList.item(8).getFirstChild().getTextContent();
|
||||||
|
//
|
||||||
|
// Track track = Track.getTrack(trackName, artistName, Reference.getUserName());
|
||||||
|
// track.setAlbum(album);
|
||||||
|
// System.out.println(track.getName());
|
||||||
|
//
|
||||||
|
// album.addTrack(track);
|
||||||
|
//
|
||||||
|
// sibling = sibling.getNextSibling();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// while (!(sibling instanceof Element) && sibling != null) {
|
||||||
|
// sibling = sibling.getNextSibling();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// NodeList list = sibling.getChildNodes();
|
||||||
|
// list.item(0);
|
||||||
|
// System.out.println(list.item(0));
|
||||||
|
// System.out.println(trackListNode.item(0).getTextContent());
|
||||||
// NodeList trackNodeList = trackListNode.getChildNodes();
|
// NodeList trackNodeList = trackListNode.getChildNodes();
|
||||||
// if (trackListNode != null) {
|
// if (trackListNode != null) {
|
||||||
// int counter = 0;
|
// int counter = 0;
|
||||||
@ -69,7 +111,8 @@ public class Parser {
|
|||||||
// String trackUrl =
|
// String trackUrl =
|
||||||
// track.getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
// track.getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
||||||
// // String trackDuration =
|
// // String trackDuration =
|
||||||
// track.getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getTextContent();
|
// track.getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling()
|
||||||
|
// .getTextContent();
|
||||||
// int trackNumber =
|
// int trackNumber =
|
||||||
// Integer.parseInt(track.getAttributes().getNamedItem("rank").getNodeValue());
|
// Integer.parseInt(track.getAttributes().getNamedItem("rank").getNodeValue());
|
||||||
// // String trackName =
|
// // String trackName =
|
||||||
@ -90,15 +133,13 @@ public class Parser {
|
|||||||
// System.out.println(summary);
|
// System.out.println(summary);
|
||||||
// System.out.println(content);
|
// System.out.println(content);
|
||||||
|
|
||||||
Artist artistObj = Artist.getArtist(artist, Reference.getUserName());
|
|
||||||
Wiki wiki = new Wiki();
|
|
||||||
|
|
||||||
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
|
||||||
return album;
|
return album;
|
||||||
// } catch (NullPointerException e) {
|
// } catch (NullPointerException e) {
|
||||||
// System.err.println("Could Not Parse Album");
|
// System.err.println("Could Not Parse Album");
|
||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,13 +263,13 @@ public class Parser {
|
|||||||
String artistName = doc.getElementsByTagName("artist").item(0).getTextContent();
|
String artistName = doc.getElementsByTagName("artist").item(0).getTextContent();
|
||||||
|
|
||||||
String albumName = doc.getElementsByTagName("album").item(0).getTextContent();
|
String albumName = doc.getElementsByTagName("album").item(0).getTextContent();
|
||||||
|
System.out.println(albumName);
|
||||||
Track track = Track.getTrack(name, artistName, Reference.getUserName());
|
Track track = Track.getTrack(name, artistName, Reference.getUserName());
|
||||||
|
|
||||||
// Album album = Album.getAlbum(albumName, artistName, Reference.getUserName());
|
Album album = Album.getAlbum(albumName, artistName, Reference.getUserName());
|
||||||
|
|
||||||
// if (album.getName() != null)
|
// if (album.getName() != null)
|
||||||
// track.setAlbum(album);
|
track.setAlbum(album);
|
||||||
|
|
||||||
return track;
|
return track;
|
||||||
// } catch (NullPointerException e) {
|
// } catch (NullPointerException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user