Search in sources :

Example 21 with OrientationHelperEx

use of com.alibaba.android.vlayout.OrientationHelperEx in project vlayout by alibaba.

the class OnePlusNLayoutHelper method handleFive.

private int handleFive(LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper, boolean layoutInVertical, int parentWidth, int parentHeight, int parentHPadding, int parentVPadding) {
    int mainConsumed = 0;
    OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
    final View child1 = mChildrenViews[0];
    final VirtualLayoutManager.LayoutParams lp1 = (VirtualLayoutManager.LayoutParams) child1.getLayoutParams();
    final View child2 = helper.getReverseLayout() ? mChildrenViews[4] : mChildrenViews[1];
    final VirtualLayoutManager.LayoutParams lp2 = (VirtualLayoutManager.LayoutParams) child2.getLayoutParams();
    final View child3 = helper.getReverseLayout() ? mChildrenViews[3] : mChildrenViews[2];
    final VirtualLayoutManager.LayoutParams lp3 = (VirtualLayoutManager.LayoutParams) child3.getLayoutParams();
    final View child4 = helper.getReverseLayout() ? mChildrenViews[2] : mChildrenViews[3];
    final VirtualLayoutManager.LayoutParams lp4 = (VirtualLayoutManager.LayoutParams) child4.getLayoutParams();
    final View child5 = helper.getReverseLayout() ? mChildrenViews[1] : mChildrenViews[4];
    final VirtualLayoutManager.LayoutParams lp5 = (VirtualLayoutManager.LayoutParams) child5.getLayoutParams();
    final float weight1 = getViewMainWeight(0);
    final float weight2 = getViewMainWeight(1);
    final float weight3 = getViewMainWeight(2);
    final float weight4 = getViewMainWeight(3);
    final float weight5 = getViewMainWeight(4);
    if (layoutInVertical) {
        lp2.topMargin = lp1.topMargin;
        lp3.bottomMargin = lp4.bottomMargin = lp1.bottomMargin;
        lp3.leftMargin = lp2.leftMargin;
        lp4.rightMargin = lp2.rightMargin;
        lp5.rightMargin = lp2.rightMargin;
        if (!Float.isNaN(mAspectRatio)) {
            lp1.height = (int) ((parentWidth - parentHPadding) / mAspectRatio);
        }
        int availableSpace = parentWidth - parentHPadding - lp1.leftMargin - lp1.rightMargin - lp2.leftMargin - lp2.rightMargin;
        int width1 = Float.isNaN(weight1) ? (int) (availableSpace / 2.0f + 0.5f) : (int) (availableSpace * weight1 / 100 + 0.5f);
        int width2 = Float.isNaN(weight2) ? (int) (availableSpace - width1) : (int) (availableSpace * weight2 / 100 + 0.5f);
        int width3 = Float.isNaN(weight3) ? (int) ((width2 - lp3.rightMargin - lp4.leftMargin) / 3.0f + 0.5f) : (int) (availableSpace * weight3 / 100 + 0.5f);
        int width4 = Float.isNaN(weight4) ? (int) ((width2 - lp3.rightMargin - lp4.leftMargin) / 3.0f + 0.5f) : (int) (availableSpace * weight4 / 100 + 0.5f);
        int width5 = Float.isNaN(weight5) ? (int) ((width2 - lp3.rightMargin - lp4.leftMargin - width3 - width4)) : (int) (availableSpace * weight5 / 100 + 0.5f);
        helper.measureChildWithMargins(child1, MeasureSpec.makeMeasureSpec(width1 + lp1.leftMargin + lp1.rightMargin, MeasureSpec.EXACTLY), helper.getChildMeasureSpec(helper.getContentHeight(), lp1.height, true));
        int height1 = child1.getMeasuredHeight();
        int height2 = Float.isNaN(mRowWeight) ? (int) ((height1 - lp2.bottomMargin - lp3.topMargin) / 2.0f + 0.5f) : (int) ((height1 - lp2.bottomMargin - lp3.topMargin) * mRowWeight / 100 + 0.5f);
        int height3 = (int) ((height1 - lp2.bottomMargin - lp3.topMargin) - height2);
        helper.measureChildWithMargins(child2, MeasureSpec.makeMeasureSpec(width2 + lp2.leftMargin + lp2.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height2 + lp2.topMargin + lp2.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child3, MeasureSpec.makeMeasureSpec(width3 + lp3.leftMargin + lp3.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp3.topMargin + lp3.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child4, MeasureSpec.makeMeasureSpec(width4 + lp4.leftMargin + lp4.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp4.topMargin + lp4.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child5, MeasureSpec.makeMeasureSpec(width5 + lp5.leftMargin + lp5.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp5.topMargin + lp5.bottomMargin, MeasureSpec.EXACTLY));
        mainConsumed += Math.max(height1 + lp1.topMargin + lp1.bottomMargin, height2 + lp2.topMargin + lp2.bottomMargin + Math.max(height3 + lp3.topMargin + lp3.bottomMargin, height3 + lp4.topMargin + lp4.bottomMargin));
        calculateRect(mainConsumed, mAreaRect, layoutState, helper);
        int right1 = mAreaRect.left + orientationHelper.getDecoratedMeasurementInOther(child1);
        layoutChildWithMargin(child1, mAreaRect.left, mAreaRect.top, right1, mAreaRect.bottom, helper);
        int right2 = right1 + orientationHelper.getDecoratedMeasurementInOther(child2);
        layoutChildWithMargin(child2, right1, mAreaRect.top, right2, mAreaRect.top + orientationHelper.getDecoratedMeasurement(child2), helper);
        int right3 = right1 + orientationHelper.getDecoratedMeasurementInOther(child3);
        layoutChildWithMargin(child3, right1, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child3), right3, mAreaRect.bottom, helper);
        int right4 = right3 + orientationHelper.getDecoratedMeasurementInOther(child4);
        layoutChildWithMargin(child4, right3, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child4), right3 + orientationHelper.getDecoratedMeasurementInOther(child4), mAreaRect.bottom, helper);
        layoutChildWithMargin(child5, right4, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child5), right4 + orientationHelper.getDecoratedMeasurementInOther(child5), mAreaRect.bottom, helper);
        mainConsumed = mAreaRect.bottom - mAreaRect.top + (hasHeader ? 0 : mMarginTop + mPaddingTop) + (hasFooter ? 0 : mMarginBottom + mPaddingBottom);
    } else {
    // TODO: horizontal support
    }
    handleStateOnResult(result, mChildrenViews);
    return mainConsumed;
}
Also used : LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) OrientationHelperEx(com.alibaba.android.vlayout.OrientationHelperEx) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 22 with OrientationHelperEx

use of com.alibaba.android.vlayout.OrientationHelperEx in project vlayout by alibaba.

the class OnePlusNLayoutHelper method handleFour.

private int handleFour(LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper, boolean layoutInVertical, int parentWidth, int parentHeight, int parentHPadding, int parentVPadding) {
    int mainConsumed = 0;
    OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
    final View child1 = mChildrenViews[0];
    final VirtualLayoutManager.LayoutParams lp1 = (VirtualLayoutManager.LayoutParams) child1.getLayoutParams();
    final View child2 = helper.getReverseLayout() ? mChildrenViews[3] : mChildrenViews[1];
    final VirtualLayoutManager.LayoutParams lp2 = (VirtualLayoutManager.LayoutParams) child2.getLayoutParams();
    final View child3 = mChildrenViews[2];
    final VirtualLayoutManager.LayoutParams lp3 = (VirtualLayoutManager.LayoutParams) child3.getLayoutParams();
    final View child4 = helper.getReverseLayout() ? mChildrenViews[1] : mChildrenViews[3];
    final VirtualLayoutManager.LayoutParams lp4 = (VirtualLayoutManager.LayoutParams) child4.getLayoutParams();
    final float weight1 = getViewMainWeight(0);
    final float weight2 = getViewMainWeight(1);
    final float weight3 = getViewMainWeight(2);
    final float weight4 = getViewMainWeight(3);
    if (layoutInVertical) {
        lp2.topMargin = lp1.topMargin;
        lp3.bottomMargin = lp4.bottomMargin = lp1.bottomMargin;
        lp3.leftMargin = lp2.leftMargin;
        lp4.rightMargin = lp2.rightMargin;
        if (!Float.isNaN(mAspectRatio)) {
            lp1.height = (int) ((parentWidth - parentHPadding) / mAspectRatio);
        }
        int availableSpace = parentWidth - parentHPadding - lp1.leftMargin - lp1.rightMargin - lp2.leftMargin - lp2.rightMargin;
        int width1 = Float.isNaN(weight1) ? (int) (availableSpace / 2.0f + 0.5f) : (int) (availableSpace * weight1 / 100 + 0.5f);
        int width2 = Float.isNaN(weight2) ? (int) (availableSpace - width1) : (int) (availableSpace * weight2 / 100 + 0.5f);
        int width3 = Float.isNaN(weight3) ? (int) ((width2 - lp3.rightMargin - lp4.leftMargin) / 2.0f + 0.5f) : (int) (availableSpace * weight3 / 100 + 0.5f);
        int width4 = Float.isNaN(weight4) ? (int) ((width2 - lp3.rightMargin - lp4.leftMargin - width3)) : (int) (availableSpace * weight4 / 100 + 0.5f);
        helper.measureChildWithMargins(child1, MeasureSpec.makeMeasureSpec(width1 + lp1.leftMargin + lp1.rightMargin, MeasureSpec.EXACTLY), helper.getChildMeasureSpec(helper.getContentHeight(), lp1.height, true));
        int height1 = child1.getMeasuredHeight();
        int height2 = Float.isNaN(mRowWeight) ? (int) ((height1 - lp2.bottomMargin - lp3.topMargin) / 2.0f + 0.5f) : (int) ((height1 - lp2.bottomMargin - lp3.topMargin) * mRowWeight / 100 + 0.5f);
        int height3 = (int) ((height1 - lp2.bottomMargin - lp3.topMargin) - height2);
        helper.measureChildWithMargins(child2, MeasureSpec.makeMeasureSpec(width2 + lp2.leftMargin + lp2.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height2 + lp2.topMargin + lp2.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child3, MeasureSpec.makeMeasureSpec(width3 + lp3.leftMargin + lp3.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp3.topMargin + lp3.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child4, MeasureSpec.makeMeasureSpec(width4 + lp4.leftMargin + lp4.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp4.topMargin + lp4.bottomMargin, MeasureSpec.EXACTLY));
        mainConsumed += Math.max(height1 + lp1.topMargin + lp1.bottomMargin, height2 + lp2.topMargin + lp2.bottomMargin + Math.max(height3 + lp3.topMargin + lp3.bottomMargin, height3 + lp4.topMargin + lp4.bottomMargin));
        calculateRect(mainConsumed, mAreaRect, layoutState, helper);
        int right1 = mAreaRect.left + orientationHelper.getDecoratedMeasurementInOther(child1);
        layoutChildWithMargin(child1, mAreaRect.left, mAreaRect.top, right1, mAreaRect.bottom, helper);
        int right2 = right1 + orientationHelper.getDecoratedMeasurementInOther(child2);
        layoutChildWithMargin(child2, right1, mAreaRect.top, right2, mAreaRect.top + orientationHelper.getDecoratedMeasurement(child2), helper);
        int right3 = right1 + orientationHelper.getDecoratedMeasurementInOther(child3);
        layoutChildWithMargin(child3, right1, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child3), right3, mAreaRect.bottom, helper);
        layoutChildWithMargin(child4, right3, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child4), right3 + orientationHelper.getDecoratedMeasurementInOther(child4), mAreaRect.bottom, helper);
        mainConsumed = mAreaRect.bottom - mAreaRect.top + (hasHeader ? 0 : mMarginTop + mPaddingTop) + (hasFooter ? 0 : mMarginBottom + mPaddingBottom);
    } else {
    // TODO: horizontal support
    }
    handleStateOnResult(result, mChildrenViews);
    return mainConsumed;
}
Also used : LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) OrientationHelperEx(com.alibaba.android.vlayout.OrientationHelperEx) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 23 with OrientationHelperEx

use of com.alibaba.android.vlayout.OrientationHelperEx in project vlayout by alibaba.

the class OnePlusNLayoutHelper method handleOne.

private int handleOne(LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper, boolean layoutInVertical, int parentWidth, int parentHeight, int parentHPadding, int parentVPadding) {
    int mainConsumed = 0;
    OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
    View view = mChildrenViews[0];
    final VirtualLayoutManager.LayoutParams lp = (LayoutParams) view.getLayoutParams();
    if (!Float.isNaN(mAspectRatio)) {
        if (layoutInVertical) {
            lp.height = (int) ((parentWidth - parentHPadding) / mAspectRatio);
        } else {
            lp.width = (int) ((parentHeight - parentVPadding) * mAspectRatio);
        }
    }
    final float weight = getViewMainWeight(0);
    // fill width
    int widthSpec = helper.getChildMeasureSpec(Float.isNaN(weight) ? (parentWidth - parentHPadding) : (int) ((parentWidth - parentHPadding) * weight), layoutInVertical ? MATCH_PARENT : lp.width, !layoutInVertical);
    int heightSpec = helper.getChildMeasureSpec(parentHeight - parentVPadding, layoutInVertical ? lp.height : MeasureSpec.EXACTLY, layoutInVertical);
    helper.measureChildWithMargins(view, widthSpec, heightSpec);
    mainConsumed += orientationHelper.getDecoratedMeasurement(view);
    calculateRect(mainConsumed, mAreaRect, layoutState, helper);
    layoutChildWithMargin(view, mAreaRect.left, mAreaRect.top, mAreaRect.right, mAreaRect.bottom, helper);
    handleStateOnResult(result, view);
    mainConsumed = mAreaRect.bottom - mAreaRect.top + (hasHeader ? 0 : mMarginTop + mPaddingTop) + (hasFooter ? 0 : mMarginBottom + mPaddingBottom);
    return mainConsumed;
}
Also used : LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) OrientationHelperEx(com.alibaba.android.vlayout.OrientationHelperEx) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 24 with OrientationHelperEx

use of com.alibaba.android.vlayout.OrientationHelperEx in project vlayout by alibaba.

the class OnePlusNLayoutHelper method handleThree.

private int handleThree(LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper, boolean layoutInVertical, int parentWidth, int parentHeight, int parentHPadding, int parentVPadding) {
    int mainConsumed = 0;
    OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
    final View child1 = mChildrenViews[0];
    final VirtualLayoutManager.LayoutParams lp1 = (VirtualLayoutManager.LayoutParams) child1.getLayoutParams();
    final View child2 = helper.getReverseLayout() ? mChildrenViews[2] : mChildrenViews[1];
    final View child3 = helper.getReverseLayout() ? mChildrenViews[1] : mChildrenViews[2];
    final VirtualLayoutManager.LayoutParams lp2 = (VirtualLayoutManager.LayoutParams) child2.getLayoutParams();
    final VirtualLayoutManager.LayoutParams lp3 = (VirtualLayoutManager.LayoutParams) child3.getLayoutParams();
    final float weight1 = getViewMainWeight(0);
    final float weight2 = getViewMainWeight(1);
    final float weight3 = getViewMainWeight(2);
    if (layoutInVertical) {
        if (!Float.isNaN(mAspectRatio)) {
            lp1.height = (int) ((parentWidth - parentHPadding) / mAspectRatio);
        }
        // make border consistent
        lp2.topMargin = lp1.topMargin;
        lp3.bottomMargin = lp1.bottomMargin;
        lp3.leftMargin = lp2.leftMargin;
        lp3.rightMargin = lp2.rightMargin;
        int availableSpace = parentWidth - parentHPadding - lp1.leftMargin - lp1.rightMargin - lp2.leftMargin - lp2.rightMargin;
        int width1 = Float.isNaN(weight1) ? (int) (availableSpace / 2.0f + 0.5f) : (int) (availableSpace * weight1 / 100 + 0.5f);
        int width2 = Float.isNaN(weight2) ? (int) (availableSpace - width1) : (int) (availableSpace * weight2 / 100 + 0.5);
        int width3 = Float.isNaN(weight3) ? (int) (width2) : (int) (availableSpace * weight3 / 100 + 0.5);
        helper.measureChildWithMargins(child1, MeasureSpec.makeMeasureSpec(width1 + lp1.leftMargin + lp1.rightMargin, MeasureSpec.EXACTLY), helper.getChildMeasureSpec(helper.getContentHeight(), lp1.height, true));
        int height1 = child1.getMeasuredHeight();
        int height2 = Float.isNaN(mRowWeight) ? (int) ((height1 - lp2.bottomMargin - lp3.topMargin) / 2.0f + 0.5f) : (int) ((height1 - lp2.bottomMargin - lp3.topMargin) * mRowWeight / 100 + 0.5f);
        int height3 = height1 - lp2.bottomMargin - lp3.topMargin - height2;
        helper.measureChildWithMargins(child2, MeasureSpec.makeMeasureSpec(width2 + lp2.leftMargin + lp2.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height2 + lp2.topMargin + lp2.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child3, MeasureSpec.makeMeasureSpec(width3 + lp3.leftMargin + lp3.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp3.topMargin + lp3.bottomMargin, MeasureSpec.EXACTLY));
        mainConsumed += Math.max(height1 + lp1.topMargin + lp1.bottomMargin, height2 + lp2.topMargin + lp2.bottomMargin + height3 + lp3.topMargin + lp3.bottomMargin);
        calculateRect(mainConsumed, mAreaRect, layoutState, helper);
        int right1 = mAreaRect.left + orientationHelper.getDecoratedMeasurementInOther(child1);
        layoutChildWithMargin(child1, mAreaRect.left, mAreaRect.top, right1, mAreaRect.bottom, helper);
        int right2 = right1 + orientationHelper.getDecoratedMeasurementInOther(child2);
        layoutChildWithMargin(child2, right1, mAreaRect.top, right2, mAreaRect.top + child2.getMeasuredHeight() + lp2.topMargin + lp2.bottomMargin, helper);
        layoutChildWithMargin(child3, right1, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child3), right1 + orientationHelper.getDecoratedMeasurementInOther(child3), mAreaRect.bottom, helper);
        mainConsumed = mAreaRect.bottom - mAreaRect.top + (hasHeader ? 0 : mMarginTop + mPaddingTop) + (hasFooter ? 0 : mMarginBottom + mPaddingBottom);
    } else {
    // TODO: horizontal support
    }
    handleStateOnResult(result, mChildrenViews);
    return mainConsumed;
}
Also used : LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) LayoutParams(com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams) OrientationHelperEx(com.alibaba.android.vlayout.OrientationHelperEx) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 25 with OrientationHelperEx

use of com.alibaba.android.vlayout.OrientationHelperEx in project vlayout by alibaba.

the class OnePlusNLayoutHelperEx method handSix.

private int handSix(LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper, boolean layoutInVertical, int parentWidth, int parentHeight, int parentHPadding, int parentVPadding) {
    int mainConsumed = 0;
    OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
    final View child1 = mChildrenViews[0];
    final VirtualLayoutManager.LayoutParams lp1 = (VirtualLayoutManager.LayoutParams) child1.getLayoutParams();
    final View child2 = helper.getReverseLayout() ? mChildrenViews[5] : mChildrenViews[1];
    final VirtualLayoutManager.LayoutParams lp2 = (VirtualLayoutManager.LayoutParams) child2.getLayoutParams();
    final View child3 = helper.getReverseLayout() ? mChildrenViews[4] : mChildrenViews[2];
    final VirtualLayoutManager.LayoutParams lp3 = (VirtualLayoutManager.LayoutParams) child3.getLayoutParams();
    final View child4 = helper.getReverseLayout() ? mChildrenViews[3] : mChildrenViews[3];
    final VirtualLayoutManager.LayoutParams lp4 = (VirtualLayoutManager.LayoutParams) child4.getLayoutParams();
    final View child5 = helper.getReverseLayout() ? mChildrenViews[2] : mChildrenViews[4];
    final VirtualLayoutManager.LayoutParams lp5 = (VirtualLayoutManager.LayoutParams) child5.getLayoutParams();
    final View child6 = helper.getReverseLayout() ? mChildrenViews[1] : mChildrenViews[5];
    final VirtualLayoutManager.LayoutParams lp6 = (VirtualLayoutManager.LayoutParams) child6.getLayoutParams();
    final float weight1 = getViewMainWeight(0);
    final float weight2 = getViewMainWeight(1);
    final float weight3 = getViewMainWeight(2);
    final float weight4 = getViewMainWeight(3);
    final float weight5 = getViewMainWeight(4);
    final float weight6 = getViewMainWeight(5);
    if (layoutInVertical) {
        lp2.topMargin = lp1.topMargin;
        lp3.bottomMargin = lp4.bottomMargin = lp1.bottomMargin;
        lp3.leftMargin = lp2.leftMargin;
        lp4.rightMargin = lp2.rightMargin;
        lp5.rightMargin = lp2.rightMargin;
        if (!Float.isNaN(mAspectRatio)) {
            lp1.height = (int) ((parentWidth - parentHPadding) / mAspectRatio);
        }
        int availableSpace = parentWidth - parentHPadding - lp1.leftMargin - lp1.rightMargin - lp2.leftMargin - lp2.rightMargin;
        int width1 = Float.isNaN(weight1) ? (int) (availableSpace / 2.0f + 0.5f) : (int) (availableSpace * weight1 / 100 + 0.5f);
        int width2 = Float.isNaN(weight2) ? availableSpace - width1 : (int) (availableSpace * weight2 / 100 + 0.5f);
        int width3 = Float.isNaN(weight3) ? width2 : (int) (availableSpace * weight3 / 100 + 0.5);
        int bottomavailableSpace = parentWidth - parentHPadding - lp4.leftMargin - lp4.rightMargin - lp5.leftMargin - lp5.rightMargin - lp6.leftMargin - lp6.rightMargin;
        int width4 = Float.isNaN(weight4) ? (int) (bottomavailableSpace / 3.0f + 0.5f) : (int) (availableSpace * weight4 / 100 + 0.5f);
        int width5 = Float.isNaN(weight5) ? width4 : (int) (availableSpace * weight5 / 100 + 0.5f);
        int width6 = Float.isNaN(weight6) ? width4 : (int) (availableSpace * weight6 / 100 + 0.5f);
        helper.measureChildWithMargins(child1, MeasureSpec.makeMeasureSpec(width1 + lp1.leftMargin + lp1.rightMargin, MeasureSpec.EXACTLY), helper.getChildMeasureSpec(helper.getContentHeight(), lp1.height, true));
        int height1 = child1.getMeasuredHeight();
        int height2 = Float.isNaN(mRowWeight) ? (int) ((height1 - lp2.bottomMargin - lp3.topMargin) / 2.0f + 0.5f) : (int) ((height1 - lp2.bottomMargin - lp3.topMargin) * mRowWeight / 100 + 0.5f);
        int height3 = (height1 - lp2.bottomMargin - lp3.topMargin) - height2;
        helper.measureChildWithMargins(child2, MeasureSpec.makeMeasureSpec(width2 + lp2.leftMargin + lp2.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height2 + lp2.topMargin + lp2.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child3, MeasureSpec.makeMeasureSpec(width3 + lp3.leftMargin + lp3.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp3.topMargin + lp3.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child4, MeasureSpec.makeMeasureSpec(width4 + lp4.leftMargin + lp4.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp4.topMargin + lp4.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child5, MeasureSpec.makeMeasureSpec(width5 + lp5.leftMargin + lp5.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp5.topMargin + lp5.bottomMargin, MeasureSpec.EXACTLY));
        helper.measureChildWithMargins(child6, MeasureSpec.makeMeasureSpec(width6 + lp6.leftMargin + lp6.rightMargin, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height3 + lp6.topMargin + lp6.bottomMargin, MeasureSpec.EXACTLY));
        int maxTopHeight = Math.max(height1 + lp1.topMargin + lp1.bottomMargin, (height2 + lp2.topMargin + lp2.bottomMargin) * 2);
        int maxBottomHeight = Math.max(height3 + lp4.topMargin + lp4.bottomMargin, Math.max(height3 + lp5.topMargin + lp5.bottomMargin, height3 + lp6.topMargin + lp6.bottomMargin));
        mainConsumed = maxTopHeight + maxBottomHeight + getVerticalMargin() + getVerticalPadding();
        calculateRect(mainConsumed - getVerticalMargin() - getVerticalPadding(), mAreaRect, layoutState, helper);
        int right1 = mAreaRect.left + orientationHelper.getDecoratedMeasurementInOther(child1);
        layoutChildWithMargin(child1, mAreaRect.left, mAreaRect.top, right1, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child4), helper);
        int right2 = right1 + orientationHelper.getDecoratedMeasurementInOther(child2);
        layoutChildWithMargin(child2, right1, mAreaRect.top, right2, mAreaRect.top + orientationHelper.getDecoratedMeasurement(child2), helper);
        int right3 = right1 + orientationHelper.getDecoratedMeasurementInOther(child3);
        layoutChildWithMargin(child3, right1, mAreaRect.top + orientationHelper.getDecoratedMeasurement(child3), right3, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child4), helper);
        int right4 = mAreaRect.left + orientationHelper.getDecoratedMeasurementInOther(child4);
        layoutChildWithMargin(child4, mAreaRect.left, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child4), right4, mAreaRect.bottom, helper);
        int right5 = right4 + orientationHelper.getDecoratedMeasurementInOther(child5);
        layoutChildWithMargin(child5, right4, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child5), right5, mAreaRect.bottom, helper);
        int right6 = right5 + orientationHelper.getDecoratedMeasurementInOther(child6);
        layoutChildWithMargin(child6, right5, mAreaRect.bottom - orientationHelper.getDecoratedMeasurement(child6), right6, mAreaRect.bottom, helper);
    } else {
    // TODO: horizontal support
    }
    handleStateOnResult(result, mChildrenViews);
    return mainConsumed;
}
Also used : OrientationHelperEx(com.alibaba.android.vlayout.OrientationHelperEx) VirtualLayoutManager(com.alibaba.android.vlayout.VirtualLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)32 RecyclerView (android.support.v7.widget.RecyclerView)26 View (android.view.View)26 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)18 LayoutParams (com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams)10 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)5 Rect (android.graphics.Rect)2 ArrayMap (android.support.v4.util.ArrayMap)1 SimpleArrayMap (android.support.v4.util.SimpleArrayMap)1 ViewGroup (android.view.ViewGroup)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 TextView (android.widget.TextView)1 LayoutHelper (com.alibaba.android.vlayout.LayoutHelper)1 Range (com.alibaba.android.vlayout.Range)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1