changed fmobjlist scrobble summing for streams
This commit is contained in:
parent
b355c8a5d3
commit
d5e9769157
@ -1,3 +0,0 @@
|
|||||||
Manifest-Version: 1.0
|
|
||||||
Class-Path:
|
|
||||||
|
|
@ -9,7 +9,7 @@ import sarsoo.fmframework.music.Artist;
|
|||||||
import sarsoo.fmframework.music.FMObj;
|
import sarsoo.fmframework.music.FMObj;
|
||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
|
|
||||||
public class FMObjList extends ArrayList<FMObj> implements Comparable<FMObjList>, Serializable{
|
public class FMObjList extends ArrayList<FMObj> implements Comparable<FMObjList>, Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -25,57 +25,49 @@ public class FMObjList extends ArrayList<FMObj> implements Comparable<FMObjList>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalUserScrobbles() {
|
public int getTotalUserScrobbles() {
|
||||||
int counter;
|
|
||||||
int totalScrobbles = 0;
|
|
||||||
for (counter = 0; counter < size(); counter++) {
|
|
||||||
FMObj obj = get(counter);
|
|
||||||
|
|
||||||
if (obj.getClass() == Artist.class)
|
int totalScrobbles = stream().filter(t -> t.getClass() == Artist.class).mapToInt(FMObj::getUserPlayCount).sum();
|
||||||
totalScrobbles += obj.getUserPlayCount();
|
|
||||||
|
totalScrobbles += stream().filter(t -> {
|
||||||
else if (obj.getClass() == Track.class) {
|
if (t.getClass() == Album.class) {
|
||||||
Track track = (Track) obj;
|
|
||||||
|
Album album = (Album) t;
|
||||||
Artist artist = track.getArtist();
|
|
||||||
|
if (contains(album.getArtist())) {
|
||||||
boolean found = false;
|
return false;
|
||||||
int counter2;
|
} else {
|
||||||
for (counter2 = 0; counter2 < size(); counter2++) {
|
return true;
|
||||||
if (artist.equals(get(counter2))) {
|
}
|
||||||
found = true;
|
} else {
|
||||||
break;
|
return false;
|
||||||
|
}
|
||||||
|
}).mapToInt(FMObj::getUserPlayCount).sum();
|
||||||
|
|
||||||
|
totalScrobbles += stream().filter(t -> {
|
||||||
|
if (t.getClass() == Track.class) {
|
||||||
|
|
||||||
|
Track track = (Track) t;
|
||||||
|
|
||||||
|
if (contains(track.getArtist())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (track.getAlbum() != null) {
|
||||||
|
if (contains(track.getAlbum())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
totalScrobbles += obj.getUserPlayCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (!super.contains(track.getArtist())) {
|
|
||||||
// Album album = track.getAlbum();
|
|
||||||
// if (album != null) {
|
|
||||||
// if (!super.contains(album))
|
|
||||||
// totalScrobbles += obj.getUserPlayCount();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
else if (obj.getClass() == Album.class) {
|
|
||||||
Album album = (Album) obj;
|
|
||||||
|
|
||||||
Artist artist = album.getArtist();
|
} else {
|
||||||
|
return false;
|
||||||
boolean found = false;
|
|
||||||
int counter2;
|
|
||||||
for (counter2 = 0; counter2 < size(); counter2++) {
|
|
||||||
if (artist.equals(get(counter2))) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
totalScrobbles += obj.getUserPlayCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}).mapToInt(FMObj::getUserPlayCount).sum();
|
||||||
|
|
||||||
return totalScrobbles;
|
return totalScrobbles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +98,12 @@ public class FMObjList extends ArrayList<FMObj> implements Comparable<FMObjList>
|
|||||||
public int compareTo(FMObjList list) {
|
public int compareTo(FMObjList list) {
|
||||||
return getTotalUserScrobbles() - list.getTotalUserScrobbles();
|
return getTotalUserScrobbles() - list.getTotalUserScrobbles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
int counter;
|
int counter;
|
||||||
for(counter = 0; counter < size(); counter++) {
|
for (counter = 0; counter < size(); counter++) {
|
||||||
get(counter).refresh();
|
get(counter).refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user