mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-06 09:34:37 +02:00
fix(YouTube Music - Dark theme): Gradient not applied to playlist header background
This commit is contained in:
parent
44600d9525
commit
d4736e6dc6
@ -1,6 +1,7 @@
|
||||
package app.revanced.extension.music.patches.utils;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
@ -35,17 +36,29 @@ public class DrawableColorPatch {
|
||||
viewGroup.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||
if (!(viewGroup instanceof FrameLayout frameLayout))
|
||||
return;
|
||||
if (!(frameLayout.getChildAt(0) instanceof ViewGroup parentViewGroup))
|
||||
if (!(frameLayout.getChildAt(0) instanceof ViewGroup firstChildView))
|
||||
return;
|
||||
if (!(parentViewGroup.getChildAt(0) instanceof ImageView gradientView))
|
||||
return;
|
||||
// For some reason, it sometimes applies to other lithoViews.
|
||||
// To prevent this, check the viewId before applying the gradient.
|
||||
if (headerGradient != null && viewGroup.getId() == elementsContainerIdentifier) {
|
||||
gradientView.setForeground(headerGradient);
|
||||
View secondChildView = firstChildView.getChildAt(0);
|
||||
|
||||
if (secondChildView instanceof ImageView gradientView) {
|
||||
// Album
|
||||
setHeaderGradient(viewGroup, gradientView);
|
||||
} else if (secondChildView instanceof ViewGroup thirdChildView &&
|
||||
thirdChildView.getChildCount() == 1 &&
|
||||
thirdChildView.getChildAt(0) instanceof ImageView gradientView) {
|
||||
// Playlist
|
||||
setHeaderGradient(viewGroup, gradientView);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setHeaderGradient(ViewGroup viewGroup, ImageView gradientView) {
|
||||
// For some reason, it sometimes applies to other lithoViews.
|
||||
// To prevent this, check the viewId before applying the gradient.
|
||||
if (headerGradient != null && viewGroup.getId() == elementsContainerIdentifier) {
|
||||
gradientView.setForeground(headerGradient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user