Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix(YouTube - Disable suggested video end screen): Do not spam click …
Browse files Browse the repository at this point in the history
…to disable the screen
  • Loading branch information
oSumAtrIX committed Nov 6, 2023
1 parent e94de61 commit 7216ec1
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}

0 comments on commit 7216ec1

Please sign in to comment.