Search in sources :

Example 91 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project RxJavaInAction by fengzhizi715.

the class DividerGridItemDecoration method drawHorizontal.

public void drawHorizontal(Canvas c, RecyclerView parent) {
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getLeft() - params.leftMargin;
        final int right = child.getRight() + params.rightMargin + mDivider.getIntrinsicWidth();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        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 92 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project opacclient by opacapp.

the class AccountDividerItemDecoration method onDraw.

@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.ViewHolder vh = parent.getChildViewHolder(child);
        if (!isDecorated(child, parent))
            continue;
        if (!(vh instanceof AccountAdapter.ViewHolder))
            continue;
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final Drawable drawable = (((AccountAdapter.ViewHolder) vh).isCoversHidden() ? mDividerWithoutInset : mDividerWithInset);
        final int bottom = top + drawable.getIntrinsicHeight();
        drawable.setBounds(left, top, right, bottom);
        drawable.draw(c);
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 93 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project butter-android by butterproject.

the class OneShotDividerDecorator method onDraw.

@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
    super.onDraw(canvas, parent, state);
    final int left = parent.getPaddingLeft();
    final int right = parent.getWidth() - parent.getPaddingRight();
    // only draw the divider at the specified position
    final View child = parent.getChildAt(position);
    if (null == child) {
        return;
    }
    final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
    final int top = child.getBottom() + params.bottomMargin;
    final int bottom = top + divider.getIntrinsicHeight();
    divider.setBounds(left, top, right, bottom);
    divider.draw(canvas);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 94 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project opacclient by opacapp.

the class ExpandingCardListManager method expand.

public void expand(final int position) {
    if (isExpanded()) {
        if (expandedPosition != position) {
            collapse(new CompleteListener() {

                @Override
                public void onComplete() {
                    expand(position);
                }
            });
        }
        return;
    }
    resetViews();
    for (int i = 0; i < position; i++) {
        llUpper.addView(getView(i, llUpper));
        if (i < position - 1)
            addSeparator(llUpper);
    }
    final View expandedView = getView(position, expandedCard);
    expandView(position, expandedView);
    expandedCard.addView(expandedView);
    for (int i = position + 1; i < getCount(); i++) {
        llLower.addView(getView(i, llLower));
        if (i < getCount() - 1)
            addSeparator(llLower);
    }
    final float lowerPos;
    if (position + 1 < getCount()) {
        lowerPos = ViewHelper.getY(views.get(position + 1)) + context.getResources().getDimensionPixelSize(R.dimen.card_topbottom_margin_default);
    } else
        lowerPos = -1;
    final float mainPos = ViewHelper.getY(views.get(position)) - mainCard.getPaddingTop();
    unexpandedHeight = views.get(position).getHeight();
    if (interceptor != null)
        interceptor.beforeExpand(views.get(position));
    // Wait a little so that touch feedback is visible before hiding buttons
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            if (position != 0)
                upperCard.setVisibility(View.VISIBLE);
            if (lowerPos > 0)
                lowerCard.setVisibility(View.VISIBLE);
            expandedCard.setVisibility(View.VISIBLE);
            mainCard.setVisibility(View.GONE);
            final int previousHeight = layout.getHeight();
            layout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    int newHeight = layout.getHeight();
                    heightDifference = newHeight - previousHeight;
                    layout.getViewTreeObserver().removeOnPreDrawListener(this);
                    if (lowerPos > 0)
                        ViewHelper.setY(lowerCard, lowerPos);
                    ViewHelper.setY(expandedCard, mainPos);
                    lowerTranslationY = ViewHelper.getTranslationY(lowerCard);
                    expandedTranslationY = ViewHelper.getTranslationY(expandedCard);
                    AnimatorSet set = new AnimatorSet();
                    int defaultMargin = context.getResources().getDimensionPixelSize(R.dimen.card_side_margin_default);
                    int expandedMargin = context.getResources().getDimensionPixelSize(R.dimen.card_side_margin_selected);
                    int marginDifference = expandedMargin - defaultMargin;
                    List<Animator> animators = new ArrayList<>();
                    addAll(animators, ObjectAnimator.ofFloat(lowerCard, "translationY", ViewHelper.getTranslationY(lowerCard), 0), ObjectAnimator.ofFloat(expandedCard, "translationY", ViewHelper.getTranslationY(expandedCard), 0), ObjectAnimator.ofFloat(expandedCard, "cardElevation", context.getResources().getDimension(R.dimen.card_elevation_default), context.getResources().getDimension(R.dimen.card_elevation_selected)), ObjectAnimator.ofInt(expandedCard, "bottom", expandedCard.getBottom() + unexpandedHeight - expandedView.getHeight(), expandedCard.getBottom()), ObjectAnimator.ofInt(expandedCard, "left", expandedCard.getLeft() - marginDifference, expandedCard.getLeft()), ObjectAnimator.ofInt(expandedCard, "right", expandedCard.getRight() + marginDifference, expandedCard.getRight()));
                    if (interceptor != null) {
                        animators.addAll(interceptor.getExpandAnimations(heightDifference, expandedView));
                    }
                    set.playTogether(animators);
                    set.setDuration(ANIMATION_DURATION).start();
                    return false;
                }
            });
            expandedPosition = position;
        }
    }, 100);
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ArrayList(java.util.ArrayList) Handler(android.os.Handler) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) CardView(android.support.v7.widget.CardView) View(android.view.View)

Example 95 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project AndFrameWorks by scwang90.

the class RecycleViewDivider method drawVertical.

// 绘制纵向 item 分割线
private void drawVertical(Canvas canvas, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    final int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        final View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + layoutParams.rightMargin;
        final int right = left + mDividerHeight;
        if (mDivider != null) {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(canvas);
        }
        if (mPaint != null) {
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Aggregations

View (android.view.View)291 RecyclerView (android.support.v7.widget.RecyclerView)276 Paint (android.graphics.Paint)43 TextView (android.widget.TextView)36 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)22 ImageView (android.widget.ImageView)20 Rect (android.graphics.Rect)11 Intent (android.content.Intent)9 SuppressLint (android.annotation.SuppressLint)8 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)8 OrientationHelperEx (com.alibaba.android.vlayout.OrientationHelperEx)8 ArrayList (java.util.ArrayList)8 AlertDialog (android.support.v7.app.AlertDialog)7 Toolbar (android.support.v7.widget.Toolbar)7 ViewGroup (android.view.ViewGroup)7 GridLayoutManager (android.support.v7.widget.GridLayoutManager)6 Button (android.widget.Button)6 Animator (android.animation.Animator)5 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)5