private int[] createReorderedIndices(View viewBeforeAdded, int indexForViewBeforeAdded,
            ViewGroup.LayoutParams paramsForViewBeforeAdded) {
        int childCount = getChildCount();
        List<Order> orders = createOrders(childCount);
        Order orderForViewToBeAdded = new Order();
        if (viewBeforeAdded != null
                && paramsForViewBeforeAdded instanceof FlexboxLayout.LayoutParams) {
            orderForViewToBeAdded.order = ((LayoutParams) paramsForViewBeforeAdded).order;
        } else {
            orderForViewToBeAdded.order = LayoutParams.ORDER_DEFAULT;
        }

        if (indexForViewBeforeAdded == -1 || indexForViewBeforeAdded == childCount) {
            orderForViewToBeAdded.index = childCount;
        } else if (indexForViewBeforeAdded < getChildCount()) {
            orderForViewToBeAdded.index = indexForViewBeforeAdded;
            for (int i = indexForViewBeforeAdded; i < childCount; i++) {
                orders.get(i).index++;
            }
        } else {
            // This path is not expected since OutOfBoundException will be thrown in the ViewGroup
            // But setting the index for fail-safe
            orderForViewToBeAdded.index = childCount;
        }
        orders.add(orderForViewToBeAdded);

        return sortOrdersIntoReorderedIndices(childCount + 1, orders);
    }
Create an array, which indicates the reordered indices that {@link LayoutParams#order}
attributes are taken into account. This method takes a View before that is added as the
parent ViewGroup's children.

@param viewBeforeAdded          the View instance before added to the array of children
                                Views of the parent ViewGroup
@param indexForViewBeforeAdded  the index for the View before added to the array of the
                                parent ViewGroup
@param paramsForViewBeforeAdded the layout parameters for the View before added to the array
                                of the parent ViewGroup
@return an array which have the reordered indices
common/src/main/java/com/sxjs/common/widget/flexboxlayout/FlexboxLayout.java