Search in sources :

Example 61 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project android-advancedrecyclerview by h6ah4i.

the class DraggableCheckCanDropExampleItemAdapter method onCheckCanStartDrag.

@Override
public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
    // x, y --- relative from the itemView's top-left
    final View containerView = holder.mContainer;
    final View dragHandleView = holder.mDragHandle;
    final int offsetX = containerView.getLeft() + (int) (containerView.getTranslationX() + 0.5f);
    final int offsetY = containerView.getTop() + (int) (containerView.getTranslationY() + 0.5f);
    return ViewUtils.hitTest(dragHandleView, x - offsetX, y - offsetY);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 62 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project android-advancedrecyclerview by h6ah4i.

the class ExpandableDraggableSwipeableExampleAdapter method onCheckChildCanStartDrag.

@Override
public boolean onCheckChildCanStartDrag(MyChildViewHolder holder, int groupPosition, int childPosition, int x, int y) {
    // x, y --- relative from the itemView's top-left
    final View containerView = holder.mContainer;
    final View dragHandleView = holder.mDragHandle;
    final int offsetX = containerView.getLeft() + (int) (containerView.getTranslationX() + 0.5f);
    final int offsetY = containerView.getTop() + (int) (containerView.getTranslationY() + 0.5f);
    return ViewUtils.hitTest(dragHandleView, x - offsetX, y - offsetY);
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 63 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project android-advancedrecyclerview by h6ah4i.

the class ExpandableDraggableSwipeableExampleAdapter method onCheckGroupCanStartDrag.

@Override
public boolean onCheckGroupCanStartDrag(MyGroupViewHolder holder, int groupPosition, int x, int y) {
    // x, y --- relative from the itemView's top-left
    final View containerView = holder.mContainer;
    final View dragHandleView = holder.mDragHandle;
    final int offsetX = containerView.getLeft() + (int) (containerView.getTranslationX() + 0.5f);
    final int offsetY = containerView.getTop() + (int) (containerView.getTranslationY() + 0.5f);
    return ViewUtils.hitTest(dragHandleView, x - offsetX, y - offsetY);
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 64 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project android-advancedrecyclerview by h6ah4i.

the class DraggableSwipeableExampleAdapter method onCheckCanStartDrag.

@Override
public boolean onCheckCanStartDrag(MyViewHolder holder, int position, int x, int y) {
    // x, y --- relative from the itemView's top-left
    final View containerView = holder.mContainer;
    final View dragHandleView = holder.mDragHandle;
    final int offsetX = containerView.getLeft() + (int) (containerView.getTranslationX() + 0.5f);
    final int offsetY = containerView.getTop() + (int) (containerView.getTranslationY() + 0.5f);
    return ViewUtils.hitTest(dragHandleView, x - offsetX, y - offsetY);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 65 with LEFT

use of android.support.v7.widget.helper.ItemTouchHelper.LEFT in project android-advancedrecyclerview by h6ah4i.

the class SimpleListDividerDecorator method onDrawOver.

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    final int childCount = parent.getChildCount();
    if (childCount == 0) {
        return;
    }
    // [px]
    final float xPositionThreshold = (mOverlap) ? 1.0f : (mVerticalDividerWidth + 1.0f);
    // [px]
    final float yPositionThreshold = (mOverlap) ? 1.0f : (mHorizontalDividerHeight + 1.0f);
    // [px]
    final float zPositionThreshold = 1.0f;
    for (int i = 0; i < childCount - 1; i++) {
        final View child = parent.getChildAt(i);
        final View nextChild = parent.getChildAt(i + 1);
        if ((child.getVisibility() != View.VISIBLE) || (nextChild.getVisibility() != View.VISIBLE)) {
            continue;
        }
        // check if the next item is placed at the bottom or right
        final float childBottom = child.getBottom() + child.getTranslationY();
        final float nextChildTop = nextChild.getTop() + nextChild.getTranslationY();
        final float childRight = child.getRight() + child.getTranslationX();
        final float nextChildLeft = nextChild.getLeft() + nextChild.getTranslationX();
        if (!(((mHorizontalDividerHeight != 0) && (Math.abs(nextChildTop - childBottom) < yPositionThreshold)) || ((mVerticalDividerWidth != 0) && (Math.abs(nextChildLeft - childRight) < xPositionThreshold)))) {
            continue;
        }
        // check if the next item is placed on the same plane
        final float childZ = ViewCompat.getTranslationZ(child) + ViewCompat.getElevation(child);
        final float nextChildZ = ViewCompat.getTranslationZ(nextChild) + ViewCompat.getElevation(nextChild);
        if (!(Math.abs(nextChildZ - childZ) < zPositionThreshold)) {
            continue;
        }
        final float childAlpha = child.getAlpha();
        final float nextChildAlpha = nextChild.getAlpha();
        final int tx = (int) (child.getTranslationX() + 0.5f);
        final int ty = (int) (child.getTranslationY() + 0.5f);
        if (mHorizontalDividerHeight != 0) {
            final int left = child.getLeft();
            final int right = child.getRight();
            final int top = child.getBottom() - (mOverlap ? mHorizontalDividerHeight : 0);
            final int bottom = top + mHorizontalDividerHeight;
            mHorizontalDrawable.setAlpha((int) ((0.5f * 255) * (childAlpha + nextChildAlpha) + 0.5f));
            mHorizontalDrawable.setBounds(left + tx, top + ty, right + tx, bottom + ty);
            mHorizontalDrawable.draw(c);
        }
        if (mVerticalDividerWidth != 0) {
            final int left = child.getRight() - (mOverlap ? mVerticalDividerWidth : 0);
            final int right = left + mVerticalDividerWidth;
            final int top = child.getTop();
            final int bottom = child.getBottom();
            mVerticalDrawable.setAlpha((int) ((0.5f * 255) * (childAlpha + nextChildAlpha) + 0.5f));
            mVerticalDrawable.setBounds(left + tx, top + ty, right + tx, bottom + ty);
            mVerticalDrawable.draw(c);
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

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