Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Util.activity reference from being nullified. #404

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/util/src/main/native/android/dalvik/Util.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023, Gluon
* Copyright (c) 2020, 2024, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -47,9 +47,9 @@ public class Util {
private static boolean debug = false;

public Util(Activity activity) {
Util.activity = activity;
Log.v(TAG, "Util <init>");
if (activity != null) {
Util.activity = activity;
new Handler(Util.activity.getMainLooper()).postDelayed(new Runnable() {

@Override
Expand Down Expand Up @@ -97,6 +97,9 @@ private static void syncClipboardFromOS() {
@Override
public void run() {
if (Util.activity == null) {
if (debug) {
Log.v(TAG, "Util::syncClipboardFromOS failed, no activity");
}
return;
}
new Handler(Util.activity.getMainLooper()).postDelayed(new Runnable() {
Expand All @@ -123,6 +126,9 @@ public void run() {

private static void syncClipboardToOS() {
if (Util.activity == null) {
if (debug) {
Log.v(TAG, "Util::syncClipboardToOS failed, no activity");
}
return;
}
final String text = nativeSyncClipboardToOS();
Expand Down
Loading