mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-23 18:27:32 +01:00
fix(YouTube - Disable suggested video end screen): Do not spam click to disable the screen
This commit is contained in:
parent
e94de61eb0
commit
4f57d56042
@ -14,13 +14,23 @@ public final class DisableSuggestedVideoEndScreenPatch {
|
||||
public static void closeEndScreen(final ImageView imageView) {
|
||||
if (!SettingsEnum.DISABLE_SUGGESTED_VIDEO_END_SCREEN.getBoolean()) return;
|
||||
|
||||
// Get the view which can be listened to for layout changes.
|
||||
// Get a parent 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());
|
||||
lastView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
|
||||
int oldRight, int oldBottom) {
|
||||
// Disable sound effects to prevent the click sound.
|
||||
imageView.performClick();
|
||||
|
||||
// Remove the listener to prevent it from being called multiple times.
|
||||
lastView.removeOnLayoutChangeListener(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user