I have a recyclerview. Each cell of recyclerview has an associated file. I am using ItemTouchHelper for swiping. When a user swipes a cell, i want to disable the swipe of other cells as long as the the file associated with swiped cell does not get deleted. How do i enable and disable swiping for a particular amount of time. I went through questions on this on stack, but they mostly answers how to disable swipe for particular position, which i don't want.
Asked
Active
Viewed 247 times
0
-
so you want it to be disabled for a "particular" amount of time, you mean like 2, 5, 10 seconds, or you want to disable it until the file is deleted? – Suleyman Apr 25 '18 at 13:13
-
@LieForBananas Until the file is deleted – BraveEvidence Apr 25 '18 at 15:00
-
If you are deleting a file from the system, as far as I know, it returns a boolean which indicates whether the operation is successful or not. So once the user swipes the cell you can disable it, and when the delete operation returns true you can enable it again. – Suleyman Apr 25 '18 at 15:18
-
@LieForBananas How to disable a cell? – BraveEvidence Apr 25 '18 at 16:27
-
@LieForBananas I tried disabling recycler view but it doesn't work – BraveEvidence Apr 25 '18 at 16:28
-
I thought you said you found posts that explain it, when you say "cell" you do not mean "position"? – Suleyman Apr 25 '18 at 16:30
-
@LieForBananas The post which i have found shows how to disable cell at particular position. If there are 100 cells and i swiped first cell then i can't disable cell 1 by 1. – BraveEvidence Apr 25 '18 at 16:32
-
I don't fully understand your question. When you have a 100 items in a `RecyclerView` and you delete the first one, you expect it to disappear and be replaced by the item in the 2nd position. As far as I know, `RecyclerView` uses only position to identify the views inside it, so I don't know which criteria you want to use to delete the elements. – Suleyman Apr 25 '18 at 17:04
-
I meant "which criteria you want to use to **disable** elements" – Suleyman Apr 25 '18 at 17:48
1 Answers
0
Just override the following method
@Override
public boolean isItemViewSwipeEnabled()
{
return mSwipable;
}

halfer
- 19,824
- 17
- 99
- 186

BraveEvidence
- 53
- 11
- 45
- 119