mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
fix: cleans up duplicates
This commit is contained in:
parent
d04ed8d430
commit
05785979e3
1 changed files with 6 additions and 10 deletions
|
|
@ -117,22 +117,20 @@ public class SongRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
int added = 0;
|
int added = 0;
|
||||||
for (Child s : batch) {
|
for (Child song : batch) {
|
||||||
if (!accumulatedSongs.contains(s) && accumulatedSongs.size() < targetCount) {
|
if (!trackIds.contains(song.getId()) && accumulatedSongs.size() < targetCount) {
|
||||||
trackIds.add(s.getId());
|
trackIds.add(song.getId());
|
||||||
accumulatedSongs.add(s);
|
accumulatedSongs.add(song);
|
||||||
added++;
|
added++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (added > 0) {
|
|
||||||
originalCallback.onSongsAvailable(new ArrayList<>(accumulatedSongs));
|
|
||||||
if (accumulatedSongs.size() >= targetCount) {
|
if (accumulatedSongs.size() >= targetCount) {
|
||||||
|
originalCallback.onSongsAvailable(new ArrayList<>(accumulatedSongs));
|
||||||
isComplete = true;
|
isComplete = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void performSmartMix(final String id, final SeedType type, final int count, final MediaCallbackInternal callback) {
|
private void performSmartMix(final String id, final SeedType type, final int count, final MediaCallbackInternal callback) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
@ -194,14 +192,12 @@ public class SongRepository {
|
||||||
List<Child> limitedSimilar = similar.subList(0, Math.min(count, similar.size()));
|
List<Child> limitedSimilar = similar.subList(0, Math.min(count, similar.size()));
|
||||||
callback.onSongsAvailable(limitedSimilar);
|
callback.onSongsAvailable(limitedSimilar);
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "No similar songs, calling fillWithRandom");
|
|
||||||
fillWithRandom(count, callback);
|
fillWithRandom(count, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<ApiResponse> call, @NonNull Throwable t) {
|
||||||
Log.d(TAG, "getSimilarSongs2 failed: " + t.getMessage());
|
|
||||||
fillWithRandom(count, callback);
|
fillWithRandom(count, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue