From 85c706a54d61541deda0dd520a0e7768d558ec40 Mon Sep 17 00:00:00 2001 From: Andrey Kulikov Date: Tue, 12 Mar 2019 14:56:19 +0000 Subject: [PATCH] Improve javadocs for ViewGroup.getChildDrawingOrder The explanation with "iteration" was difficult to understand. Rephrased with the use of "drawing order position". Bug: 128029546 Test: N/A Change-Id: I7c93750ea3f85a5f053b3079ade78869894945c3 --- core/java/android/view/ViewGroup.java | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 4dc20d4fad6dd..4964ee1f0d289 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -4284,35 +4284,38 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } /** - * Returns the index of the child to draw for this iteration. Override this + * Converts drawing order position to container position. Override this * if you want to change the drawing order of children. By default, it - * returns i. + * returns drawingPosition. *

* NOTE: In order for this method to be called, you must enable child ordering * first by calling {@link #setChildrenDrawingOrderEnabled(boolean)}. * - * @param i The current iteration. - * @return The index of the child to draw this iteration. + * @param drawingPosition the drawing order position. + * @return the container position of a child for this drawing order position. * * @see #setChildrenDrawingOrderEnabled(boolean) * @see #isChildrenDrawingOrderEnabled() */ - protected int getChildDrawingOrder(int childCount, int i) { - return i; + protected int getChildDrawingOrder(int childCount, int drawingPosition) { + return drawingPosition; } /** - * The public version of getChildDrawingOrder(). + * Converts drawing order position to container position. + *

+ * Children are not necessarily drawn in the order in which they appear in the container. + * ViewGroups can enable a custom ordering via {@link #setChildrenDrawingOrderEnabled(boolean)}. + * This method returns the container position of a child that appears in the given position + * in the current drawing order. * - * Returns the index of the child to draw for this iteration. - * - * @param i The current iteration. - * @return The index of the child to draw this iteration. + * @param drawingPosition the drawing order position. + * @return the container position of a child for this drawing order position. * * @see #getChildDrawingOrder(int, int)} */ - public final int getChildDrawingOrder(int i) { - return getChildDrawingOrder(getChildCount(), i); + public final int getChildDrawingOrder(int drawingPosition) { + return getChildDrawingOrder(getChildCount(), drawingPosition); } private boolean hasChildWithZ() {