@Test public void test_positive_inter_object_delay() { List<SpruceTimedView> resultViews = new ContinuousSort(1, false, RadialSort.Position.TOP_LEFT) .getViewListWithTimeOffsets(mockParent, mockChildren); Assert.assertEquals(0, resultViews.get(0).getTimeOffset()); Assert.assertEquals(1, resultViews.get(1).getTimeOffset()); Assert.assertEquals(1, resultViews.get(2).getTimeOffset()); }
@Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double maxDistance = 0; for (View v1: children) { for (View v2: children) { if (v1 != v2) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(v1), comparisonPoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(v2), comparisonPoint); if (leftDistance > rightDistance && leftDistance > maxDistance) { maxDistance = leftDistance; } } } } List<SpruceTimedView> timedViews = new ArrayList<>(); for (View view : children) { double normalizedDistance; double viewDistance = getDistanceBetweenPoints(Utils.viewToPoint(view), comparisonPoint); if (reversed) { normalizedDistance = (maxDistance - viewDistance) / maxDistance; } else { normalizedDistance = viewDistance / maxDistance; } long offset = Math.round(duration * normalizedDistance); timedViews.add(new SpruceTimedView(view, offset)); } return timedViews; }
ContinuousSort extends RadialSort { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double maxDistance = 0; for (View v1: children) { for (View v2: children) { if (v1 != v2) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(v1), comparisonPoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(v2), comparisonPoint); if (leftDistance > rightDistance && leftDistance > maxDistance) { maxDistance = leftDistance; } } } } List<SpruceTimedView> timedViews = new ArrayList<>(); for (View view : children) { double normalizedDistance; double viewDistance = getDistanceBetweenPoints(Utils.viewToPoint(view), comparisonPoint); if (reversed) { normalizedDistance = (maxDistance - viewDistance) / maxDistance; } else { normalizedDistance = viewDistance / maxDistance; } long offset = Math.round(duration * normalizedDistance); timedViews.add(new SpruceTimedView(view, offset)); } return timedViews; } }
ContinuousSort extends RadialSort { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double maxDistance = 0; for (View v1: children) { for (View v2: children) { if (v1 != v2) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(v1), comparisonPoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(v2), comparisonPoint); if (leftDistance > rightDistance && leftDistance > maxDistance) { maxDistance = leftDistance; } } } } List<SpruceTimedView> timedViews = new ArrayList<>(); for (View view : children) { double normalizedDistance; double viewDistance = getDistanceBetweenPoints(Utils.viewToPoint(view), comparisonPoint); if (reversed) { normalizedDistance = (maxDistance - viewDistance) / maxDistance; } else { normalizedDistance = viewDistance / maxDistance; } long offset = Math.round(duration * normalizedDistance); timedViews.add(new SpruceTimedView(view, offset)); } return timedViews; } ContinuousSort(long interObjectDelay, boolean reversed, Position position); }
ContinuousSort extends RadialSort { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double maxDistance = 0; for (View v1: children) { for (View v2: children) { if (v1 != v2) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(v1), comparisonPoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(v2), comparisonPoint); if (leftDistance > rightDistance && leftDistance > maxDistance) { maxDistance = leftDistance; } } } } List<SpruceTimedView> timedViews = new ArrayList<>(); for (View view : children) { double normalizedDistance; double viewDistance = getDistanceBetweenPoints(Utils.viewToPoint(view), comparisonPoint); if (reversed) { normalizedDistance = (maxDistance - viewDistance) / maxDistance; } else { normalizedDistance = viewDistance / maxDistance; } long offset = Math.round(duration * normalizedDistance); timedViews.add(new SpruceTimedView(view, offset)); } return timedViews; } ContinuousSort(long interObjectDelay, boolean reversed, Position position); @Override List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children); @Override void sortChildren(ViewGroup parent, List<View> children); }
ContinuousSort extends RadialSort { @Override public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) { final PointF comparisonPoint = getDistancePoint(parent, children); double maxDistance = 0; for (View v1: children) { for (View v2: children) { if (v1 != v2) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(v1), comparisonPoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(v2), comparisonPoint); if (leftDistance > rightDistance && leftDistance > maxDistance) { maxDistance = leftDistance; } } } } List<SpruceTimedView> timedViews = new ArrayList<>(); for (View view : children) { double normalizedDistance; double viewDistance = getDistanceBetweenPoints(Utils.viewToPoint(view), comparisonPoint); if (reversed) { normalizedDistance = (maxDistance - viewDistance) / maxDistance; } else { normalizedDistance = viewDistance / maxDistance; } long offset = Math.round(duration * normalizedDistance); timedViews.add(new SpruceTimedView(view, offset)); } return timedViews; } ContinuousSort(long interObjectDelay, boolean reversed, Position position); @Override List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children); @Override void sortChildren(ViewGroup parent, List<View> children);  }