feat(autojs): UiSelector.indexInParent
This commit is contained in:
@@ -79,7 +79,7 @@ public class ImageWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Mat getMat() {
|
public Mat getMat() {
|
||||||
if (mMat == null) {
|
if (mMat == null && mBitmap != null) {
|
||||||
mMat = new Mat();
|
mMat = new Mat();
|
||||||
Utils.bitmapToMat(mBitmap, mMat);
|
Utils.bitmapToMat(mBitmap, mMat);
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,7 @@ public class ImageWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveTo(String path) {
|
public void saveTo(String path) {
|
||||||
|
ensureNotRecycled();
|
||||||
if (mBitmap != null) {
|
if (mBitmap != null) {
|
||||||
try {
|
try {
|
||||||
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(path));
|
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(path));
|
||||||
@@ -99,6 +100,7 @@ public class ImageWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int pixel(int x, int y) {
|
public int pixel(int x, int y) {
|
||||||
|
ensureNotRecycled();
|
||||||
if (mBitmap != null) {
|
if (mBitmap != null) {
|
||||||
return mBitmap.getPixel(x, y);
|
return mBitmap.getPixel(x, y);
|
||||||
}
|
}
|
||||||
@@ -121,4 +123,9 @@ public class ImageWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ensureNotRecycled() {
|
||||||
|
if (mBitmap == null && mMat == null)
|
||||||
|
throw new IllegalStateException("image has been recycled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -396,6 +396,11 @@ public class UiGlobalSelector {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UiGlobalSelector indexInParent(int index) {
|
||||||
|
mFilters.add(new IntFilter(IntFilter.INDEX_IN_PARENT, index));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public UiGlobalSelector filter(final BooleanFilter.BooleanSupplier filter) {
|
public UiGlobalSelector filter(final BooleanFilter.BooleanSupplier filter) {
|
||||||
mFilters.add(new DfsFilter() {
|
mFilters.add(new DfsFilter() {
|
||||||
|
|||||||
@@ -96,6 +96,18 @@ public class IntFilter extends DfsFilter {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final IntProperty INDEX_IN_PARENT = new IntProperty() {
|
||||||
|
@Override
|
||||||
|
public int get(UiObject object) {
|
||||||
|
return object.indexInParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "indexInParent";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private IntProperty mIntProperty;
|
private IntProperty mIntProperty;
|
||||||
private int mValue;
|
private int mValue;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user