Skip to content

Commit

Permalink
Merge fc20d26 into be45a71
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Nov 14, 2022
2 parents be45a71 + fc20d26 commit 49cc55d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.sentry.Hint;
import io.sentry.SentryEvent;
import io.sentry.SentryLevel;
import io.sentry.util.HintUtils;
import io.sentry.util.Objects;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
Expand Down Expand Up @@ -51,10 +52,18 @@ public ScreenshotEventProcessor(
application.registerActivityLifecycleCallbacks(this);
}

public void setCurrentActivity(@NonNull Activity activity) {
if (currentActivity != null && currentActivity.get() == activity) {
return;
}
currentActivity = new WeakReference<>(activity);
}

@SuppressWarnings("NullAway")
@Override
public @NotNull SentryEvent process(final @NotNull SentryEvent event, @NotNull Hint hint) {
if (!lifecycleCallbackInstalled) {
if (!lifecycleCallbackInstalled
|| !HintUtils.shouldApplyScopeData(hint)) {
return event;
}
if (!options.isAttachScreenshot()) {
Expand Down Expand Up @@ -167,13 +176,6 @@ private void cleanCurrentActivity(@NonNull Activity activity) {
}
}

private void setCurrentActivity(@NonNull Activity activity) {
if (currentActivity != null && currentActivity.get() == activity) {
return;
}
currentActivity = new WeakReference<>(activity);
}

@SuppressLint("NewApi")
private boolean isActivityValid(@Nullable Activity activity) {
if (activity == null) {
Expand Down

0 comments on commit 49cc55d

Please sign in to comment.