diff --git a/app/src/main/java/com/cappielloantonio/play/glide/CustomGlideRequest.java b/app/src/main/java/com/cappielloantonio/play/glide/CustomGlideRequest.java index 4b1d87a5..ccf31aaf 100644 --- a/app/src/main/java/com/cappielloantonio/play/glide/CustomGlideRequest.java +++ b/app/src/main/java/com/cappielloantonio/play/glide/CustomGlideRequest.java @@ -1,11 +1,10 @@ package com.cappielloantonio.play.glide; import android.content.Context; +import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.util.Log; -import androidx.core.content.res.ResourcesCompat; - import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.RequestManager; @@ -15,6 +14,7 @@ import com.bumptech.glide.signature.ObjectKey; import com.cappielloantonio.play.App; import com.cappielloantonio.play.R; import com.cappielloantonio.play.util.Preferences; +import com.google.android.material.elevation.SurfaceColors; import java.util.Map; @@ -25,9 +25,11 @@ public class CustomGlideRequest { public static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.ALL; - public static RequestOptions createRequestOptions(String item, Drawable placeholder) { + public static RequestOptions createRequestOptions(Context context, String item) { return new RequestOptions() - .error(placeholder) + .placeholder(new ColorDrawable(SurfaceColors.SURFACE_5.getColor(context))) + .fallback(new ColorDrawable(SurfaceColors.SURFACE_5.getColor(context))) + .error(new ColorDrawable(SurfaceColors.SURFACE_5.getColor(context))) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .signature(new ObjectKey(item != null ? item : 0)) .centerCrop(); @@ -78,8 +80,7 @@ public class CustomGlideRequest { this.item = R.drawable.default_album_art; } - Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), R.drawable.default_album_art, null); - requestManager.applyDefaultRequestOptions(createRequestOptions(item, drawable)); + requestManager.applyDefaultRequestOptions(createRequestOptions(context, item)); } public static Builder from(Context context, String item) { diff --git a/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerBottomSheetFragment.java b/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerBottomSheetFragment.java index 249b0062..7950e571 100644 --- a/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerBottomSheetFragment.java +++ b/app/src/main/java/com/cappielloantonio/play/ui/fragment/PlayerBottomSheetFragment.java @@ -258,6 +258,10 @@ public class PlayerBottomSheetFragment extends Fragment { playerBottomSheetViewModel.getPlayQueue().observeForever(new Observer() { @Override public void onChanged(PlayQueue playQueue) { + playerBottomSheetViewModel.getPlayQueue().removeObserver(this); + + if (bind == null) return; + if (playQueue != null && !playQueue.getEntries().isEmpty()) { int index = IntStream.range(0, playQueue.getEntries().size()).filter(ix -> playQueue.getEntries().get(ix).getId().equals(playQueue.getCurrent())).findFirst().orElse(-1); @@ -272,8 +276,6 @@ public class PlayerBottomSheetFragment extends Fragment { bind.playerHeaderLayout.playerHeaderBookmarkMediaButton.setVisibility(View.GONE); bind.playerHeaderLayout.playerHeaderBookmarkMediaButton.setOnClickListener(null); } - - playerBottomSheetViewModel.getPlayQueue().removeObserver(this); } }); @@ -282,6 +284,9 @@ public class PlayerBottomSheetFragment extends Fragment { return false; }); - new Handler().postDelayed(() -> bind.playerHeaderLayout.playerHeaderBookmarkMediaButton.setVisibility(View.GONE), 5000); + new Handler().postDelayed(() -> { + if (bind != null) + bind.playerHeaderLayout.playerHeaderBookmarkMediaButton.setVisibility(View.GONE); + }, 5000); } } diff --git a/app/src/main/res/layout/item_placehoder_discovery.xml b/app/src/main/res/layout/item_placehoder_discovery.xml index d3874311..ea810b6b 100644 --- a/app/src/main/res/layout/item_placehoder_discovery.xml +++ b/app/src/main/res/layout/item_placehoder_discovery.xml @@ -20,7 +20,7 @@ android:layout_marginTop="12dp" android:layout_marginEnd="8dp" android:layout_weight="9" - android:background="?attr/colorSurfaceContainer" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_placeholder_album.xml b/app/src/main/res/layout/item_placeholder_album.xml index 17a0bc5a..120f0442 100644 --- a/app/src/main/res/layout/item_placeholder_album.xml +++ b/app/src/main/res/layout/item_placeholder_album.xml @@ -20,7 +20,7 @@ android:layout_marginTop="12dp" android:layout_marginEnd="8dp" android:layout_weight="8" - android:background="?attr/colorSurfaceContainer" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_placeholder_genre.xml b/app/src/main/res/layout/item_placeholder_genre.xml index 67576267..aa5aa448 100644 --- a/app/src/main/res/layout/item_placeholder_genre.xml +++ b/app/src/main/res/layout/item_placeholder_genre.xml @@ -12,7 +12,7 @@ android:layout_marginTop="20dp" android:layout_marginEnd="16dp" android:layout_marginBottom="8dp" - android:background="?attr/colorSurfaceContainer" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_placeholder_horizontal.xml b/app/src/main/res/layout/item_placeholder_horizontal.xml index 8c91b00e..e5876724 100644 --- a/app/src/main/res/layout/item_placeholder_horizontal.xml +++ b/app/src/main/res/layout/item_placeholder_horizontal.xml @@ -21,7 +21,7 @@ android:layout_marginTop="12dp" android:layout_marginEnd="8dp" android:layout_weight="8" - android:background="?attr/colorSurfaceContainer" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> @@ -58,7 +58,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="10dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_1" app:layout_constraintTop_toTopOf="parent" /> @@ -68,7 +68,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="4dp" android:layout_marginEnd="16dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_1" app:layout_constraintTop_toBottomOf="@+id/album_title_placeholder_1" /> @@ -77,7 +77,7 @@ android:layout_height="18dp" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" android:gravity="center_vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -98,7 +98,7 @@ android:layout_height="52dp" android:layout_gravity="center" android:layout_margin="2dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -110,7 +110,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="10dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_2" app:layout_constraintTop_toTopOf="parent" /> @@ -120,7 +120,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="4dp" android:layout_marginEnd="16dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_2" app:layout_constraintTop_toBottomOf="@+id/album_title_placeholder_2" /> @@ -129,7 +129,7 @@ android:layout_height="18dp" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" android:gravity="center_vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -150,7 +150,7 @@ android:layout_height="52dp" android:layout_gravity="center" android:layout_margin="2dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -162,7 +162,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="10dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_3" app:layout_constraintTop_toTopOf="parent" /> @@ -172,7 +172,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="4dp" android:layout_marginEnd="16dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_3" app:layout_constraintTop_toBottomOf="@+id/album_title_placeholder_3" /> @@ -181,7 +181,7 @@ android:layout_height="18dp" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" android:gravity="center_vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -202,7 +202,7 @@ android:layout_height="52dp" android:layout_gravity="center" android:layout_margin="2dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -214,7 +214,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="10dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_4" app:layout_constraintTop_toTopOf="parent" /> @@ -224,7 +224,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="4dp" android:layout_marginEnd="16dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_4" app:layout_constraintTop_toBottomOf="@+id/album_title_placeholder_4" /> @@ -233,7 +233,7 @@ android:layout_height="18dp" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" android:gravity="center_vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -254,7 +254,7 @@ android:layout_height="52dp" android:layout_gravity="center" android:layout_margin="2dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -266,7 +266,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="10dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_5" app:layout_constraintTop_toTopOf="parent" /> @@ -276,7 +276,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="4dp" android:layout_marginEnd="16dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" app:layout_constraintStart_toEndOf="@+id/album_cover_placeholder_5" app:layout_constraintTop_toBottomOf="@+id/album_title_placeholder_5" /> @@ -285,7 +285,7 @@ android:layout_height="18dp" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" - android:background="?attr/colorSurfaceContainer" + android:background="?attr/colorSurface" android:gravity="center_vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/item_placeholder_year.xml b/app/src/main/res/layout/item_placeholder_year.xml index b9ccf357..fe0f99ac 100644 --- a/app/src/main/res/layout/item_placeholder_year.xml +++ b/app/src/main/res/layout/item_placeholder_year.xml @@ -12,7 +12,7 @@ android:layout_marginTop="20dp" android:layout_marginEnd="16dp" android:layout_marginBottom="8dp" - android:background="?attr/colorSurfaceContainer" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> + android:background="?attr/colorSurface" /> \ No newline at end of file