fix: floaty.closeAll()
This commit is contained in:
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId "com.stardust.scriptdroid"
|
applicationId "com.stardust.scriptdroid"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 245
|
versionCode 246
|
||||||
versionName "3.0.0 Alpha45"
|
versionName "3.0.0 Alpha46"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
ndk {
|
ndk {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":34},"path":"inrt-release.apk","properties":{"packageId":"com.stardust.auojs.inrt","split":"","minSdkVersion":"17"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":246},"path":"release-3.0.0 Alpha46.apk","properties":{"packageId":"com.stardust.scriptdroid","split":"","minSdkVersion":"17"}}]
|
||||||
@@ -5,7 +5,6 @@ import android.content.Intent;
|
|||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.stardust.autojs.R;
|
import com.stardust.autojs.R;
|
||||||
import com.stardust.autojs.core.floaty.FloatyWindow;
|
import com.stardust.autojs.core.floaty.FloatyWindow;
|
||||||
@@ -19,11 +18,8 @@ import com.stardust.enhancedfloaty.FloatyService;
|
|||||||
import com.stardust.util.UiHandler;
|
import com.stardust.util.UiHandler;
|
||||||
import com.stardust.util.ViewUtil;
|
import com.stardust.util.ViewUtil;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import ezy.assist.compat.SettingsCompat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/12/5.
|
* Created by Stardust on 2017/12/5.
|
||||||
*/
|
*/
|
||||||
@@ -54,10 +50,18 @@ public class Floaty {
|
|||||||
throw new ScriptInterruptedException();
|
throw new ScriptInterruptedException();
|
||||||
}
|
}
|
||||||
JsFloatyWindow window = new JsFloatyWindow(view);
|
JsFloatyWindow window = new JsFloatyWindow(view);
|
||||||
mWindows.add(window);
|
addWindow(window);
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized void addWindow(JsFloatyWindow window) {
|
||||||
|
mWindows.add(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized boolean removeWindow(JsFloatyWindow window) {
|
||||||
|
return mWindows.remove(window);
|
||||||
|
}
|
||||||
|
|
||||||
private View inflate(String xml) {
|
private View inflate(String xml) {
|
||||||
if (Looper.getMainLooper() == Looper.myLooper()) {
|
if (Looper.getMainLooper() == Looper.myLooper()) {
|
||||||
return mJsLayoutInflater.inflate(mContext, xml);
|
return mJsLayoutInflater.inflate(mContext, xml);
|
||||||
@@ -68,13 +72,11 @@ public class Floaty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeAll() {
|
public synchronized void closeAll() {
|
||||||
Iterator<JsFloatyWindow> iterator = mWindows.iterator();
|
for (JsFloatyWindow window : mWindows) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
JsFloatyWindow window = iterator.next();
|
|
||||||
iterator.remove();
|
|
||||||
window.close(false);
|
window.close(false);
|
||||||
}
|
}
|
||||||
|
mWindows.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class JsFloatyWindow {
|
public class JsFloatyWindow {
|
||||||
@@ -154,7 +156,7 @@ public class Floaty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void close(boolean removeFromWindows) {
|
void close(boolean removeFromWindows) {
|
||||||
if (removeFromWindows && !mWindows.remove(this)) {
|
if (removeFromWindows && !removeWindow(this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runWithWindow(() -> {
|
runWithWindow(() -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user