Lines Matching refs:item

78         // Adds an item at the top-left quarter of the custom view.
81 // Adds an item at the bottom-right quarter of the custom view.
85 // Add an item at the bottom quarter of Item B.
90 // Add an item at the left quarter of Item C.
99 * Simple custom view that draws rectangular items to the screen. Each item
100 * has a checked state that may be toggled by tapping on the item.
146 * Adds an item to the custom view. The item is positioned relative to
149 * @param description The item's description.
161 final CustomItem item = new CustomItem();
162 item.mId = mItems.size();
163 item.mBounds = new RectF(left, top, right, bottom);
164 item.mDescription = description;
165 item.mChecked = false;
166 mItems.add(item);
167 return item;
173 * @param item CustomItem that will become a child node.
176 public void setParentItem(CustomItem item, CustomItem parent) {
177 item.mParent = parent;
178 parent.mChildren.add(item.mId);
182 * Walk the view hierarchy of each item and calculate mBoundsInRoot.
185 for (CustomItem item : mItems) {
186 layoutItem(item);
190 void layoutItem(CustomItem item) {
191 item.mBoundsInRoot = new RectF(item.mBounds);
192 CustomItem parent = item.mParent;
194 RectF bounds = item.mBoundsInRoot;
195 item.mBoundsInRoot.set(parent.mBounds.left + bounds.left * parent.mBounds.width(),
212 for (CustomItem item : mItems) {
213 if (item.mParent == null) {
214 paint.setColor(item.mChecked ? Color.RED : Color.BLUE);
216 paint.setColor(item.mChecked ? Color.MAGENTA : Color.GREEN);
219 scaleRectF(item.mBoundsInRoot, bounds, width, height);
223 canvas.drawText(item.mDescription, bounds.centerX(), bounds.centerY(), paint);
228 final CustomItem item = getItem(index);
229 if (item == null) {
233 item.mChecked = !item.mChecked;
236 // Since the item's checked state is exposed to accessibility
238 // the item's virtual view. At some point in the future, the
257 final CustomItem item = mItems.get(i);
258 if (item.mBoundsInRoot.contains(scaledX, scaledY)) {
303 // Since every item should be visible, and since we're mapping
304 // directly from item index to virtual view id, we can add
317 final CustomItem item = getItem(virtualViewId);
318 if (item == null) {
323 // getText().add() or setContentDescription(). Since the item's
327 event.getText().add(item.mDescription);
333 final CustomItem item = getItem(virtualViewId);
334 if (item == null) {
340 node.setText(item.mDescription);
343 // the item in onDraw(). They should also be consistent with the
349 if (item.mParent != null) {
350 width = (int) (width * item.mParent.mBoundsInRoot.width());
351 height = (int) (height * item.mParent.mBoundsInRoot.height());
353 scaleRectF(item.mBounds, bounds, width, height);
356 // Since the user can tap an item, add the CLICK action. We'll
360 // This item has a checked state.
362 node.setChecked(item.mChecked);
365 if (item.mParent != null) {
366 node.setParent(CustomView.this, item.mParent.mId);
368 for (Integer id : item.mChildren) {