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);
}
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);
}
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);
}
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);
}
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);
}
}
}
Aggregations