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

Commit

Permalink
fix(YouTube/Hide ads): toasts are shown multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 authored and anddea committed Jun 14, 2024
1 parent 72c6aad commit f89390f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class FullscreenAdsPatch {
private static final boolean closeDialog = hideFullscreenAdsEnabled && closeFullscreenAdsEnabled;
private static final boolean disableDialog = hideFullscreenAdsEnabled && !closeFullscreenAdsEnabled;

private static volatile long lastTimeClosedFullscreenAd;

private static WeakReference<Button> buttonRef = new WeakReference<>(null);

public static boolean disableFullscreenAds(int code) {
Expand Down Expand Up @@ -50,8 +52,13 @@ public static void closeFullscreenAds() {
final Button button = buttonRef.get();
if (button == null) return;
button.callOnClick();

final long currentTime = System.currentTimeMillis();
if (currentTime - lastTimeClosedFullscreenAd < 10000) return;
lastTimeClosedFullscreenAd = currentTime;

showToastShort(str("revanced_hide_fullscreen_ads_closed_success"));
}, 100);
}, 500);
}

public static void hideFullscreenAds(View view) {
Expand Down

0 comments on commit f89390f

Please sign in to comment.