private void setupPreviousMountableOutputData(LayoutState layoutState, Rect localVisibleRect) { if (localVisibleRect.isEmpty()) { return; } final ArrayList<LayoutOutput> layoutOutputTops = layoutState.getMountableOutputTops(); final ArrayList<LayoutOutput> layoutOutputBottoms = layoutState.getMountableOutputBottoms(); final int mountableOutputCount = layoutState.getMountableOutputCount(); mPreviousTopsIndex = layoutState.getMountableOutputCount(); for (int i = 0; i < mountableOutputCount; i++) { if (localVisibleRect.bottom <= layoutOutputTops.get(i).getBounds().top) { mPreviousTopsIndex = i; break; } } mPreviousBottomsIndex = layoutState.getMountableOutputCount(); for (int i = 0; i < mountableOutputCount; i++) { if (localVisibleRect.top < layoutOutputBottoms.get(i).getBounds().bottom) { mPreviousBottomsIndex = i; break; } } }
assertThat(layoutState.getMountableOutputTops().get(3).getBounds().top).isEqualTo(0); assertThat(layoutState.getMountableOutputBottoms().get(0).getBounds().bottom).isEqualTo(50); assertThat(layoutState.getMountableOutputBottoms().get(1).getBounds().bottom).isEqualTo(50); assertThat(layoutState.getMountableOutputBottoms().get(2).getBounds().bottom).isEqualTo(50); assertThat(layoutState.getMountableOutputBottoms().get(3).getBounds().bottom).isEqualTo(50); .isSameAs(layoutState.getMountableOutputBottoms().get(3)); assertThat(layoutState.getMountableOutputAt(1)) .isSameAs(layoutState.getMountableOutputBottoms().get(2)); assertThat(layoutState.getMountableOutputAt(2)) .isSameAs(layoutState.getMountableOutputBottoms().get(1)); assertThat(layoutState.getMountableOutputAt(3)) .isSameAs(layoutState.getMountableOutputBottoms().get(0));
assertThat(layoutState.getMountableOutputTops().get(4).getBounds().top).isEqualTo(50); assertThat(layoutState.getMountableOutputBottoms().get(0).getBounds().bottom).isEqualTo(40); assertThat(layoutState.getMountableOutputBottoms().get(1).getBounds().bottom).isEqualTo(50); assertThat(layoutState.getMountableOutputBottoms().get(2).getBounds().bottom).isEqualTo(50); assertThat(layoutState.getMountableOutputBottoms().get(3).getBounds().bottom).isEqualTo(70); assertThat(layoutState.getMountableOutputBottoms().get(4).getBounds().bottom).isEqualTo(70); .isSameAs(layoutState.getMountableOutputBottoms().get(0)); assertThat(layoutState.getMountableOutputAt(2)) .isSameAs(layoutState.getMountableOutputBottoms().get(1)); assertThat(layoutState.getMountableOutputAt(1)) .isSameAs(layoutState.getMountableOutputBottoms().get(2)); assertThat(layoutState.getMountableOutputAt(3)) .isSameAs(layoutState.getMountableOutputBottoms().get(3)); assertThat(layoutState.getMountableOutputAt(0)) .isSameAs(layoutState.getMountableOutputBottoms().get(4));
final ArrayList<LayoutOutput> layoutOutputBottoms = layoutState.getMountableOutputBottoms(); final int count = layoutState.getMountableOutputCount();