mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
fix: used set to address duplicates and removed toast that was firing to early
This commit is contained in:
parent
a2401302ed
commit
193447d07e
2 changed files with 5 additions and 9 deletions
|
|
@ -11,8 +11,10 @@ import com.cappielloantonio.tempo.util.Constants.SeedType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
|
@ -94,6 +96,7 @@ public class SongRepository {
|
||||||
private final MediaCallbackInternal originalCallback;
|
private final MediaCallbackInternal originalCallback;
|
||||||
private final int targetCount;
|
private final int targetCount;
|
||||||
private final List<Child> accumulatedSongs = new ArrayList<>();
|
private final List<Child> accumulatedSongs = new ArrayList<>();
|
||||||
|
private final Set<String> trackIds = new HashSet<>();
|
||||||
private boolean isComplete = false;
|
private boolean isComplete = false;
|
||||||
|
|
||||||
MediaCallbackAccumulator(MediaCallbackInternal callback, int count) {
|
MediaCallbackAccumulator(MediaCallbackInternal callback, int count) {
|
||||||
|
|
@ -113,6 +116,7 @@ public class SongRepository {
|
||||||
int added = 0;
|
int added = 0;
|
||||||
for (Child s : batch) {
|
for (Child s : batch) {
|
||||||
if (!accumulatedSongs.contains(s) && accumulatedSongs.size() < targetCount) {
|
if (!accumulatedSongs.contains(s) && accumulatedSongs.size() < targetCount) {
|
||||||
|
trackIds.add(s.getId());
|
||||||
accumulatedSongs.add(s);
|
accumulatedSongs.add(s);
|
||||||
added++;
|
added++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,9 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.session.MediaBrowser;
|
import androidx.media3.session.MediaBrowser;
|
||||||
|
|
@ -119,12 +117,6 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement
|
||||||
}
|
}
|
||||||
view.postDelayed(() -> dismissBottomSheet(), 200);
|
view.postDelayed(() -> dismissBottomSheet(), 200);
|
||||||
}, 300);
|
}, 300);
|
||||||
} else {
|
|
||||||
// No songs at all - all attempts failed
|
|
||||||
Toast.makeText(requireContext(),
|
|
||||||
"Could not load songs. Please check your connection.",
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
dismissBottomSheet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue