summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-07-25 11:19:53 +0200
committercyBerta <cyberta@riseup.net>2020-07-25 11:19:53 +0200
commit86a2a765b9b7bea005bafaad5a4489f06a151de3 (patch)
tree9b1697db01a331744bff5538b2b3cb4ebddcf931 /app/src/main/java/se/leap
parenta2af7f5c226db54442220779cef575d82d215485 (diff)
fix memory leak
Diffstat (limited to 'app/src/main/java/se/leap')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java
index 0a2e2538..890d3b67 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiSetupBroadcastReceiver.java
@@ -22,6 +22,8 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
+import java.lang.ref.WeakReference;
+
import se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState;
/**
@@ -33,18 +35,18 @@ import se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState;
*/
public class ProviderApiSetupBroadcastReceiver extends BroadcastReceiver {
- private final ProviderSetupInterface setupInterface;
+ private WeakReference<ProviderSetupInterface> setupInterfaceRef;
public ProviderApiSetupBroadcastReceiver(ProviderSetupInterface setupInterface) {
- this.setupInterface = setupInterface;
+ this.setupInterfaceRef = new WeakReference<>(setupInterface);
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d(ProviderListBaseActivity.TAG, "received Broadcast");
-
+ ProviderSetupInterface setupInterface = setupInterfaceRef.get();
String action = intent.getAction();
- if (action == null || !action.equalsIgnoreCase(Constants.BROADCAST_PROVIDER_API_EVENT)) {
+ if (action == null || !action.equalsIgnoreCase(Constants.BROADCAST_PROVIDER_API_EVENT) || setupInterface == null) {
return;
}