-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
100 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
library/src/main/java/com/mikepenz/fastadapter/drag/ItemTouchCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mikepenz.fastadapter.drag; | ||
|
||
public interface ItemTouchCallback { | ||
|
||
/** | ||
* Called when an item has been dragged | ||
* | ||
* @param oldPosition start position | ||
* @param newPosition end position | ||
* @return true if moved otherwise false | ||
*/ | ||
boolean itemTouchOnMove(int oldPosition, int newPosition); | ||
} |
39 changes: 39 additions & 0 deletions
39
library/src/main/java/com/mikepenz/fastadapter/drag/SimpleDragCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.mikepenz.fastadapter.drag; | ||
|
||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.helper.ItemTouchHelper; | ||
|
||
/** | ||
* based on the sample from | ||
* https://github.com/AleBarreto/DragRecyclerView | ||
*/ | ||
public class SimpleDragCallback extends ItemTouchHelper.SimpleCallback { | ||
|
||
//our callback | ||
private ItemTouchCallback mCallbackItemTouch; // interface | ||
private boolean mIsDragEnabled = true; | ||
|
||
public SimpleDragCallback(ItemTouchCallback itemTouchCallback) { | ||
super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0); | ||
this.mCallbackItemTouch = itemTouchCallback; | ||
} | ||
|
||
public void setIsDragEnabled(boolean mIsDragEnabled) { | ||
this.mIsDragEnabled = mIsDragEnabled; | ||
} | ||
|
||
@Override | ||
public boolean isLongPressDragEnabled() { | ||
return mIsDragEnabled; | ||
} | ||
|
||
@Override | ||
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { | ||
return mCallbackItemTouch.itemTouchOnMove(viewHolder.getAdapterPosition(), target.getAdapterPosition()); // information to the interface | ||
} | ||
|
||
@Override | ||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { | ||
// swiped disabled | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters