Waits for a certain view.

@param view the id of the view to wait for
@param index the index of the {@link View}. {@code 0} if only one is available
@return the specified View
188120
public View waitForView(int id, int index, int timeout, boolean scroll){
		Set<View> uniqueViewsMatchingId = new HashSet<View>();
		long endTime = SystemClock.uptimeMillis() + timeout;

		while (SystemClock.uptimeMillis() <= endTime) {
			sleeper.sleep();

			for (View view : viewFetcher.getAllViews(false)) {
				Integer idOfView = Integer.valueOf(view.getId());

				if (idOfView.equals(id)) {
					uniqueViewsMatchingId.add(view);

					if(uniqueViewsMatchingId.size() > index) {
						return view;
					}
				}
			}
			if(scroll) 
				scroller.scrollDown();
		}
		return null;
	}
34714
public <T extends View> ViewGroup getRecyclerView(int recyclerViewIndex, int timeOut) {
		final long endTime = SystemClock.uptimeMillis() + timeOut;

		while (SystemClock.uptimeMillis() < endTime) {
			View recyclerView = getRecyclerView(true, recyclerViewIndex);
			if(recyclerView != null){
				return (ViewGroup) recyclerView;
			}
		}
		return null;
	}
98510
public <T extends View> boolean waitForView(final Class<T> viewClass){
		if(config.commandLogging){
			Log.d(config.commandLoggingTag, "waitForView("+viewClass+")");
		}
		
		return waiter.waitForView(viewClass, 0, Timeout.getLargeTimeout(), true);
	}
509992
@SuppressWarnings("unchecked")
	public <V extends View> V findView(View containerView, int id) {
		return (V)containerView.findViewById(id);
	}
414006
public E get(int index) {
        if (index >= mSize)
            throw new IndexOutOfBoundsException("Index: " + index + ", Size: "
                    + mSize);

        return index < 0 ? mElements.get(index + mSize) : mElements.get(index);
    }
775900
public <T> boolean waitForResource(int res, int timeout) {
        int RETRY_PERIOD = 250;
        int retryNum = timeout / RETRY_PERIOD;
        for (int i = 0; i < retryNum; i++) {
            T View = (T) this.getView(res);
            if (View != null) {
                break;
            }
            if (i == retryNum - 1) {
                return false;
            }
            this.sleep(RETRY_PERIOD);
        }
        return true;
    }
1201591
protected Widget getViewFromAdapter(final int index, ListItemHostWidget host) {
        return mAdapter == null ? null : mAdapter.getView(index, host.getGuest(), host);
    }
167271
public void registerView(final String type, final Pair<View, View> view) {
        registeredViews.put(type, view);
    }
393713
public View getView(String id, int index){
		if(config.commandLogging){
			Log.d(config.commandLoggingTag, "getView(\""+id+"\", "+index+")");
		}
		
		View viewToReturn = getter.getView(id, index);

		if(viewToReturn == null) {
			int match = index + 1;
			if(match > 1){
				Assert.fail(match + " Views with id: '" + id + "' are not found!");
			}
			else {
				Assert.fail("View with id: '" + id + "' is not found!");
			}
		}
		return viewToReturn;
	}
682079
public View getIdenticalView(View view) {
		if(view == null){
			return null;
		}
		View viewToReturn = null;
		List<? extends View> visibleViews = RobotiumUtils.removeInvisibleViews(getCurrentViews(view.getClass(), true));

		for(View v : visibleViews){
			if(areViewsIdentical(v, view)){
				viewToReturn = v;
				break;
			}
		}

		return viewToReturn;
	}
653045
private static void enableView(final View view, final boolean enable) {
    view.setEnabled(enable);
    view.setAlpha(enable ? 1f : 0.1f);
  }
35056
public void setEmptyView(View emptyView) {
        mEmptyView = emptyView;

        final ListAdapter adapter = getAdapter();
        final boolean empty = ((adapter == null) || adapter.isEmpty());
        updateEmptyStatus(empty);
    }
292453
public View getView(int id, int timeout) {
        View v = null;
        int RETRY_PERIOD = 250;
        int retryNum = timeout / RETRY_PERIOD;

        for (int i = 0; i < retryNum; i++) {
            try {
                v = super.getView(id);
            } catch (Exception e) {}

            if (v != null) {
                break;
            }
            this.sleep(RETRY_PERIOD);
        }
        return v;
    }
783660
public ArrayList<View> getCustomViews(String viewName)
    {
        ArrayList<View> returnViews = new ArrayList<View>();
        for(View v: this.getViews())
        {
            if(v.getClass().getSimpleName().equals(viewName))
                returnViews.add(v);
        }

        return returnViews;
    }
852389
public View waitForView(Object tag, int index, int timeout){
		if(timeout == 0){
			timeout = Timeout.getSmallTimeout();
		}
		return waitForView(tag, index, timeout, false);
	}
1073032
public static ViewPosition from(@NonNull View view) {
        ViewPosition pos = new ViewPosition();
        pos.init(view);
        return pos;
    }
1115283
@SuppressWarnings("unchecked")
    public static <T extends View> T get(View view, int id) {
        SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
        if (viewHolder == null) {
            viewHolder = new SparseArray<View>();
            view.setTag(viewHolder);
        }
        View childView = viewHolder.get(id);
        if (childView == null) {
            childView = view.findViewById(id);
            viewHolder.put(id, childView);
        }
        return (T) childView;
    }