mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-24 03:35:49 +01:00
fix(YouTube - Disable suggested video end screen): Hide the view once possible
Previously the patch tried to hide the screen when it was not visible to begin with.
This commit is contained in:
parent
21bccf6a99
commit
df278222e8
@ -1,13 +1,26 @@
|
||||
package app.revanced.integrations.patches;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import app.revanced.integrations.settings.SettingsEnum;
|
||||
|
||||
/** @noinspection unused*/
|
||||
public final class DisableSuggestedVideoEndScreenPatch {
|
||||
public static void closeEndScreen(ImageView imageView) {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static View lastView;
|
||||
|
||||
public static void closeEndScreen(final ImageView imageView) {
|
||||
if (!SettingsEnum.DISABLE_SUGGESTED_VIDEO_END_SCREEN.getBoolean()) return;
|
||||
|
||||
imageView.performClick();
|
||||
// Get the view which can be listened to for layout changes.
|
||||
final var parent = imageView.getParent().getParent();
|
||||
|
||||
// Prevent adding the listener multiple times.
|
||||
if (lastView == parent) return;
|
||||
|
||||
lastView = (ViewGroup)parent;
|
||||
lastView.addOnLayoutChangeListener((view, i, i1, i2, i3, i4, i5, i6, i7) -> imageView.performClick());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user