Search in sources :

Example 31 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project QuickReturn by lawloretienne.

the class DividerItemDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
        super.onDrawOver(c, parent, state);
        return;
    }
    // Initialization needed to avoid compiler warning
    int left = 0, right = 0, top = 0, bottom = 0, size;
    int orientation = getOrientation(parent);
    int childCount = parent.getChildCount();
    if (orientation == LinearLayoutManager.VERTICAL) {
        size = mDivider.getIntrinsicHeight();
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
    } else {
        // horizontal
        size = mDivider.getIntrinsicWidth();
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
    }
    for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getTop() - params.topMargin;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getLeft() - params.leftMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    // show last divider
    if (mShowLastDivider && childCount > 0) {
        View child = parent.getChildAt(childCount - 1);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getBottom() + params.bottomMargin;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getRight() + params.rightMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 32 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project YourAppIdea by Michenux.

the class DividerItemDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
        super.onDrawOver(c, parent, state);
        return;
    }
    // Initialization needed to avoid compiler warning
    int left = 0, right = 0, top = 0, bottom = 0, size;
    int orientation = getOrientation(parent);
    int childCount = parent.getChildCount();
    if (orientation == LinearLayoutManager.VERTICAL) {
        size = mDivider.getIntrinsicHeight();
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
    } else {
        // horizontal
        size = mDivider.getIntrinsicWidth();
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
    }
    for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getTop() - params.topMargin;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getLeft() - params.leftMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    // show last divider
    if (mShowLastDivider && childCount > 0) {
        View child = parent.getChildAt(childCount - 1);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getBottom() + params.bottomMargin;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getRight() + params.rightMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 33 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project MusicDNA by harjot-oberai.

the class HomeActivity method hidePlayer.

// //////////////////////////////////////////////////////////////////////////////////////////////
/*
     * Methods to control the transitions of the player fragment
     * hidePlayer() / showPlayer()  -> the vertical animation to hide/show the visualizer
     * hidePlayer2() / showPlayer2()  -> the horizontal animation to hide/show the equalizer
     * hidePlayer3() / showPlayer3()  -> the horizontal animation to hide/show the queue
     */
public void hidePlayer() {
    if (playerFragment != null && playerFragment.mVisualizerView != null) {
        playerFragment.mVisualizerView.setVisibility(View.GONE);
        playerFragment.lyricsContainer.setVisibility(View.GONE);
    }
    drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
    if (Build.VERSION.SDK_INT >= 21) {
        Window window = ((Activity) (ctx)).getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(CommonUtils.getDarkColor(themeColor));
    }
    isPlayerVisible = false;
    if (playerFragment != null && playerFragment.cpb != null) {
        playerFragment.cpb.setAlpha(0.0f);
        playerFragment.cpb.setVisibility(View.VISIBLE);
        playerFragment.cpb.animate().alpha(1.0f);
    }
    if (playerFragment != null && playerFragment.smallPlayer != null) {
        playerFragment.smallPlayer.setAlpha(0.0f);
        playerFragment.smallPlayer.setVisibility(View.VISIBLE);
        playerFragment.smallPlayer.animate().alpha(1.0f);
    }
    if (playerFragment != null && playerFragment.spToolbar != null) {
        playerFragment.spToolbar.animate().alpha(0.0f).withEndAction(new Runnable() {

            @Override
            public void run() {
                playerFragment.spToolbar.setVisibility(GONE);
            }
        });
    }
    playerContainer.setVisibility(View.VISIBLE);
    if (playerFragment != null) {
        playerContainer.animate().translationY(playerContainer.getHeight() - playerFragment.smallPlayer.getHeight()).setDuration(300);
    } else {
        playerContainer.animate().translationY(playerContainer.getHeight() - playerFragment.smallPlayer.getHeight()).setDuration(300).setStartDelay(500);
    }
    if (playerFragment != null) {
        playerFragment.player_controller.setAlpha(0.0f);
        playerFragment.player_controller.setImageDrawable(playerFragment.mainTrackController.getDrawable());
        playerFragment.player_controller.animate().alpha(1.0f);
        playerFragment.snappyRecyclerView.animate().alpha(0.0f).withEndAction(new Runnable() {

            @Override
            public void run() {
                playerFragment.snappyRecyclerView.setVisibility(GONE);
            }
        });
    }
}
Also used : Window(android.view.Window) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity)

Example 34 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project SpotiQ by ZinoKader.

the class CustomDividerItemDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    if (mDivider == null) {
        super.onDrawOver(c, parent, state);
        return;
    }
    // Initialization needed to avoid compiler warning
    int left = 0, right = 0, top = 0, bottom = 0, size;
    int orientation = mOrientation != -1 ? mOrientation : getOrientation(parent);
    int childCount = parent.getChildCount();
    if (orientation == LinearLayoutManager.VERTICAL) {
        size = mDivider.getIntrinsicHeight();
        left = parent.getPaddingLeft();
        right = parent.getWidth() - parent.getPaddingRight();
    } else {
        // horizontal
        size = mDivider.getIntrinsicWidth();
        top = parent.getPaddingTop();
        bottom = parent.getHeight() - parent.getPaddingBottom();
    }
    for (int i = mShowFirstDivider ? 0 : 1; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        if (orientation == LinearLayoutManager.VERTICAL) {
            top = child.getTop() - params.topMargin - size;
            bottom = top + size;
        } else {
            // horizontal
            left = child.getLeft() - params.leftMargin;
            right = left + size;
        }
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    // show last divider
    if (mShowLastDivider && childCount > 0) {
        View child = parent.getChildAt(childCount - 1);
        if (parent.getChildAdapterPosition(child) == (state.getItemCount() - 1)) {
            RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
            if (orientation == LinearLayoutManager.VERTICAL) {
                top = child.getBottom() + params.bottomMargin;
                bottom = top + size;
            } else {
                // horizontal
                left = child.getRight() + params.rightMargin;
                right = left + size;
            }
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 35 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL 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

RecyclerView (android.support.v7.widget.RecyclerView)33 View (android.view.View)31 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)6 TextView (android.widget.TextView)5 ImageView (android.widget.ImageView)4 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 LayoutParams (com.alibaba.android.vlayout.VirtualLayoutManager.LayoutParams)3 Intent (android.content.Intent)2 Bitmap (android.graphics.Bitmap)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1