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);
}
Aggregations