added time play ratio, added wrapping and scrollbar to wiki view
This commit is contained in:
parent
55b4ed625a
commit
d4a7120df2
@ -31,6 +31,7 @@ public class AlbumView extends JFrame {
|
||||
JLabel listeners = new JLabel();
|
||||
JLabel playCount = new JLabel();
|
||||
JLabel userPlayCount = new JLabel();
|
||||
JLabel timePlayRatio = new JLabel();
|
||||
|
||||
JButton open = new JButton("View Online");
|
||||
JButton viewArtist = new JButton("View Artist");
|
||||
@ -41,18 +42,18 @@ public class AlbumView extends JFrame {
|
||||
public AlbumView(Album album) {
|
||||
super(album.getName());
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setLayout(new GridLayout(6, 1));
|
||||
setLayout(new GridLayout(7, 1));
|
||||
setSize(300, 300);
|
||||
setResizable(false);
|
||||
|
||||
buttons.setLayout(new FlowLayout());
|
||||
buttons2.setLayout(new FlowLayout());
|
||||
// System.out.println(album.getName());
|
||||
// if (album.getTrackList() != null)
|
||||
// buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1));
|
||||
// System.out.println(album.getName());
|
||||
// if (album.getTrackList() != null)
|
||||
// buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1));
|
||||
|
||||
buttons.add(open);
|
||||
// buttons2.add(viewArtist);
|
||||
// buttons2.add(viewArtist);
|
||||
|
||||
if (album.getWiki() != null)
|
||||
buttons.add(viewWiki);
|
||||
@ -77,10 +78,25 @@ public class AlbumView extends JFrame {
|
||||
playCount.setText(numberFormat.format(album.getPlayCount()) + " Total Scrobbles");
|
||||
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName())));
|
||||
userPlayCount.setText(numberFormat.format(album.getUserPlayCount())
|
||||
+ String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName())));
|
||||
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
userPlayCount.setFont(sub);
|
||||
|
||||
double ratio = album.getTimeListenRatio();
|
||||
|
||||
// int ratioRound = (int) Math.round(ratio);
|
||||
// int oneOverRatioRound = (int) Math.round(1/ratio);
|
||||
if (ratio > 1) {
|
||||
timePlayRatio.setText(String.format("listen every %.2f days", ratio));
|
||||
} else if (ratio == 1) {
|
||||
timePlayRatio.setText("listen every day");
|
||||
} else {
|
||||
timePlayRatio.setText(String.format("%.2f times a day", 1/ratio));
|
||||
}
|
||||
timePlayRatio.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
timePlayRatio.setFont(sub);
|
||||
|
||||
artist.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@ -88,7 +104,6 @@ public class AlbumView extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
open.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Network.openURL(album.getUrl());
|
||||
@ -117,55 +132,57 @@ public class AlbumView extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// 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(artist);
|
||||
add(userPlayCount);
|
||||
add(timePlayRatio);
|
||||
add(listeners);
|
||||
add(playCount);
|
||||
|
||||
// add(trackListPanel);
|
||||
// add(trackListPanel);
|
||||
add(buttons);
|
||||
// add(buttons2);
|
||||
// add(buttons2);
|
||||
pack();
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import sarsoo.fmframework.music.Album;
|
||||
@ -32,10 +33,19 @@ public class FMObjListView extends JFrame {
|
||||
public FMObjListView(FMObjList objects, String title) {
|
||||
super(title);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setLayout(new GridLayout(objects.size() + 2, 0));
|
||||
setResizable(false);
|
||||
// setLayout(new GridLayout(objects.size() + 2, 0));
|
||||
// setResizable(false);
|
||||
// createMenu();
|
||||
|
||||
int limit = 20;
|
||||
|
||||
if(objects.size() > limit) {
|
||||
setSize(600, 800);
|
||||
}
|
||||
|
||||
JPanel container = new JPanel();
|
||||
container.setLayout(new GridLayout(objects.size() + 2, 0));
|
||||
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
Font font = new Font("Arial", Font.PLAIN, 20);
|
||||
Font header = new Font("Arial", Font.BOLD, 16);
|
||||
@ -63,7 +73,7 @@ public class FMObjListView extends JFrame {
|
||||
headerLabels.add(new JLabel(""));
|
||||
// headerLabels.add(new JLabel(""));
|
||||
|
||||
add(headerLabels);
|
||||
container.add(headerLabels);
|
||||
|
||||
Collections.sort(objects);
|
||||
Collections.reverse(objects);
|
||||
@ -112,7 +122,7 @@ public class FMObjListView extends JFrame {
|
||||
// panel.add(openInternal);
|
||||
panel.add(openExternal);
|
||||
|
||||
add(panel);
|
||||
container.add(panel);
|
||||
}
|
||||
|
||||
JPanel info = new JPanel();
|
||||
@ -133,8 +143,15 @@ public class FMObjListView extends JFrame {
|
||||
|
||||
// }
|
||||
|
||||
add(info);
|
||||
pack();
|
||||
container.add(info);
|
||||
|
||||
JScrollPane scroll = new JScrollPane(container);
|
||||
add(scroll);
|
||||
|
||||
if(objects.size() <= limit) {
|
||||
pack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void createMenu() {
|
||||
|
@ -19,13 +19,14 @@ import sarsoo.fmframework.net.Network;
|
||||
import sarsoo.fmframework.util.Maths;
|
||||
import sarsoo.fmframework.util.Reference;
|
||||
|
||||
public class FMObjView extends JFrame{
|
||||
public class FMObjView extends JFrame {
|
||||
JPanel buttons = new JPanel();
|
||||
|
||||
JLabel name = new JLabel();
|
||||
JLabel listeners = new JLabel();
|
||||
JLabel playCount = new JLabel();
|
||||
JLabel userPlayCount = new JLabel();
|
||||
JLabel timePlayRatio = new JLabel();
|
||||
|
||||
JButton viewWiki = new JButton("View Wiki");
|
||||
JButton open = new JButton("View Online");
|
||||
@ -34,16 +35,16 @@ public class FMObjView extends JFrame{
|
||||
public FMObjView(FMObj obj) {
|
||||
super(obj.toString());
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setLayout(new GridLayout(5,0));
|
||||
setLayout(new GridLayout(6, 1));
|
||||
setSize(300, 300);
|
||||
// setResizable(false);
|
||||
// setResizable(false);
|
||||
|
||||
buttons.setLayout(new FlowLayout());
|
||||
|
||||
buttons.add(open);
|
||||
if (obj.getWiki() != null)
|
||||
buttons.add(viewWiki);
|
||||
if(obj.getMbid() != null)
|
||||
if (obj.getMbid() != null)
|
||||
buttons.add(musicBrainz);
|
||||
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
@ -58,10 +59,25 @@ public class FMObjView extends JFrame{
|
||||
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
playCount.setText(numberFormat.format(obj.getPlayCount()) + " Total Scrobbles");
|
||||
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(obj, Reference.getUserName())));
|
||||
userPlayCount.setText(numberFormat.format(obj.getUserPlayCount())
|
||||
+ String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(obj, Reference.getUserName())));
|
||||
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
userPlayCount.setFont(sub);
|
||||
|
||||
double ratio = obj.getTimeListenRatio();
|
||||
|
||||
// int ratioRound = (int) Math.round(ratio);
|
||||
// int oneOverRatioRound = (int) Math.round(1/ratio);
|
||||
if (ratio > 1) {
|
||||
timePlayRatio.setText(String.format("listen every %.2f days", ratio));
|
||||
} else if (ratio == 1) {
|
||||
timePlayRatio.setText("listen every day");
|
||||
} else {
|
||||
timePlayRatio.setText(String.format("%.2f times a day", 1 / ratio));
|
||||
}
|
||||
timePlayRatio.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
timePlayRatio.setFont(sub);
|
||||
|
||||
viewWiki.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
obj.getWiki().view(obj.getName());
|
||||
@ -74,18 +90,19 @@ public class FMObjView extends JFrame{
|
||||
});
|
||||
musicBrainz.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Network.openURL(obj.getMusicBrainzURL());;
|
||||
Network.openURL(obj.getMusicBrainzURL());
|
||||
;
|
||||
}
|
||||
});
|
||||
add(name);
|
||||
add(userPlayCount);
|
||||
add(timePlayRatio);
|
||||
add(listeners);
|
||||
add(playCount);
|
||||
// add(info);
|
||||
// add(info);
|
||||
add(buttons);
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public class MainMenu extends JFrame {
|
||||
today.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
Network.openURL(String.format("https://www.last.fm/user/%s/library?date_preset=LAST_30_DAYS", Reference.getUserName()));
|
||||
today.setText("Today: " + Integer.toString(Getter.getScrobblesToday(Reference.getUserName())));
|
||||
}
|
||||
});
|
||||
add(viewLastTrack);
|
||||
|
@ -22,7 +22,7 @@ public class TagMenuView extends JFrame {
|
||||
ArrayList<Tag> tags = Getter.getUserTags(Reference.getUserName());
|
||||
|
||||
setLayout(new GridLayout(4, 4));
|
||||
setSize(300, 300);
|
||||
setSize(700, 700);
|
||||
setResizable(false);
|
||||
|
||||
int counter;
|
||||
|
@ -34,6 +34,7 @@ public class TrackView extends JFrame {
|
||||
JLabel listeners = new JLabel();
|
||||
JLabel playCount = new JLabel();
|
||||
JLabel userPlayCount = new JLabel();
|
||||
JLabel timePlayRatio = new JLabel();
|
||||
|
||||
JButton open = new JButton("View Online");
|
||||
JButton viewArtist = new JButton("View Artist");
|
||||
@ -46,9 +47,9 @@ public class TrackView extends JFrame {
|
||||
super(track.getName());
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
if (track.getAlbum() != null) {
|
||||
setLayout(new GridLayout(7, 1));
|
||||
setLayout(new GridLayout(8, 1));
|
||||
} else {
|
||||
setLayout(new GridLayout(6, 1));
|
||||
setLayout(new GridLayout(7, 1));
|
||||
}
|
||||
// setSize(300, 300);
|
||||
setResizable(false);
|
||||
@ -74,6 +75,7 @@ public class TrackView extends JFrame {
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
Font title = new Font("Arial", Font.BOLD, 24);
|
||||
Font sub = new Font("Arial", Font.PLAIN, 20);
|
||||
Font subSub = new Font("Arial", Font.PLAIN, 16);
|
||||
|
||||
name.setText(track.getName());
|
||||
name.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
@ -95,6 +97,20 @@ public class TrackView extends JFrame {
|
||||
artist.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
artist.setFont(sub);
|
||||
|
||||
double ratio = track.getTimeListenRatio();
|
||||
|
||||
// int ratioRound = (int) Math.round(ratio);
|
||||
// int oneOverRatioRound = (int) Math.round(1/ratio);
|
||||
if (ratio > 1) {
|
||||
timePlayRatio.setText(String.format("listen every %.2f days", ratio));
|
||||
} else if (ratio == 1) {
|
||||
timePlayRatio.setText("listen every day");
|
||||
} else {
|
||||
timePlayRatio.setText(String.format("%.2f times a day", 1 / ratio));
|
||||
}
|
||||
timePlayRatio.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
timePlayRatio.setFont(subSub);
|
||||
|
||||
listeners.setText(numberFormat.format(track.getListeners()) + " Listeners");
|
||||
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles");
|
||||
@ -161,6 +177,7 @@ public class TrackView extends JFrame {
|
||||
add(album);
|
||||
add(artist);
|
||||
add(userPlayCount);
|
||||
add(timePlayRatio);
|
||||
add(listeners);
|
||||
add(playCount);
|
||||
|
||||
|
@ -12,6 +12,8 @@ import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import sarsoo.fmframework.music.Album;
|
||||
import sarsoo.fmframework.music.FMObj;
|
||||
@ -20,134 +22,22 @@ import sarsoo.fmframework.music.Wiki;
|
||||
import sarsoo.fmframework.net.Network;
|
||||
|
||||
public class WikiView extends JFrame {
|
||||
// JPanel date = new JPanel();
|
||||
// JPanel content = new JPanel();
|
||||
// JPanel trackListPanel = new JPanel();
|
||||
|
||||
// JLabel dateLabel = new JLabel();
|
||||
JLabel contentLabel = new JLabel();
|
||||
// JLabel listeners = new JLabel();
|
||||
// JLabel playCount = new JLabel();
|
||||
// JLabel userPlayCount = new JLabel();
|
||||
//
|
||||
// JButton open = new JButton("View Online");
|
||||
// JButton viewArtist = new JButton("View Artist");
|
||||
// JButton viewWiki = new JButton("View Wiki");
|
||||
// JButton musicBrainz = new JButton("Open MusicBrainz");
|
||||
// JButton rym = new JButton("Open RYM");
|
||||
JTextArea contentLabel = new JTextArea();
|
||||
|
||||
public WikiView(Wiki wiki, String name) {
|
||||
super(name);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setLayout(new GridLayout(1,1));
|
||||
setSize(500, 700);
|
||||
// setResizable(false);
|
||||
contentLabel.setText(wiki.getContent()+ "\n\n" + wiki.getDate());
|
||||
|
||||
// buttons.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(viewArtist);
|
||||
// if (album.getWiki() != null)
|
||||
// buttons2.add(viewWiki);
|
||||
// if (album.getMbid() != null)
|
||||
// buttons2.add(musicBrainz);
|
||||
// buttons2.add(rym);
|
||||
//
|
||||
// NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
//
|
||||
// dateLabel.setText(wiki.getDate());
|
||||
contentLabel.setText("<html>" + wiki.getContent() + "<br><br>" + wiki.getDate() + "</html>");
|
||||
contentLabel.setLineWrap(true);
|
||||
// contentLabel.setText("<html>" + wiki.getContent() + "<br><br>" + wiki.getDate() + "</html>");
|
||||
|
||||
// artist.setText(album.getArtist().getName());
|
||||
// listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
|
||||
// playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
||||
// userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + " Your Scrobbles");
|
||||
//
|
||||
// open.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent arg0) {
|
||||
// Network.openURL(album.getUrl());
|
||||
// }
|
||||
// });
|
||||
// viewArtist.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent arg0) {
|
||||
// album.getArtist().view();
|
||||
// }
|
||||
// });
|
||||
// viewWiki.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent arg0) {
|
||||
// album.getWiki().view();
|
||||
// }
|
||||
// });
|
||||
// musicBrainz.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent arg0) {
|
||||
// Network.openURL(album.getMusicBrainzURL());
|
||||
// ;
|
||||
// }
|
||||
// });
|
||||
// rym.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent arg0) {
|
||||
// Network.openURL(album.getRymURL());
|
||||
// ;
|
||||
// }
|
||||
// });
|
||||
JScrollPane scroll = new JScrollPane(contentLabel);
|
||||
add(scroll);
|
||||
|
||||
// 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(artist);
|
||||
// add(listeners);
|
||||
// add(playCount);
|
||||
// add(userPlayCount);
|
||||
//
|
||||
// add(trackListPanel);
|
||||
// JPanel datePanel = new JPanel();
|
||||
// datePanel.setLayout(new FlowLayout());
|
||||
// datePanel.add(dateLabel);
|
||||
|
||||
// add(datePanel);
|
||||
add(contentLabel);
|
||||
// add(contentLabel);
|
||||
// pack();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package sarsoo.fmframework.music;
|
||||
|
||||
import sarsoo.fmframework.gui.FMObjView;
|
||||
import sarsoo.fmframework.util.Maths;
|
||||
|
||||
public abstract class FMObj implements Comparable<FMObj>{
|
||||
|
||||
@ -39,6 +40,10 @@ public abstract class FMObj implements Comparable<FMObj>{
|
||||
return userPlayCount - obj.getUserPlayCount();
|
||||
}
|
||||
|
||||
public double getTimeListenRatio() {
|
||||
return Maths.getDaysScrobbling() / (double) userPlayCount;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import sarsoo.fmframework.parser.AlbumParser;
|
||||
import sarsoo.fmframework.parser.Parser;
|
||||
import sarsoo.fmframework.util.FMObjList;
|
||||
import sarsoo.fmframework.util.Getter;
|
||||
import sarsoo.fmframework.util.Maths;
|
||||
import sarsoo.fmframework.util.Reference;
|
||||
|
||||
class NetworkTest {
|
||||
@ -57,7 +58,7 @@ class NetworkTest {
|
||||
void testTag() {
|
||||
|
||||
// System.out.println(Instant.parse("2018-04-05T07:00:00.00Z").getEpochSecond());
|
||||
System.out.println(Getter.getScrobblesToday("sarsoo"));
|
||||
System.out.println(Maths.getDaysScrobbling());
|
||||
|
||||
// System.out.println(url);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package sarsoo.fmframework.util;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import sarsoo.fmframework.music.FMObj;
|
||||
|
||||
@ -22,7 +24,7 @@ public class Maths {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double getPercentListening(FMObjList objList, String username) {
|
||||
public static double getPercentListening(FMObjList objList, String username) {
|
||||
|
||||
int userScrobbles = Getter.getScrobbles(Reference.getUserName());
|
||||
double plays = (double) objList.getTotalUserScrobbles();
|
||||
@ -37,4 +39,20 @@ public static double getPercentListening(FMObjList objList, String username) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getDaysScrobbling() {
|
||||
|
||||
Calendar calendar = new GregorianCalendar(2017, 10, 2);
|
||||
|
||||
// System.out.println(calendar.getTime().getTime());
|
||||
|
||||
Date date = new Date();
|
||||
// System.out.println(date.getTime());
|
||||
|
||||
long diff = date.getTime() - calendar.getTime().getTime();
|
||||
|
||||
// System.out.println(diff/(1000*60*60*24));
|
||||
|
||||
return (int) (diff/(1000*60*60*24));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user