public boolean nearPos(int x1, int y1, int x2, int y2, int diffx, int diffy) { int dx = Math.abs(x2 - x1); int dy = Math.abs(y2 - y1); LogEx.i(x2 + "-" + x1 + ", " + y2 + "-" + y1); LogEx.i("dx: " + dx + ", diffx: " + diffx + ", dy:" + dy + ", diffy:" + diffy); return dx < diffx && dy < diffy; }
/** * 根据匹配参考元素获取同序号的目标元素 * * @param idTarget * @param idRef * @param refText * @return */ public View getRelateView(String idTarget, String idRef, String refText, View parent) { // 先滚动定位到refText位置 if (!this.searchText(refText, true)) return null; View[] refs = getViews(idRef, false, parent); View[] targets = getViews(idTarget, false, parent); LogEx.i(refs.length + " refs"); LogEx.i(targets.length + " targets"); int index = -1; int i = 0; for (View v : refs) { if (((TextView) v).getText().toString().matches(refText)) { index = i; break; } i++; } if (index == -1) return null; View view = targets[index]; return view; }
public void waitLimit(int msTime) { int spend = Timer.spend(); if (msTime > spend) { LogEx.i("limited time: wait..."); sleep(msTime - spend); } }
public View getUpperViewIn(View view, String listId) { ViewGroup p = (ViewGroup) view.getParent(); ViewGroup t = null; while (p != null) { LogEx.i(p.toString()); t = (ViewGroup) p.getParent(); if (t != null && t.getId() == this.getId(listId)) return p; p = t; } return null; }