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): Properly hide it e…
Browse files Browse the repository at this point in the history
…very time the screen appears

Previously, the screen appeared, which a handler was attached to, in order to hide it again, but the handler was removed again from the same screen, so the next time it appeared, it was not hidden.
  • Loading branch information
oSumAtrIX committed Nov 12, 2023
1 parent 847cce4 commit 828ff6f
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ public static void closeEndScreen(final ImageView imageView) {
if (lastView == parent) return;

lastView = (ViewGroup)parent;
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.setSoundEffectsEnabled(false);
imageView.performClick();

// Remove the listener to prevent it from being called multiple times.
lastView.removeOnLayoutChangeListener(this);
}
lastView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
// Disable sound effects to prevent the click sound.
imageView.setSoundEffectsEnabled(false);
imageView.performClick();
});
}
}

0 comments on commit 828ff6f

Please sign in to comment.