Search in sources :

Example 1 with UiObjectCollection

use of com.stardust.automator.UiObjectCollection in project Auto.js by hyb1996.

the class UiSelector method findOne.

@ScriptInterface
public UiObject findOne(long timeout) {
    if (timeout == -1) {
        return untilFindOne();
    }
    UiObjectCollection uiObjectCollection = find();
    long start = SystemClock.uptimeMillis();
    while (uiObjectCollection.empty()) {
        if (Thread.currentThread().isInterrupted()) {
            throw new ScriptInterruptedException();
        }
        if (SystemClock.uptimeMillis() - start > timeout) {
            return null;
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            throw new ScriptInterruptedException();
        }
        uiObjectCollection = find();
    }
    return uiObjectCollection.get(0);
}
Also used : UiObjectCollection(com.stardust.automator.UiObjectCollection) ScriptInterruptedException(com.stardust.autojs.runtime.exception.ScriptInterruptedException) ScriptInterruptedException(com.stardust.autojs.runtime.exception.ScriptInterruptedException) ScriptInterface(com.stardust.autojs.annotation.ScriptInterface)

Aggregations

ScriptInterface (com.stardust.autojs.annotation.ScriptInterface)1 ScriptInterruptedException (com.stardust.autojs.runtime.exception.ScriptInterruptedException)1 UiObjectCollection (com.stardust.automator.UiObjectCollection)1