-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from FakeDevelopers/feature/BDBD-240
현재 작업 내용 sandbox에 적용
- Loading branch information
Showing
7 changed files
with
114 additions
and
13 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
55 changes: 55 additions & 0 deletions
55
...ain/kotlin/com/fakedevelopers/bidderbidder/ui/product_registration/DragAndDropCallback.kt
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,55 @@ | ||
package com.fakedevelopers.bidderbidder.ui.product_registration | ||
|
||
import androidx.recyclerview.widget.ItemTouchHelper | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
class DragAndDropCallback( | ||
private val adapter: SelectedPictureListAdapter | ||
) : ItemTouchHelper.Callback() { | ||
|
||
private var isMoved = false | ||
|
||
// 좌우 드래그 | ||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) = | ||
makeMovementFlags(ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT, 0) | ||
|
||
override fun onMove( | ||
recyclerView: RecyclerView, | ||
viewHolder: RecyclerView.ViewHolder, | ||
target: RecyclerView.ViewHolder | ||
): Boolean { | ||
adapter.onItemDragMove(viewHolder.adapterPosition, target.adapterPosition) | ||
return true | ||
} | ||
|
||
override fun onMoved( | ||
recyclerView: RecyclerView, | ||
viewHolder: RecyclerView.ViewHolder, | ||
fromPos: Int, | ||
target: RecyclerView.ViewHolder, | ||
toPos: Int, | ||
x: Int, | ||
y: Int | ||
) { | ||
super.onMoved(recyclerView, viewHolder, fromPos, target, toPos, x, y) | ||
isMoved = true | ||
} | ||
|
||
override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) { | ||
super.onSelectedChanged(viewHolder, actionState) | ||
if (isMoved) { | ||
isMoved = false | ||
adapter.changeMoveEvent() | ||
} | ||
} | ||
|
||
override fun isLongPressDragEnabled(): Boolean { | ||
return true | ||
} | ||
|
||
override fun isItemViewSwipeEnabled(): Boolean { | ||
return false | ||
} | ||
|
||
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {} | ||
} |
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