Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing boundaries after swipe left #1

Open
AmanRathi9 opened this issue Nov 22, 2017 · 1 comment
Open

Showing boundaries after swipe left #1

AmanRathi9 opened this issue Nov 22, 2017 · 1 comment

Comments

@AmanRathi9
Copy link

Hi,
When i swipe left and then swipe right or just tap to return back to the normal state, it shows the boundaries around the item layout or you can say elevation. I am not using any cardview.
So the layout doesn't look nice.
Please help.

@BorisG
Copy link

BorisG commented Dec 3, 2017

Hi @AmanRathi9,
I had the same issue with the elevation staying after the item returns to its normal state.
After some digging in the code, I solved it by adding a call to clearView(recyclerView, currentItemViewHolder); method inside setTouchUpListener(...) in SwipeController.java right after the buttons click callbacks.

Here is a the full modified method:

private void setTouchUpListener(final Canvas c, final RecyclerView recyclerView, final RecyclerView.ViewHolder viewHolder, final float dX, final float dY, final int actionState, final boolean isCurrentlyActive) {
	recyclerView.setOnTouchListener(new View.OnTouchListener() {
		@Override
		public boolean onTouch(View v, MotionEvent event) {
			if (event.getAction() == MotionEvent.ACTION_UP) {
				SwipeController.super.onChildDraw(c, recyclerView, viewHolder, 0F, dY, actionState, isCurrentlyActive);
				recyclerView.setOnTouchListener(new View.OnTouchListener() {
					@Override
					public boolean onTouch(View v, MotionEvent event) {
						return false;
					}
				});
				setItemsClickable(recyclerView, true);
				swipeBack = false;

				if (buttonsActions != null && buttonInstance != null && buttonInstance.contains(event.getX(), event.getY())) {
					if (buttonVisibilityState == ButtonsState.LEFT_VISIBLE) {
						buttonsActions.onLeftClicked(viewHolder.getAdapterPosition());
					}
					else if (buttonVisibilityState == ButtonsState.RIGHT_VISIBLE) {
						buttonsActions.onRightClicked(viewHolder.getAdapterPosition());
					}
				}
				clearView(recyclerView, currentItemViewHolder);
				buttonVisibilityState = ButtonsState.GONE;
				currentItemViewHolder = null;
			}
			return false;
		}
	});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants