Skip to content

Commit

Permalink
Prevent Util.activity reference from being nullified. (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
jperedadnr authored Aug 11, 2024
1 parent d3178b7 commit 80260a7
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit 80260a7

Please sign in to comment.