Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class FloatLifecycle extends BroadcastReceiver implements Application.ActivityLi
applicationContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}

public void unRegisterReceiver(Context applicationContext) {
((Application) applicationContext).unregisterActivityLifecycleCallbacks(this);
applicationContext.unregisterReceiver(this);
}

public static void setResumedListener(ResumedListener resumedListener) {
sResumedListener = resumedListener;
}
Expand Down
15 changes: 15 additions & 0 deletions floatwindow/src/main/java/com/yhao/floatwindow/FloatWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,23 @@ public static void destroy(String tag) {
return;
}
mFloatWindowMap.get(tag).dismiss();
mFloatWindowMap.get(tag).destory();
mFloatWindowMap.remove(tag);
}

public static void destroyAll() {
if (mFloatWindowMap == null) return;
for (IFloatWindow iFloatWindow : mFloatWindowMap.values()) {
try {
iFloatWindow.dismiss();
iFloatWindow.destory();
mFloatWindowMap.remove(iFloatWindow);
} catch (Exception e) {
e.printStackTrace();
}
}
mFloatWindowMap = null;
}

public static class B {
Context mApplicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ public abstract class IFloatWindow {
public abstract View getView();

abstract void dismiss();

public abstract void destory();
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public void onBackToDesktop() {
}
});
}

@Override
public void destory() {
if (mFloatLifecycle == null) return;
mFloatLifecycle.unRegisterReceiver(mB.mApplicationContext);
}

@Override
public void show() {
Expand Down