@Test public void test_positive_inter_object_delay() { List<SpruceTimedView> resultViews = new DistancedSort(1, false) .getViewListWithTimeOffsets(mockParent, mockChildren); Assert.assertEquals(0, resultViews.get(0).getTimeOffset()); Assert.assertEquals(1, resultViews.get(1).getTimeOffset()); Assert.assertEquals(2, resultViews.get(2).getTimeOffset()); }
@Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(children.get(0)), comparisonPoint); long currentTimeOffset = 0L; List<SpruceTimedView> childViews = new ArrayList<>(); for (View childView : children) { if (lastDistance != getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint)) { lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint); currentTimeOffset += interObjectDelay; } childViews.add(new SpruceTimedView(childView, currentTimeOffset)); } return childViews; }
DistancedSort extends SortFunction { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(children.get(0)), comparisonPoint); long currentTimeOffset = 0L; List<SpruceTimedView> childViews = new ArrayList<>(); for (View childView : children) { if (lastDistance != getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint)) { lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint); currentTimeOffset += interObjectDelay; } childViews.add(new SpruceTimedView(childView, currentTimeOffset)); } return childViews; } }
DistancedSort extends SortFunction { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(children.get(0)), comparisonPoint); long currentTimeOffset = 0L; List<SpruceTimedView> childViews = new ArrayList<>(); for (View childView : children) { if (lastDistance != getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint)) { lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint); currentTimeOffset += interObjectDelay; } childViews.add(new SpruceTimedView(childView, currentTimeOffset)); } return childViews; } DistancedSort(long interObjectDelay, boolean reversed); }
DistancedSort extends SortFunction { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(children.get(0)), comparisonPoint); long currentTimeOffset = 0L; List<SpruceTimedView> childViews = new ArrayList<>(); for (View childView : children) { if (lastDistance != getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint)) { lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint); currentTimeOffset += interObjectDelay; } childViews.add(new SpruceTimedView(childView, currentTimeOffset)); } return childViews; } DistancedSort(long interObjectDelay, boolean reversed); @Override List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children); @Override void sortChildren(ViewGroup parent, List<View> children); PointF getDistancePoint(ViewGroup parent, List<View> children); double getDistanceBetweenPoints(PointF left, PointF right); }
DistancedSort extends SortFunction { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(children.get(0)), comparisonPoint); long currentTimeOffset = 0L; List<SpruceTimedView> childViews = new ArrayList<>(); for (View childView : children) { if (lastDistance != getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint)) { lastDistance = getDistanceBetweenPoints(Utils.viewToPoint(childView), comparisonPoint); currentTimeOffset += interObjectDelay; } childViews.add(new SpruceTimedView(childView, currentTimeOffset)); } return childViews; } DistancedSort(long interObjectDelay, boolean reversed); @Override List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children); @Override void sortChildren(ViewGroup parent, List<View> children); PointF getDistancePoint(ViewGroup parent, List<View> children); double getDistanceBetweenPoints(PointF left, PointF right);  }