changed fmobjlist scrobble summing for streams

This commit is contained in:
aj 2018-05-10 13:26:13 -07:00
parent b355c8a5d3
commit d5e9769157
2 changed files with 42 additions and 53 deletions

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -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();
else if (obj.getClass() == Track.class) { totalScrobbles += stream().filter(t -> {
Track track = (Track) obj; if (t.getClass() == Album.class) {
Artist artist = track.getArtist(); Album album = (Album) t;
boolean found = false; if (contains(album.getArtist())) {
int counter2; return false;
for (counter2 = 0; counter2 < size(); counter2++) { } else {
if (artist.equals(get(counter2))) { return true;
found = true;
break;
} }
} else {
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())) { } else {
// Album album = track.getAlbum(); return false;
// if (album != null) {
// if (!super.contains(album))
// totalScrobbles += obj.getUserPlayCount();
// }
// }
} }
else if (obj.getClass() == Album.class) { }).mapToInt(FMObj::getUserPlayCount).sum();
Album album = (Album) obj;
Artist artist = album.getArtist();
boolean found = false;
int counter2;
for (counter2 = 0; counter2 < size(); counter2++) {
if (artist.equals(get(counter2))) {
found = true;
break;
}
}
if (!found) {
totalScrobbles += obj.getUserPlayCount();
}
}
}
return totalScrobbles; return totalScrobbles;
} }