@Test public void testCustomExpandCollapseView() { View customExpandCollapse = new ToggleButton(mActivity); customExpandCollapse.setContentDescription(mActivity.getString( R.string.action_bar_expand_collapse_button)); setExpandCollapseCustomView(customExpandCollapse); setUpActionBarItems(NUM_COLS + 1); onView(withContentDescription(R.string.action_bar_expand_collapse_button)) .check((view, noViewFoundException) -> { Preconditions.checkNotNull(view); assertEquals(customExpandCollapse, mActionBar.getViewAt(BOTTOM_ROW_IDX, NUM_COLS - 1)); }); }
@VisibleForTesting @Nullable View getViewAt(int rowIdx, int colIdx) { if (rowIdx < 0 || rowIdx > mRowsContainer.getChildCount()) { throw new IllegalArgumentException(String.format((Locale) null, "Row index out of range (requested: %d, max: %d)", rowIdx, mRowsContainer.getChildCount())); } if (colIdx < 0 || colIdx > mNumColumns) { throw new IllegalArgumentException(String.format((Locale) null, "Column index out of range (requested: %d, max: %d)", colIdx, mNumColumns)); } FrameLayout slot = (FrameLayout) ((LinearLayout) mRowsContainer.getChildAt(rowIdx)) .getChildAt(colIdx + 1); return slot.getChildCount() > 0 ? slot.getChildAt(0) : null; }
ActionBar extends RelativeLayout { @VisibleForTesting @Nullable View getViewAt(int rowIdx, int colIdx) { if (rowIdx < 0 || rowIdx > mRowsContainer.getChildCount()) { throw new IllegalArgumentException(String.format((Locale) null, "Row index out of range (requested: %d, max: %d)", rowIdx, mRowsContainer.getChildCount())); } if (colIdx < 0 || colIdx > mNumColumns) { throw new IllegalArgumentException(String.format((Locale) null, "Column index out of range (requested: %d, max: %d)", colIdx, mNumColumns)); } FrameLayout slot = (FrameLayout) ((LinearLayout) mRowsContainer.getChildAt(rowIdx)) .getChildAt(colIdx + 1); return slot.getChildCount() > 0 ? slot.getChildAt(0) : null; } }
ActionBar extends RelativeLayout { @VisibleForTesting @Nullable View getViewAt(int rowIdx, int colIdx) { if (rowIdx < 0 || rowIdx > mRowsContainer.getChildCount()) { throw new IllegalArgumentException(String.format((Locale) null, "Row index out of range (requested: %d, max: %d)", rowIdx, mRowsContainer.getChildCount())); } if (colIdx < 0 || colIdx > mNumColumns) { throw new IllegalArgumentException(String.format((Locale) null, "Column index out of range (requested: %d, max: %d)", colIdx, mNumColumns)); } FrameLayout slot = (FrameLayout) ((LinearLayout) mRowsContainer.getChildAt(rowIdx)) .getChildAt(colIdx + 1); return slot.getChildCount() > 0 ? slot.getChildAt(0) : null; } ActionBar(Context context);  ActionBar(Context context, AttributeSet attrs);  ActionBar(Context context, AttributeSet attrs, int defStyleAttrs);  ActionBar(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes); }
ActionBar extends RelativeLayout { @VisibleForTesting @Nullable View getViewAt(int rowIdx, int colIdx) { if (rowIdx < 0 || rowIdx > mRowsContainer.getChildCount()) { throw new IllegalArgumentException(String.format((Locale) null, "Row index out of range (requested: %d, max: %d)", rowIdx, mRowsContainer.getChildCount())); } if (colIdx < 0 || colIdx > mNumColumns) { throw new IllegalArgumentException(String.format((Locale) null, "Column index out of range (requested: %d, max: %d)", colIdx, mNumColumns)); } FrameLayout slot = (FrameLayout) ((LinearLayout) mRowsContainer.getChildAt(rowIdx)) .getChildAt(colIdx + 1); return slot.getChildCount() > 0 ? slot.getChildAt(0) : null; } ActionBar(Context context);  ActionBar(Context context, AttributeSet attrs);  ActionBar(Context context, AttributeSet attrs, int defStyleAttrs);  ActionBar(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes); void setView(@Nullable View view, @SlotPosition int slotPosition); void setExpandCollapseView(@NonNull View view); void setViews(@Nullable View[] views); }
ActionBar extends RelativeLayout { @VisibleForTesting @Nullable View getViewAt(int rowIdx, int colIdx) { if (rowIdx < 0 || rowIdx > mRowsContainer.getChildCount()) { throw new IllegalArgumentException(String.format((Locale) null, "Row index out of range (requested: %d, max: %d)", rowIdx, mRowsContainer.getChildCount())); } if (colIdx < 0 || colIdx > mNumColumns) { throw new IllegalArgumentException(String.format((Locale) null, "Column index out of range (requested: %d, max: %d)", colIdx, mNumColumns)); } FrameLayout slot = (FrameLayout) ((LinearLayout) mRowsContainer.getChildAt(rowIdx)) .getChildAt(colIdx + 1); return slot.getChildCount() > 0 ? slot.getChildAt(0) : null; } ActionBar(Context context);  ActionBar(Context context, AttributeSet attrs);  ActionBar(Context context, AttributeSet attrs, int defStyleAttrs);  ActionBar(Context context, AttributeSet attrs, int defStyleAttrs, int defStyleRes); void setView(@Nullable View view, @SlotPosition int slotPosition); void setExpandCollapseView(@NonNull View view); void setViews(@Nullable View[] views); static final int SLOT_MAIN; static final int SLOT_LEFT; static final int SLOT_RIGHT; static final int SLOT_EXPAND_COLLAPSE; }