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.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -35,21 +37,44 @@ public class FMObjListView extends JFrame {
|
||||
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
Font font = new Font("Arial", Font.PLAIN, 20);
|
||||
Font header = new Font("Arial", Font.BOLD, 16);
|
||||
|
||||
JPanel headerLabels = new JPanel();
|
||||
headerLabels.setLayout(new GridLayout(1, 5));
|
||||
headerLabels.add(new JLabel("Name"));
|
||||
headerLabels.add(new JLabel("User Scrobbles"));
|
||||
headerLabels.add(new JLabel("Total Scrobbles"));
|
||||
headerLabels.add(new JLabel(""));
|
||||
// headerLabels.setFont(header);
|
||||
headerLabels.setLayout(new GridLayout(1, 4));
|
||||
|
||||
|
||||
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(""));
|
||||
|
||||
add(headerLabels);
|
||||
|
||||
int counter;
|
||||
for (counter = 0; counter < objects.size(); 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();
|
||||
|
||||
@ -58,26 +83,29 @@ public class FMObjListView extends JFrame {
|
||||
userPlays = new JLabel("0");
|
||||
else
|
||||
userPlays = new JLabel(Integer.toString(fmObj.getUserPlayCount()));
|
||||
userPlays.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
JLabel plays = new JLabel(numberFormat.format(fmObj.getPlayCount()));
|
||||
plays.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
JButton openExternal = new JButton("Open Online");
|
||||
openExternal.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Network.openURL(fmObj.getUrl());
|
||||
}
|
||||
});
|
||||
JButton openInternal = new JButton("Open " + fmObj.getClass().getSimpleName());
|
||||
openInternal.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
fmObj.view();
|
||||
}
|
||||
});
|
||||
// JButton openInternal = new JButton("Open " + fmObj.getClass().getSimpleName());
|
||||
// openInternal.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent arg0) {
|
||||
// fmObj.view();
|
||||
// }
|
||||
// });
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new GridLayout(1, 5));
|
||||
panel.add(name);
|
||||
panel.setLayout(new GridLayout(1, 4));
|
||||
panel.add(artistName);
|
||||
panel.add(userPlays);
|
||||
panel.add(plays);
|
||||
panel.add(openInternal);
|
||||
// panel.add(openInternal);
|
||||
panel.add(openExternal);
|
||||
|
||||
add(panel);
|
||||
|
@ -34,7 +34,7 @@ public class RefListsView extends JFrame {
|
||||
// add(view);
|
||||
// }
|
||||
|
||||
JButton viewTDE = new JButton("View TDE");
|
||||
JButton viewTDE = new JButton("TDE");
|
||||
viewTDE.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getTDE().view();
|
||||
@ -42,7 +42,7 @@ public class RefListsView extends JFrame {
|
||||
});
|
||||
add(viewTDE);
|
||||
|
||||
JButton viewBPHQ = new JButton("View BPHQ");
|
||||
JButton viewBPHQ = new JButton("BPHQ");
|
||||
viewBPHQ.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getBPHQ().view();
|
||||
@ -50,33 +50,41 @@ public class RefListsView extends JFrame {
|
||||
});
|
||||
add(viewBPHQ);
|
||||
|
||||
JButton viewDre = new JButton("View Dre");
|
||||
JButton viewDre = new JButton("Dre");
|
||||
viewDre.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getDre().view();
|
||||
}
|
||||
});
|
||||
add(viewDre);
|
||||
JButton viewWu = new JButton("View Wu");
|
||||
JButton viewWu = new JButton("Wu");
|
||||
viewWu.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getWu().view();
|
||||
}
|
||||
});
|
||||
add(viewWu);
|
||||
JButton viewHopeless = new JButton("View Hopeless");
|
||||
JButton viewHopeless = new JButton("Hopeless");
|
||||
viewHopeless.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getHopeless().view();
|
||||
}
|
||||
});
|
||||
add(viewHopeless);
|
||||
JButton viewSaturation = new JButton("View Saturation");
|
||||
JButton viewSaturation = new JButton("Saturation");
|
||||
viewSaturation.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getSaturation().view();
|
||||
}
|
||||
});
|
||||
add(viewSaturation);
|
||||
|
||||
JButton viewEmoTrio = new JButton("Emo Trio");
|
||||
viewEmoTrio.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Reference.getEmoTrio().view();
|
||||
}
|
||||
});
|
||||
add(viewEmoTrio);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class TrackView extends JFrame {
|
||||
playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles");
|
||||
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
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.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() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
@ -24,7 +24,7 @@ public class Network {
|
||||
URL url = new URL(urlString);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept", "text/xml");
|
||||
conn.setRequestProperty("Accept", "application/xml");
|
||||
conn.setRequestProperty("User-Agent", "fmframework/1.0");
|
||||
|
||||
if (conn.getResponseCode() != 200) {
|
||||
|
@ -123,4 +123,14 @@ public class Reference {
|
||||
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