private static void populateEventFromJSON(AccessibilityEvent event, JSONObject message) { final JSONArray textArray = message.optJSONArray("text"); if (textArray != null) { for (int i = 0; i < textArray.length(); i++) event.getText().add(textArray.optString(i)); } event.setContentDescription(message.optString("description")); event.setEnabled(message.optBoolean("enabled", true)); event.setChecked(message.optBoolean("checked")); event.setPassword(message.optBoolean("password")); event.setAddedCount(message.optInt("addedCount", -1)); event.setRemovedCount(message.optInt("removedCount", -1)); event.setFromIndex(message.optInt("fromIndex", -1)); event.setItemCount(message.optInt("itemCount", -1)); event.setCurrentItemIndex(message.optInt("currentItemIndex", -1)); event.setBeforeText(message.optString("beforeText")); if (Versions.feature14Plus) { event.setToIndex(message.optInt("toIndex", -1)); event.setScrollable(message.optBoolean("scrollable")); event.setScrollX(message.optInt("scrollX", -1)); event.setScrollY(message.optInt("scrollY", -1)); } if (Versions.feature15Plus) { event.setMaxScrollX(message.optInt("maxScrollX", -1)); event.setMaxScrollY(message.optInt("maxScrollY", -1)); } }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); int childCount = getChildCount(); if (childCount > 0) { DeckChildView<T> backMostTask = (DeckChildView) getChildAt(0); DeckChildView<T> frontMostTask = (DeckChildView) getChildAt(childCount - 1); event.setFromIndex(mCallback.getData().indexOf(backMostTask.getAttachedKey())); event.setToIndex(mCallback.getData().indexOf(frontMostTask.getAttachedKey())); } event.setItemCount(mCallback.getData().size()); event.setScrollY(mStackScroller.mScroller.getCurrY()); event.setMaxScrollY(mStackScroller.progressToScrollRange(mLayoutAlgorithm.mMaxScrollP)); }
@Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); int childCount = getChildCount(); if (childCount > 0) { TaskView backMostTask = (TaskView) getChildAt(0); TaskView frontMostTask = (TaskView) getChildAt(childCount - 1); event.setFromIndex(mStack.indexOfTask(backMostTask.getTask())); event.setToIndex(mStack.indexOfTask(frontMostTask.getTask())); event.setContentDescription(frontMostTask.getTask().activityLabel); } event.setItemCount(mStack.getTaskCount()); event.setScrollY(mStackScroller.mScroller.getCurrY()); event.setMaxScrollY(mStackScroller.progressToScrollRange(mLayoutAlgorithm.mMaxScrollP)); }