Closed navotera closed 8 years ago
if you just want to showed some text or bitmap on the side when swiping, you can overwrite the onChildDraw method in the ItemDragAndSwipeCallback.java, but will disappear after release.
@Overwrite
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
// Fade out the view as it is swiped out of the parent's bounds
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
View itemView = viewHolder.itemView;
Context context = recyclerView.getContext();
Paint paint = new Paint();
Bitmap icon;
if (dX > 0) {
icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.temp);
// Set color for right swipe
paint.setColor(Color.YELLOW);
// Draw Rect with varying right side, equal to displacement dX
c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX,
(float) itemView.getBottom(), paint);
// Set the image icon for right swipe
c.drawBitmap(icon, (float) itemView.getLeft() + 25, (float) itemView.getTop() +
((float) itemView.getBottom() - (float) itemView.getTop() - icon.getHeight()) / 2, paint);
}
}
}
i guess it would be great if on the implementation of OnItemSwipeListener interface there are method listener to know which direction is we need...
by the way thanks a lot sir
If you want to set the direction on the swipe event, you can overwrite the getMovementFlags in ItemDragAndSwipeCallback.java, change the swipeFlag like this
int swipeFlags = ItemTouchHelper.START;
I will add a public method to do this soon.
what if i need both direction ?
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.8.6' Enable change the drag and swipe movement direction and threshold by setters.
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:v1.8.7' Enable draw on the edge when swipe moving
pardon me, i cannot test it yet since i got another things to do, please dont close this issue yet
Thanks
@navotera ok
Still no test?When you have problems and open the issue
seems like your documentation on this github on how to use this lib need to update.. since when creating new object from class onItemSwipeListener need to implement another method (onItemSwipeMoving method). ....
sorry sir can u give us example on how to implement that two update.. anyway thanks for your kindly reply.....
You can find the usage in the demo ItemDragAndSwipeUseActivity.java
thanks :+1: :+1: :+1: please close this issues (cannot find button comment and close on this issues)
Much Thank u sir
On Thu, Jul 27, 2017, 18:11 arscree notifications@github.com wrote:
What about swiping to the right? @overwrite https://github.com/overwrite public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
// Fade out the view as it is swiped out of the parent's bounds if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { View itemView = viewHolder.itemView;
Context context = recyclerView.getContext(); Paint paint = new Paint(); Bitmap icon; if (dX > 0) { icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.temp); // Set color for right swipe paint.setColor(Color.YELLOW); // Draw Rect with varying right side, equal to displacement dX c.drawRect((float) itemView.getLeft(), (float) itemView.getTop(), dX, (float) itemView.getBottom(), paint); // Set the image icon for right swipe c.drawBitmap(icon, (float) itemView.getLeft() + 25, (float) itemView.getTop() + ((float) itemView.getBottom() - (float) itemView.getTop() - icon.getHeight()) / 2, paint); }
}
}
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CymChad/BaseRecyclerViewAdapterHelper/issues/122#issuecomment-318319961, or mute the thread https://github.com/notifications/unsubscribe-auth/ABW903tLyrmvD7fcfug_4uwrG5CqiX-3ks5sSGJLgaJpZM4JCvhJ .
is it possible to add swipe that showed some view on recycler view using this library and how to setdirection on the swipe event... so user can swipe right or left based on the different listener method
thanks