Search in sources :

Example 11 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project android-advancedrecyclerview by h6ah4i.

the class ItemSlidingAnimator method slideToSpecifiedPositionInternal.

private boolean slideToSpecifiedPositionInternal(final RecyclerView.ViewHolder holder, float amount, boolean proportional, boolean horizontal, boolean shouldAnimate, Interpolator interpolator, long duration, SwipeFinishInfo swipeFinish) {
    final View containerView = SwipeableViewHolderUtils.getSwipeableContainerView(holder);
    if (shouldAnimate) {
        shouldAnimate = ViewCompat.isAttachedToWindow(containerView) && (containerView.getVisibility() == View.VISIBLE);
    }
    duration = (shouldAnimate) ? duration : 0;
    if (amount != 0.0f) {
        final int width = containerView.getWidth();
        final int height = containerView.getHeight();
        if (horizontal && (!proportional || width != 0)) {
            final int translationX;
            translationX = (int) ((proportional ? width * amount : amount) + 0.5f);
            return animateSlideInternalCompat(holder, horizontal, translationX, 0, duration, interpolator, swipeFinish);
        } else if (!horizontal && (!proportional || height != 0)) {
            final int translationY;
            translationY = (int) ((proportional ? height * amount : amount) + 0.5f);
            return animateSlideInternalCompat(holder, horizontal, 0, translationY, duration, interpolator, swipeFinish);
        } else {
            if (swipeFinish != null) {
                throw new IllegalStateException("Unexpected state in slideToSpecifiedPositionInternal (swipeFinish == null)");
            }
            scheduleViewHolderDeferredSlideProcess(holder, new DeferredSlideProcess(holder, amount, horizontal));
            return false;
        }
    } else {
        return animateSlideInternalCompat(holder, horizontal, 0, 0, duration, interpolator, swipeFinish);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 12 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project android-advancedrecyclerview by h6ah4i.

the class ItemSlidingAnimator method slideToOutsideOfWindowInternal.

private boolean slideToOutsideOfWindowInternal(RecyclerView.ViewHolder holder, int dir, boolean shouldAnimate, long duration, SwipeFinishInfo swipeFinish) {
    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }
    final View containerView = SwipeableViewHolderUtils.getSwipeableContainerView(holder);
    final ViewGroup parent = (ViewGroup) containerView.getParent();
    if (parent == null) {
        return false;
    }
    final int left = containerView.getLeft();
    final int right = containerView.getRight();
    final int top = containerView.getTop();
    final int bottom = containerView.getBottom();
    final int width = right - left;
    final int height = bottom - top;
    parent.getWindowVisibleDisplayFrame(mTmpRect);
    final int windowWidth = mTmpRect.width();
    final int windowHeight = mTmpRect.height();
    int translateX = 0;
    int translateY = 0;
    if ((width == 0) || (height == 0)) {
        // not measured yet or not shown
        switch(dir) {
            case DIR_LEFT:
                translateX = -windowWidth;
                break;
            case DIR_UP:
                translateY = -windowHeight;
                break;
            case DIR_RIGHT:
                translateX = windowWidth;
                break;
            case DIR_DOWN:
                translateY = windowHeight;
                break;
            default:
                break;
        }
        shouldAnimate = false;
    } else {
        parent.getLocationInWindow(mTmpLocation);
        final int x = mTmpLocation[0];
        final int y = mTmpLocation[1];
        switch(dir) {
            case DIR_LEFT:
                translateX = -(x + width);
                break;
            case DIR_UP:
                translateY = -(y + height);
                break;
            case DIR_RIGHT:
                translateX = windowWidth - (x - left);
                break;
            case DIR_DOWN:
                translateY = windowHeight - (y - top);
                break;
            default:
                break;
        }
    }
    if (shouldAnimate) {
        shouldAnimate = ViewCompat.isAttachedToWindow(containerView) && (containerView.getVisibility() == View.VISIBLE);
    }
    duration = (shouldAnimate) ? duration : 0;
    boolean horizontal = (dir == DIR_LEFT || dir == DIR_RIGHT);
    return animateSlideInternalCompat(holder, horizontal, translateX, translateY, duration, mSlideToOutsideOfWindowAnimationInterpolator, swipeFinish);
}
Also used : ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 13 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project xRecyclerViewF by Dsiner.

the class DividerItemDecoration method drawHorizontalDividers.

/**
 * Adds dividers to a RecyclerView with a LinearLayoutManager or its
 * subclass oriented horizontally.
 *
 * @param canvas The {@link Canvas} onto which horizontal dividers will be
 *               drawn
 * @param parent The RecyclerView onto which horizontal dividers are being
 *               added
 */
private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) {
    int parentTop = parent.getPaddingTop();
    int parentBottom = parent.getHeight() - parent.getPaddingBottom();
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount - 1; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int parentLeft = child.getRight() + params.rightMargin;
        int parentRight = parentLeft + mDivider.getIntrinsicWidth();
        mDivider.setBounds(parentLeft, parentTop, parentRight, parentBottom);
        mDivider.draw(canvas);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 14 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project RecyclerViewTutorial by vamsitallapudi.

the class MainActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.item_grid:
            // use this in case of gridlayoutmanager
            mLayoutManager = new GridLayoutManager(this, 2);
            mRecyclerView.setLayoutManager(mLayoutManager);
            break;
        case R.id.item_staggered_grid:
            // use this in case of Staggered GridLayoutManager
            mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
            mRecyclerView.setLayoutManager(mLayoutManager);
            break;
        case R.id.item_horizontal:
            // horizontal linear layout
            mLayoutManager = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false);
            mRecyclerView.setLayoutManager(mLayoutManager);
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 15 with HORIZONTAL

use of android.support.v7.widget.LinearLayoutManager.HORIZONTAL in project Saiy-PS by brandall76.

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 = 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)

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