added time play ratio, added wrapping and scrollbar to wiki view

This commit is contained in:
aj 2018-04-08 22:09:17 -07:00
parent 55b4ed625a
commit d4a7120df2
10 changed files with 196 additions and 213 deletions

View File

@ -31,6 +31,7 @@ public class AlbumView extends JFrame {
JLabel listeners = new JLabel(); JLabel listeners = new JLabel();
JLabel playCount = new JLabel(); JLabel playCount = new JLabel();
JLabel userPlayCount = new JLabel(); JLabel userPlayCount = new JLabel();
JLabel timePlayRatio = new JLabel();
JButton open = new JButton("View Online"); JButton open = new JButton("View Online");
JButton viewArtist = new JButton("View Artist"); JButton viewArtist = new JButton("View Artist");
@ -41,18 +42,18 @@ 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(6, 1)); setLayout(new GridLayout(7, 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()); // System.out.println(album.getName());
// if (album.getTrackList() != null) // if (album.getTrackList() != null)
// buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1)); // buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1));
buttons.add(open); buttons.add(open);
// buttons2.add(viewArtist); // buttons2.add(viewArtist);
if (album.getWiki() != null) if (album.getWiki() != null)
buttons.add(viewWiki); buttons.add(viewWiki);
@ -77,10 +78,25 @@ public class AlbumView extends JFrame {
playCount.setText(numberFormat.format(album.getPlayCount()) + " Total Scrobbles"); playCount.setText(numberFormat.format(album.getPlayCount()) + " Total Scrobbles");
playCount.setHorizontalAlignment(SwingConstants.CENTER); 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.setHorizontalAlignment(SwingConstants.CENTER);
userPlayCount.setFont(sub); 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() { artist.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -88,7 +104,6 @@ public class AlbumView extends JFrame {
} }
}); });
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());
@ -117,55 +132,57 @@ public class AlbumView extends JFrame {
} }
}); });
// if (album.getTrackList() != null) { // if (album.getTrackList() != null) {
// int counter; // int counter;
// ArrayList<Track> trackList = album.getTrackList(); // ArrayList<Track> trackList = album.getTrackList();
// for (counter = 0; counter < trackList.size(); counter++) { // for (counter = 0; counter < trackList.size(); counter++) {
// Track track = trackList.get(counter); // Track track = trackList.get(counter);
// JLabel name = new JLabel(track.getName()); // JLabel name = new JLabel(track.getName());
// //
// int playCountString = track.getUserPlayCount(); // int playCountString = track.getUserPlayCount();
// //
// JLabel userPlays; // JLabel userPlays;
// if (playCountString == 0) // if (playCountString == 0)
// userPlays = new JLabel("0"); // userPlays = new JLabel("0");
// else // else
// userPlays = new JLabel(Integer.toString(track.getUserPlayCount())); // userPlays = new JLabel(Integer.toString(track.getUserPlayCount()));
// //
// JLabel plays = new JLabel(numberFormat.format(track.getPlayCount())); // JLabel plays = new JLabel(numberFormat.format(track.getPlayCount()));
// 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(track.getUrl()); // Network.openURL(track.getUrl());
// } // }
// }); // });
// JButton openInternal = new JButton("Open " + track.getClass().getSimpleName()); // JButton openInternal = new JButton("Open " +
// openInternal.addActionListener(new ActionListener() { // track.getClass().getSimpleName());
// public void actionPerformed(ActionEvent arg0) { // openInternal.addActionListener(new ActionListener() {
// track.view(); // public void actionPerformed(ActionEvent arg0) {
// } // track.view();
// }); // }
// JPanel panel = new JPanel(); // });
// panel.setLayout(new GridLayout(1, 5)); // JPanel panel = new JPanel();
// panel.add(name); // panel.setLayout(new GridLayout(1, 5));
// panel.add(userPlays); // panel.add(name);
// panel.add(plays); // panel.add(userPlays);
// panel.add(openInternal); // panel.add(plays);
// panel.add(openExternal); // panel.add(openInternal);
// // panel.add(openExternal);
// trackListPanel.add(panel); //
// } // trackListPanel.add(panel);
// } // }
// }
add(name); add(name);
add(artist); add(artist);
add(userPlayCount); add(userPlayCount);
add(timePlayRatio);
add(listeners); add(listeners);
add(playCount); add(playCount);
// add(trackListPanel); // add(trackListPanel);
add(buttons); add(buttons);
// add(buttons2); // add(buttons2);
pack(); pack();
} }
} }

View File

@ -17,6 +17,7 @@ import javax.swing.JMenu;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import sarsoo.fmframework.music.Album; import sarsoo.fmframework.music.Album;
@ -32,10 +33,19 @@ public class FMObjListView extends JFrame {
public FMObjListView(FMObjList objects, String title) { public FMObjListView(FMObjList objects, String title) {
super(title); super(title);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLayout(new GridLayout(objects.size() + 2, 0)); // setLayout(new GridLayout(objects.size() + 2, 0));
setResizable(false); // setResizable(false);
// createMenu(); // 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); 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); 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(""));
// headerLabels.add(new JLabel("")); // headerLabels.add(new JLabel(""));
add(headerLabels); container.add(headerLabels);
Collections.sort(objects); Collections.sort(objects);
Collections.reverse(objects); Collections.reverse(objects);
@ -112,7 +122,7 @@ public class FMObjListView extends JFrame {
// panel.add(openInternal); // panel.add(openInternal);
panel.add(openExternal); panel.add(openExternal);
add(panel); container.add(panel);
} }
JPanel info = new JPanel(); JPanel info = new JPanel();
@ -133,8 +143,15 @@ public class FMObjListView extends JFrame {
// } // }
add(info); container.add(info);
pack();
JScrollPane scroll = new JScrollPane(container);
add(scroll);
if(objects.size() <= limit) {
pack();
}
} }
private void createMenu() { private void createMenu() {

View File

@ -19,13 +19,14 @@ import sarsoo.fmframework.net.Network;
import sarsoo.fmframework.util.Maths; import sarsoo.fmframework.util.Maths;
import sarsoo.fmframework.util.Reference; import sarsoo.fmframework.util.Reference;
public class FMObjView extends JFrame{ public class FMObjView extends JFrame {
JPanel buttons = new JPanel(); JPanel buttons = new JPanel();
JLabel name = new JLabel(); JLabel name = new JLabel();
JLabel listeners = new JLabel(); JLabel listeners = new JLabel();
JLabel playCount = new JLabel(); JLabel playCount = new JLabel();
JLabel userPlayCount = new JLabel(); JLabel userPlayCount = new JLabel();
JLabel timePlayRatio = new JLabel();
JButton viewWiki = new JButton("View Wiki"); JButton viewWiki = new JButton("View Wiki");
JButton open = new JButton("View Online"); JButton open = new JButton("View Online");
@ -34,16 +35,16 @@ public class FMObjView extends JFrame{
public FMObjView(FMObj obj) { public FMObjView(FMObj obj) {
super(obj.toString()); super(obj.toString());
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLayout(new GridLayout(5,0)); setLayout(new GridLayout(6, 1));
setSize(300, 300); setSize(300, 300);
// setResizable(false); // setResizable(false);
buttons.setLayout(new FlowLayout()); buttons.setLayout(new FlowLayout());
buttons.add(open); buttons.add(open);
if (obj.getWiki() != null) if (obj.getWiki() != null)
buttons.add(viewWiki); buttons.add(viewWiki);
if(obj.getMbid() != null) if (obj.getMbid() != null)
buttons.add(musicBrainz); buttons.add(musicBrainz);
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US); NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
@ -58,10 +59,25 @@ public class FMObjView extends JFrame{
listeners.setHorizontalAlignment(SwingConstants.CENTER); listeners.setHorizontalAlignment(SwingConstants.CENTER);
playCount.setText(numberFormat.format(obj.getPlayCount()) + " Total Scrobbles"); playCount.setText(numberFormat.format(obj.getPlayCount()) + " Total Scrobbles");
playCount.setHorizontalAlignment(SwingConstants.CENTER); 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.setHorizontalAlignment(SwingConstants.CENTER);
userPlayCount.setFont(sub); 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() { viewWiki.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
obj.getWiki().view(obj.getName()); obj.getWiki().view(obj.getName());
@ -74,18 +90,19 @@ public class FMObjView extends JFrame{
}); });
musicBrainz.addActionListener(new ActionListener() { musicBrainz.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
Network.openURL(obj.getMusicBrainzURL());; Network.openURL(obj.getMusicBrainzURL());
;
} }
}); });
add(name); add(name);
add(userPlayCount); add(userPlayCount);
add(timePlayRatio);
add(listeners); add(listeners);
add(playCount); add(playCount);
// add(info); // add(info);
add(buttons); add(buttons);
pack(); pack();
} }
} }

View File

@ -77,6 +77,7 @@ public class MainMenu extends JFrame {
today.addActionListener(new ActionListener() { today.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
Network.openURL(String.format("https://www.last.fm/user/%s/library?date_preset=LAST_30_DAYS", Reference.getUserName())); 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); add(viewLastTrack);

View File

@ -22,7 +22,7 @@ public class TagMenuView extends JFrame {
ArrayList<Tag> tags = Getter.getUserTags(Reference.getUserName()); ArrayList<Tag> tags = Getter.getUserTags(Reference.getUserName());
setLayout(new GridLayout(4, 4)); setLayout(new GridLayout(4, 4));
setSize(300, 300); setSize(700, 700);
setResizable(false); setResizable(false);
int counter; int counter;

View File

@ -34,6 +34,7 @@ public class TrackView extends JFrame {
JLabel listeners = new JLabel(); JLabel listeners = new JLabel();
JLabel playCount = new JLabel(); JLabel playCount = new JLabel();
JLabel userPlayCount = new JLabel(); JLabel userPlayCount = new JLabel();
JLabel timePlayRatio = new JLabel();
JButton open = new JButton("View Online"); JButton open = new JButton("View Online");
JButton viewArtist = new JButton("View Artist"); JButton viewArtist = new JButton("View Artist");
@ -46,9 +47,9 @@ public class TrackView extends JFrame {
super(track.getName()); super(track.getName());
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
if (track.getAlbum() != null) { if (track.getAlbum() != null) {
setLayout(new GridLayout(7, 1)); setLayout(new GridLayout(8, 1));
} else { } else {
setLayout(new GridLayout(6, 1)); setLayout(new GridLayout(7, 1));
} }
// setSize(300, 300); // setSize(300, 300);
setResizable(false); setResizable(false);
@ -74,6 +75,7 @@ public class TrackView extends JFrame {
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US); NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
Font title = new Font("Arial", Font.BOLD, 24); Font title = new Font("Arial", Font.BOLD, 24);
Font sub = new Font("Arial", Font.PLAIN, 20); Font sub = new Font("Arial", Font.PLAIN, 20);
Font subSub = new Font("Arial", Font.PLAIN, 16);
name.setText(track.getName()); name.setText(track.getName());
name.setHorizontalAlignment(SwingConstants.CENTER); name.setHorizontalAlignment(SwingConstants.CENTER);
@ -95,6 +97,20 @@ public class TrackView extends JFrame {
artist.setHorizontalAlignment(SwingConstants.CENTER); artist.setHorizontalAlignment(SwingConstants.CENTER);
artist.setFont(sub); 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.setText(numberFormat.format(track.getListeners()) + " Listeners");
listeners.setHorizontalAlignment(SwingConstants.CENTER); listeners.setHorizontalAlignment(SwingConstants.CENTER);
playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles"); playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles");
@ -161,6 +177,7 @@ public class TrackView extends JFrame {
add(album); add(album);
add(artist); add(artist);
add(userPlayCount); add(userPlayCount);
add(timePlayRatio);
add(listeners); add(listeners);
add(playCount); add(playCount);

View File

@ -12,6 +12,8 @@ import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import sarsoo.fmframework.music.Album; import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.music.FMObj; import sarsoo.fmframework.music.FMObj;
@ -20,134 +22,22 @@ import sarsoo.fmframework.music.Wiki;
import sarsoo.fmframework.net.Network; import sarsoo.fmframework.net.Network;
public class WikiView extends JFrame { public class WikiView extends JFrame {
// JPanel date = new JPanel(); JTextArea contentLabel = new JTextArea();
// 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");
public WikiView(Wiki wiki, String name) { public WikiView(Wiki wiki, String name) {
super(name); super(name);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLayout(new GridLayout(1,1)); setLayout(new GridLayout(1,1));
setSize(500, 700); setSize(500, 700);
// setResizable(false); contentLabel.setText(wiki.getContent()+ "\n\n" + wiki.getDate());
// buttons.setLayout(new FlowLayout()); contentLabel.setLineWrap(true);
// buttons2.setLayout(new FlowLayout()); // contentLabel.setText("<html>" + wiki.getContent() + "<br><br>" + wiki.getDate() + "</html>");
//// 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>");
// artist.setText(album.getArtist().getName()); JScrollPane scroll = new JScrollPane(contentLabel);
// listeners.setText(numberFormat.format(album.getListeners()) + " Listeners"); add(scroll);
// 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());
// ;
// }
// });
// if (album.getTrackList() != null) { // add(contentLabel);
// 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);
// pack(); // pack();
} }
} }

View File

@ -1,6 +1,7 @@
package sarsoo.fmframework.music; package sarsoo.fmframework.music;
import sarsoo.fmframework.gui.FMObjView; import sarsoo.fmframework.gui.FMObjView;
import sarsoo.fmframework.util.Maths;
public abstract class FMObj implements Comparable<FMObj>{ public abstract class FMObj implements Comparable<FMObj>{
@ -39,6 +40,10 @@ public abstract class FMObj implements Comparable<FMObj>{
return userPlayCount - obj.getUserPlayCount(); return userPlayCount - obj.getUserPlayCount();
} }
public double getTimeListenRatio() {
return Maths.getDaysScrobbling() / (double) userPlayCount;
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -20,6 +20,7 @@ import sarsoo.fmframework.parser.AlbumParser;
import sarsoo.fmframework.parser.Parser; import sarsoo.fmframework.parser.Parser;
import sarsoo.fmframework.util.FMObjList; import sarsoo.fmframework.util.FMObjList;
import sarsoo.fmframework.util.Getter; import sarsoo.fmframework.util.Getter;
import sarsoo.fmframework.util.Maths;
import sarsoo.fmframework.util.Reference; import sarsoo.fmframework.util.Reference;
class NetworkTest { class NetworkTest {
@ -57,7 +58,7 @@ class NetworkTest {
void testTag() { void testTag() {
// System.out.println(Instant.parse("2018-04-05T07:00:00.00Z").getEpochSecond()); // 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); // System.out.println(url);
} }

View File

@ -1,7 +1,9 @@
package sarsoo.fmframework.util; package sarsoo.fmframework.util;
import javax.swing.JLabel; import java.util.Calendar;
import javax.swing.SwingConstants; import java.util.Date;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;
import sarsoo.fmframework.music.FMObj; import sarsoo.fmframework.music.FMObj;
@ -22,7 +24,7 @@ public class Maths {
return 0; return 0;
} }
public static double getPercentListening(FMObjList objList, String username) { public static double getPercentListening(FMObjList objList, String username) {
int userScrobbles = Getter.getScrobbles(Reference.getUserName()); int userScrobbles = Getter.getScrobbles(Reference.getUserName());
double plays = (double) objList.getTotalUserScrobbles(); double plays = (double) objList.getTotalUserScrobbles();
@ -37,4 +39,20 @@ public static double getPercentListening(FMObjList objList, String username) {
return 0; 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));
}
} }