@Test public void test_translate_returns_a_point() { List<View> mockChildren = new ArrayList<>(); mockChildren.add(Mockito.mock(View.class)); DistancedSort distancedSort = new DistancedSort(0, false); Assert.assertThat(distancedSort.translate(new PointF(0, 0), mockChildren), CoreMatchers.instanceOf(PointF.class)); }
PointF translate(final PointF distancePoint, List<View> children) { Collections.sort(children, new Comparator<View>() { @Override public int compare(View left, View right) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(left), distancePoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(right), distancePoint); return Double.compare(leftDistance, rightDistance); } }); return Utils.viewToPoint(children.get(0)); }
DistancedSort extends SortFunction { PointF translate(final PointF distancePoint, List<View> children) { Collections.sort(children, new Comparator<View>() { @Override public int compare(View left, View right) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(left), distancePoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(right), distancePoint); return Double.compare(leftDistance, rightDistance); } }); return Utils.viewToPoint(children.get(0)); } }
DistancedSort extends SortFunction { PointF translate(final PointF distancePoint, List<View> children) { Collections.sort(children, new Comparator<View>() { @Override public int compare(View left, View right) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(left), distancePoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(right), distancePoint); return Double.compare(leftDistance, rightDistance); } }); return Utils.viewToPoint(children.get(0)); } DistancedSort(long interObjectDelay, boolean reversed); }
DistancedSort extends SortFunction { PointF translate(final PointF distancePoint, List<View> children) { Collections.sort(children, new Comparator<View>() { @Override public int compare(View left, View right) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(left), distancePoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(right), distancePoint); return Double.compare(leftDistance, rightDistance); } }); return Utils.viewToPoint(children.get(0)); } 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 { PointF translate(final PointF distancePoint, List<View> children) { Collections.sort(children, new Comparator<View>() { @Override public int compare(View left, View right) { double leftDistance = getDistanceBetweenPoints(Utils.viewToPoint(left), distancePoint); double rightDistance = getDistanceBetweenPoints(Utils.viewToPoint(right), distancePoint); return Double.compare(leftDistance, rightDistance); } }); return Utils.viewToPoint(children.get(0)); } 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);  }