modularize init script
This commit is contained in:
@@ -2,6 +2,7 @@ package com.stardust.automator;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.stardust.automator.filter.BooleanFilter;
|
||||
import com.stardust.automator.filter.BoundsFilter;
|
||||
@@ -359,9 +360,14 @@ public class UiGlobalSelector {
|
||||
return UiObjectCollection.of(list);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UiObject findOneOf(UiObject node) {
|
||||
// TODO: 2017/3/9 优化
|
||||
return findOf(node).get(0);
|
||||
UiObjectCollection collection = findOf(node);
|
||||
if (collection.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
return collection.get(0);
|
||||
}
|
||||
|
||||
public UiGlobalSelector addFilter(ListFilter filter) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.stardust.automator;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
@@ -199,4 +200,21 @@ public class UiObjectCollection {
|
||||
return this;
|
||||
}
|
||||
|
||||
public UiObjectCollection find(UiGlobalSelector selector) {
|
||||
List<UiObject> list = new ArrayList<>();
|
||||
for (UiObject object : mNodes) {
|
||||
list.addAll(selector.findOf(object).mNodes);
|
||||
}
|
||||
return of(list);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UiObject findOne(UiGlobalSelector selector) {
|
||||
for (UiObject object : mNodes) {
|
||||
UiObject result = selector.findOneOf(object);
|
||||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user