changed list view layout, fixed? bad requests changed request property
This commit is contained in:
parent
d6c68d014d
commit
b0ea458555
@ -4,6 +4,8 @@ import java.awt.Font;
|
|||||||
import java.awt.GridLayout;
|
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.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -35,21 +37,44 @@ public class FMObjListView extends JFrame {
|
|||||||
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
Font font = new Font("Arial", Font.PLAIN, 20);
|
Font font = new Font("Arial", Font.PLAIN, 20);
|
||||||
|
Font header = new Font("Arial", Font.BOLD, 16);
|
||||||
|
|
||||||
JPanel headerLabels = new JPanel();
|
JPanel headerLabels = new JPanel();
|
||||||
headerLabels.setLayout(new GridLayout(1, 5));
|
// headerLabels.setFont(header);
|
||||||
headerLabels.add(new JLabel("Name"));
|
headerLabels.setLayout(new GridLayout(1, 4));
|
||||||
headerLabels.add(new JLabel("User Scrobbles"));
|
|
||||||
headerLabels.add(new JLabel("Total Scrobbles"));
|
|
||||||
headerLabels.add(new JLabel(""));
|
JLabel headerName = new JLabel("name");
|
||||||
|
headerName.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
headerName.setFont(header);
|
||||||
|
|
||||||
|
JLabel headerUser = new JLabel("user");
|
||||||
|
headerUser.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
headerUser.setFont(header);
|
||||||
|
|
||||||
|
JLabel headerTotal = new JLabel("total");
|
||||||
|
headerTotal.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
headerTotal.setFont(header);
|
||||||
|
|
||||||
|
headerLabels.add(headerName);
|
||||||
|
headerLabels.add(headerUser);
|
||||||
|
headerLabels.add(headerTotal);
|
||||||
headerLabels.add(new JLabel(""));
|
headerLabels.add(new JLabel(""));
|
||||||
|
// headerLabels.add(new JLabel(""));
|
||||||
|
|
||||||
add(headerLabels);
|
add(headerLabels);
|
||||||
|
|
||||||
int counter;
|
int counter;
|
||||||
for (counter = 0; counter < objects.size(); counter++) {
|
for (counter = 0; counter < objects.size(); counter++) {
|
||||||
FMObj fmObj = objects.get(counter);
|
FMObj fmObj = objects.get(counter);
|
||||||
JLabel name = new JLabel(fmObj.getName());
|
JLabel artistName = new JLabel(fmObj.getName());
|
||||||
|
artistName.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
artistName.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
fmObj.view();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
int playCountString = fmObj.getUserPlayCount();
|
int playCountString = fmObj.getUserPlayCount();
|
||||||
|
|
||||||
@ -58,26 +83,29 @@ public class FMObjListView extends JFrame {
|
|||||||
userPlays = new JLabel("0");
|
userPlays = new JLabel("0");
|
||||||
else
|
else
|
||||||
userPlays = new JLabel(Integer.toString(fmObj.getUserPlayCount()));
|
userPlays = new JLabel(Integer.toString(fmObj.getUserPlayCount()));
|
||||||
|
userPlays.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
JLabel plays = new JLabel(numberFormat.format(fmObj.getPlayCount()));
|
JLabel plays = new JLabel(numberFormat.format(fmObj.getPlayCount()));
|
||||||
|
plays.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
JButton openExternal = new JButton("Open Online");
|
JButton openExternal = new JButton("Open Online");
|
||||||
openExternal.addActionListener(new ActionListener() {
|
openExternal.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(fmObj.getUrl());
|
Network.openURL(fmObj.getUrl());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JButton openInternal = new JButton("Open " + fmObj.getClass().getSimpleName());
|
// JButton openInternal = new JButton("Open " + fmObj.getClass().getSimpleName());
|
||||||
openInternal.addActionListener(new ActionListener() {
|
// openInternal.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
// public void actionPerformed(ActionEvent arg0) {
|
||||||
fmObj.view();
|
// fmObj.view();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setLayout(new GridLayout(1, 5));
|
panel.setLayout(new GridLayout(1, 4));
|
||||||
panel.add(name);
|
panel.add(artistName);
|
||||||
panel.add(userPlays);
|
panel.add(userPlays);
|
||||||
panel.add(plays);
|
panel.add(plays);
|
||||||
panel.add(openInternal);
|
// panel.add(openInternal);
|
||||||
panel.add(openExternal);
|
panel.add(openExternal);
|
||||||
|
|
||||||
add(panel);
|
add(panel);
|
||||||
|
@ -34,7 +34,7 @@ public class RefListsView extends JFrame {
|
|||||||
// add(view);
|
// add(view);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
JButton viewTDE = new JButton("View TDE");
|
JButton viewTDE = new JButton("TDE");
|
||||||
viewTDE.addActionListener(new ActionListener() {
|
viewTDE.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Reference.getTDE().view();
|
Reference.getTDE().view();
|
||||||
@ -42,7 +42,7 @@ public class RefListsView extends JFrame {
|
|||||||
});
|
});
|
||||||
add(viewTDE);
|
add(viewTDE);
|
||||||
|
|
||||||
JButton viewBPHQ = new JButton("View BPHQ");
|
JButton viewBPHQ = new JButton("BPHQ");
|
||||||
viewBPHQ.addActionListener(new ActionListener() {
|
viewBPHQ.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Reference.getBPHQ().view();
|
Reference.getBPHQ().view();
|
||||||
@ -50,33 +50,41 @@ public class RefListsView extends JFrame {
|
|||||||
});
|
});
|
||||||
add(viewBPHQ);
|
add(viewBPHQ);
|
||||||
|
|
||||||
JButton viewDre = new JButton("View Dre");
|
JButton viewDre = new JButton("Dre");
|
||||||
viewDre.addActionListener(new ActionListener() {
|
viewDre.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Reference.getDre().view();
|
Reference.getDre().view();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(viewDre);
|
add(viewDre);
|
||||||
JButton viewWu = new JButton("View Wu");
|
JButton viewWu = new JButton("Wu");
|
||||||
viewWu.addActionListener(new ActionListener() {
|
viewWu.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Reference.getWu().view();
|
Reference.getWu().view();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(viewWu);
|
add(viewWu);
|
||||||
JButton viewHopeless = new JButton("View Hopeless");
|
JButton viewHopeless = new JButton("Hopeless");
|
||||||
viewHopeless.addActionListener(new ActionListener() {
|
viewHopeless.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Reference.getHopeless().view();
|
Reference.getHopeless().view();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(viewHopeless);
|
add(viewHopeless);
|
||||||
JButton viewSaturation = new JButton("View Saturation");
|
JButton viewSaturation = new JButton("Saturation");
|
||||||
viewSaturation.addActionListener(new ActionListener() {
|
viewSaturation.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Reference.getSaturation().view();
|
Reference.getSaturation().view();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(viewSaturation);
|
add(viewSaturation);
|
||||||
|
|
||||||
|
JButton viewEmoTrio = new JButton("Emo Trio");
|
||||||
|
viewEmoTrio.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
Reference.getEmoTrio().view();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(viewEmoTrio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class TrackView extends JFrame {
|
|||||||
setLayout(new GridLayout(6, 1));
|
setLayout(new GridLayout(6, 1));
|
||||||
}
|
}
|
||||||
// setSize(300, 300);
|
// setSize(300, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
// info.setLayout(new GridLayout(6,1));
|
// info.setLayout(new GridLayout(6,1));
|
||||||
// nameInfo.setLayout(new GridLayout(3,1));
|
// nameInfo.setLayout(new GridLayout(3,1));
|
||||||
@ -100,7 +100,7 @@ public class TrackView extends JFrame {
|
|||||||
playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles");
|
playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles");
|
||||||
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
userPlayCount.setText(numberFormat.format(track.getUserPlayCount())
|
userPlayCount.setText(numberFormat.format(track.getUserPlayCount())
|
||||||
+ String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(track, Reference.getUserName())));
|
+ String.format(" Scrobbles (%.3f%%)", Maths.getPercentListening(track, Reference.getUserName())));
|
||||||
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
userPlayCount.setFont(sub);
|
userPlayCount.setFont(sub);
|
||||||
|
|
||||||
@ -115,6 +115,19 @@ public class TrackView extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (track.getUserPlayCount() > 0) {
|
||||||
|
userPlayCount.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
String namePlus = track.getName().replaceAll(" ", "+");
|
||||||
|
String artistPlus = track.getArtist().getName().replaceAll(" ", "+");
|
||||||
|
String url = String.format("https://www.last.fm/user/%s/library/music/%s/_/%s",
|
||||||
|
Reference.getUserName(), artistPlus, namePlus);
|
||||||
|
Network.openURL(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
artist.addMouseListener(new MouseAdapter() {
|
artist.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
@ -24,7 +24,7 @@ public class Network {
|
|||||||
URL url = new URL(urlString);
|
URL url = new URL(urlString);
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
conn.setRequestMethod("GET");
|
conn.setRequestMethod("GET");
|
||||||
conn.setRequestProperty("Accept", "text/xml");
|
conn.setRequestProperty("Accept", "application/xml");
|
||||||
conn.setRequestProperty("User-Agent", "fmframework/1.0");
|
conn.setRequestProperty("User-Agent", "fmframework/1.0");
|
||||||
|
|
||||||
if (conn.getResponseCode() != 200) {
|
if (conn.getResponseCode() != 200) {
|
||||||
|
@ -123,4 +123,14 @@ public class Reference {
|
|||||||
return wu;
|
return wu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FMObjList getEmoTrio() {
|
||||||
|
FMObjList emoTrio = new FMObjList("Classic Emo Trio");
|
||||||
|
|
||||||
|
emoTrio.add(Artist.getArtist("My Chemical Romance", Reference.getUserName()));
|
||||||
|
emoTrio.add(Artist.getArtist("Fall Out Boy", Reference.getUserName()));
|
||||||
|
emoTrio.add(Artist.getArtist("Panic! at the Disco", Reference.getUserName()));
|
||||||
|
|
||||||
|
return emoTrio;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user