Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit a5a4860

Browse files
committed
Improve NoodleDebug
1 parent c4f166d commit a5a4860

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/src/main/java/com/fox2code/mmm/utils/NoodleDebug.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ public class NoodleDebug {
1818
private static final ThreadLocal<NoodleDebug> THREAD_NOODLE = new ThreadLocal<>();
1919
@SuppressLint("StaticFieldLeak") // <- Null initialized
2020
private static final NoodleDebug NULL = new NoodleDebug() {
21+
@Override
22+
public NoodleDebug bind() {
23+
getNoodleDebug().unbind();
24+
THREAD_NOODLE.remove();
25+
return this;
26+
}
27+
2128
@Override
2229
public void setEnabled(boolean enabled) {}
2330

@@ -154,7 +161,8 @@ protected void markDirty() {
154161
public static NoodleDebug getNoodleDebug() {
155162
NoodleDebug noodleDebug = THREAD_NOODLE.get();
156163
if (noodleDebug == null) return NULL;
157-
if (noodleDebug.thread.get() != Thread.currentThread()) {
164+
if (noodleDebug.thread.get() != Thread.currentThread() ||
165+
noodleDebug.activity.isDestroyed()) {
158166
THREAD_NOODLE.remove();
159167
return NULL;
160168
}

0 commit comments

Comments
 (0)