mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Merge pull request #12 from shrapnelnet/main
385-Fix: Player queue lag, limits
This commit is contained in:
commit
77cd7e2fb3
4 changed files with 29 additions and 33 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package com.cappielloantonio.tempo.ui.adapter;
|
package com.cappielloantonio.tempo.ui.adapter;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -10,6 +11,7 @@ import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.media3.session.MediaBrowser;
|
import androidx.media3.session.MediaBrowser;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.RequestBuilder;
|
||||||
import com.cappielloantonio.tempo.R;
|
import com.cappielloantonio.tempo.R;
|
||||||
import com.cappielloantonio.tempo.databinding.ItemPlayerQueueSongBinding;
|
import com.cappielloantonio.tempo.databinding.ItemPlayerQueueSongBinding;
|
||||||
import com.cappielloantonio.tempo.glide.CustomGlideRequest;
|
import com.cappielloantonio.tempo.glide.CustomGlideRequest;
|
||||||
|
|
@ -46,7 +48,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
Child song = songs.get(position);
|
Child song = songs.get(holder.getLayoutPosition());
|
||||||
|
|
||||||
holder.item.queueSongTitleTextView.setText(song.getTitle());
|
holder.item.queueSongTitleTextView.setText(song.getTitle());
|
||||||
holder.item.queueSongSubtitleTextView.setText(
|
holder.item.queueSongSubtitleTextView.setText(
|
||||||
|
|
@ -58,15 +60,21 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
RequestBuilder<Drawable> thumbnail = CustomGlideRequest.Builder
|
||||||
|
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
|
||||||
|
.build()
|
||||||
|
.sizeMultiplier(0.1f);
|
||||||
|
|
||||||
CustomGlideRequest.Builder
|
CustomGlideRequest.Builder
|
||||||
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
|
.from(holder.itemView.getContext(), song.getCoverArtId(), CustomGlideRequest.ResourceType.Song)
|
||||||
.build()
|
.build()
|
||||||
|
.thumbnail(thumbnail)
|
||||||
.into(holder.item.queueSongCoverImageView);
|
.into(holder.item.queueSongCoverImageView);
|
||||||
|
|
||||||
MediaManager.getCurrentIndex(mediaBrowserListenableFuture, new MediaIndexCallback() {
|
MediaManager.getCurrentIndex(mediaBrowserListenableFuture, new MediaIndexCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onRecovery(int index) {
|
public void onRecovery(int index) {
|
||||||
if (position < index) {
|
if (holder.getLayoutPosition() < index) {
|
||||||
holder.item.queueSongTitleTextView.setAlpha(0.2f);
|
holder.item.queueSongTitleTextView.setAlpha(0.2f);
|
||||||
holder.item.queueSongSubtitleTextView.setAlpha(0.2f);
|
holder.item.queueSongSubtitleTextView.setAlpha(0.2f);
|
||||||
holder.item.ratingIndicatorImageView.setAlpha(0.2f);
|
holder.item.ratingIndicatorImageView.setAlpha(0.2f);
|
||||||
|
|
|
||||||
|
|
@ -193,13 +193,13 @@ public class PlaylistPageFragment extends Fragment implements ClickCallback {
|
||||||
playlistPageViewModel.getPlaylistSongLiveList().observe(getViewLifecycleOwner(), songs -> {
|
playlistPageViewModel.getPlaylistSongLiveList().observe(getViewLifecycleOwner(), songs -> {
|
||||||
if (bind != null) {
|
if (bind != null) {
|
||||||
bind.playlistPagePlayButton.setOnClickListener(v -> {
|
bind.playlistPagePlayButton.setOnClickListener(v -> {
|
||||||
MediaManager.startQueue(mediaBrowserListenableFuture, songs.subList(0, Math.min(100, songs.size())), 0);
|
MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0);
|
||||||
activity.setBottomSheetInPeek(true);
|
activity.setBottomSheetInPeek(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
bind.playlistPageShuffleButton.setOnClickListener(v -> {
|
bind.playlistPageShuffleButton.setOnClickListener(v -> {
|
||||||
Collections.shuffle(songs);
|
Collections.shuffle(songs);
|
||||||
MediaManager.startQueue(mediaBrowserListenableFuture, songs.subList(0, Math.min(100, songs.size())), 0);
|
MediaManager.startQueue(mediaBrowserListenableFuture, songs, 0);
|
||||||
activity.setBottomSheetInPeek(true);
|
activity.setBottomSheetInPeek(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class HomeViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Child>> getRandomShuffleSample() {
|
public LiveData<List<Child>> getRandomShuffleSample() {
|
||||||
return songRepository.getRandomSample(100, null, null);
|
return songRepository.getRandomSample(1000, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Chronology>> getChronologySample(LifecycleOwner owner) {
|
public LiveData<List<Chronology>> getChronologySample(LifecycleOwner owner) {
|
||||||
|
|
|
||||||
|
|
@ -4,39 +4,27 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/player_clean_queue_button"
|
||||||
|
style="@style/TitleMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/player_queue_clean_all_button" />
|
||||||
|
|
||||||
<com.cappielloantonio.tempo.helper.recyclerview.NestedScrollableHost
|
<com.cappielloantonio.tempo.helper.recyclerview.NestedScrollableHost
|
||||||
android:id="@+id/player_queue_nested_scrollable_recycler_view"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/player_queue_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:paddingBottom="@dimen/global_padding_bottom">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/player_queue_recycler_view"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/player_clean_queue_button"
|
|
||||||
style="@style/TitleMedium"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:text="@string/player_queue_clean_all_button"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
</com.cappielloantonio.tempo.helper.recyclerview.NestedScrollableHost>
|
</com.cappielloantonio.tempo.helper.recyclerview.NestedScrollableHost>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue