diff --git a/app/src/main/java/app/revanced/integrations/patches/DisableSuggestedVideoEndScreenPatch.java b/app/src/main/java/app/revanced/integrations/patches/DisableSuggestedVideoEndScreenPatch.java index 6a5c3ca322..bc0d7f8c8f 100644 --- a/app/src/main/java/app/revanced/integrations/patches/DisableSuggestedVideoEndScreenPatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/DisableSuggestedVideoEndScreenPatch.java @@ -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); + } + }); } }