Removes drag and drop repositioning for spaces
This commit is contained in:
parent
a7aa72fb6e
commit
a1c79f8c13
|
@ -72,7 +72,6 @@ class SpaceListFragment @Inject constructor(
|
|||
|
||||
private fun setupSpaceController() {
|
||||
if (vectorFeatures.isNewAppLayoutEnabled()) {
|
||||
enableDragAndDropForNewSpaceController()
|
||||
newSpaceController.callback = this
|
||||
views.groupListView.configureWith(newSpaceController)
|
||||
} else {
|
||||
|
@ -82,49 +81,6 @@ class SpaceListFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun enableDragAndDropForNewSpaceController() {
|
||||
EpoxyTouchHelper.initDragging(newSpaceController)
|
||||
.withRecyclerView(views.groupListView)
|
||||
.forVerticalList()
|
||||
.withTarget(NewSpaceSummaryItem::class.java)
|
||||
.andCallbacks(object : EpoxyTouchHelper.DragCallbacks<NewSpaceSummaryItem>() {
|
||||
var toPositionM: Int? = null
|
||||
var fromPositionM: Int? = null
|
||||
var initialElevation: Float? = null
|
||||
|
||||
override fun onDragStarted(model: NewSpaceSummaryItem?, itemView: View?, adapterPosition: Int) {
|
||||
toPositionM = null
|
||||
fromPositionM = null
|
||||
model?.matrixItem?.id?.let {
|
||||
viewModel.handle(SpaceListAction.OnStartDragging(it, false))
|
||||
}
|
||||
itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
initialElevation = itemView?.elevation
|
||||
itemView?.elevation = 6f
|
||||
}
|
||||
|
||||
override fun onDragReleased(model: NewSpaceSummaryItem?, itemView: View?) {
|
||||
if (toPositionM == null || fromPositionM == null) return
|
||||
val movedSpaceId = model?.matrixItem?.id ?: return
|
||||
viewModel.handle(SpaceListAction.MoveSpace(movedSpaceId, toPositionM!! - fromPositionM!!))
|
||||
}
|
||||
|
||||
override fun clearView(model: NewSpaceSummaryItem?, itemView: View?) {
|
||||
itemView?.elevation = initialElevation ?: 0f
|
||||
}
|
||||
|
||||
override fun onModelMoved(fromPosition: Int, toPosition: Int, modelBeingMoved: NewSpaceSummaryItem?, itemView: View?) {
|
||||
if (fromPositionM == null) {
|
||||
fromPositionM = fromPosition
|
||||
}
|
||||
if (toPositionM != toPosition) {
|
||||
toPositionM = toPosition
|
||||
itemView?.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun enableDragAndDropForSpaceController() {
|
||||
EpoxyTouchHelper.initDragging(spaceController)
|
||||
.withRecyclerView(views.groupListView)
|
||||
|
|
Loading…
Reference in New Issue