fix: Swipe()
This commit is contained in:
@@ -15,7 +15,7 @@ import com.stardust.autojs.engine.RhinoJavaScriptEngineManager;
|
||||
import com.stardust.autojs.engine.ScriptEngineManager;
|
||||
import com.stardust.autojs.runtime.AccessibilityBridge;
|
||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||
import com.stardust.autojs.runtime.ScriptStopException;
|
||||
import com.stardust.autojs.runtime.ScriptException;
|
||||
import com.stardust.autojs.runtime.api.AbstractShell;
|
||||
import com.stardust.autojs.runtime.api.AppUtils;
|
||||
import com.stardust.autojs.runtime.api.Console;
|
||||
@@ -174,7 +174,7 @@ public class AutoJs {
|
||||
}
|
||||
if (errorMessage != null) {
|
||||
AccessibilityServiceTool.goToAccessibilitySetting();
|
||||
throw new ScriptStopException(errorMessage);
|
||||
throw new ScriptException(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.stardust.autojs.engine;
|
||||
|
||||
import com.stardust.autojs.runtime.ScriptException;
|
||||
import com.stardust.autojs.script.ScriptSource;
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ import com.stardust.autojs.script.ScriptSource;
|
||||
* When the execution finish successfully, the engine should be destroy in the thread that created it.
|
||||
* <p>
|
||||
* If you want to stop the engine in other threads, you should call {@link ScriptEngine#forceStop()}.
|
||||
* It will throw a {@link com.stardust.autojs.runtime.ScriptStopException}.
|
||||
* It will throw a {@link ScriptException}.
|
||||
*/
|
||||
|
||||
public interface ScriptEngine {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.stardust.autojs.runtime;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
public class ScriptException extends RuntimeException {
|
||||
|
||||
|
||||
public ScriptException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ScriptException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ScriptException() {
|
||||
|
||||
}
|
||||
|
||||
public ScriptException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ package com.stardust.autojs.runtime;
|
||||
* Created by Stardust on 2017/4/30.
|
||||
*/
|
||||
|
||||
public class ScriptInterruptedException extends ScriptStopException {
|
||||
public class ScriptInterruptedException extends ScriptException {
|
||||
|
||||
public static boolean causedByInterrupted(Throwable e) {
|
||||
return e instanceof ScriptInterruptedException || e.getCause() instanceof ScriptInterruptedException;
|
||||
|
||||
@@ -226,9 +226,6 @@ public class ScriptRuntime {
|
||||
|
||||
private void ensureRootShell() {
|
||||
if (mRootShell == null) {
|
||||
if (mShellSupplier == null) {
|
||||
throw new ScriptInterruptedException();
|
||||
}
|
||||
mRootShell = mShellSupplier.get();
|
||||
mRootShell.SetScreenMetrics(mScreenMetrics);
|
||||
mShellSupplier = null;
|
||||
@@ -249,7 +246,7 @@ public class ScriptRuntime {
|
||||
|
||||
public void requiresApi(int i) {
|
||||
if (Build.VERSION.SDK_INT < i) {
|
||||
throw new ScriptStopException(mUiHandler.getContext().getString(R.string.text_requires_sdk_version_to_run_the_script) + SdkVersionUtil.sdkIntToString(i));
|
||||
throw new ScriptException(mUiHandler.getContext().getString(R.string.text_requires_sdk_version_to_run_the_script) + SdkVersionUtil.sdkIntToString(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.stardust.autojs.runtime;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/1/29.
|
||||
*/
|
||||
public class ScriptStopException extends RuntimeException {
|
||||
|
||||
|
||||
public ScriptStopException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ScriptStopException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ScriptStopException() {
|
||||
|
||||
}
|
||||
|
||||
public ScriptStopException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.stardust.autojs.runtime.api;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.stardust.autojs.runtime.ScriptStopException;
|
||||
import com.stardust.autojs.runtime.ScriptException;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/1.
|
||||
@@ -59,7 +59,7 @@ public abstract class AbstractConsole implements Console {
|
||||
public void assertTrue(boolean value, @Nullable Object data, Object... options) {
|
||||
if (!value) {
|
||||
printf(Log.ASSERT, data, options);
|
||||
throw new ScriptStopException(new AssertionError(format(data, options)));
|
||||
throw new ScriptException(new AssertionError(format(data, options)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public abstract class AbstractShell {
|
||||
}
|
||||
|
||||
public void Swipe(int x1, int y1, int x2, int y2, int time) {
|
||||
exec(com.stardust.util.TextUtils.join(" ", "input", "tap", scaleX(x1), scaleY(y1), scaleX(x2), scaleY(y2), time));
|
||||
exec(com.stardust.util.TextUtils.join(" ", "input", "swipe", scaleX(x1), scaleY(y1), scaleX(x2), scaleY(y2), time));
|
||||
}
|
||||
|
||||
public void KeyCode(int keyCode) {
|
||||
|
||||
@@ -60,7 +60,9 @@ public class VolatileBox<T> {
|
||||
} catch (InterruptedException e) {
|
||||
try {
|
||||
throw exception.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e1) {
|
||||
} catch (InstantiationException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
} catch (IllegalAccessException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user