Closed tfaki closed 4 years ago
I just checked the update capabilities on the sample project and it works fine. Please add more information about your problem or this issue will be closed.
maybe I did wrong, my code is like this ;
private inner class PlaceItemSwipeEvent : SwipeEventHook
override fun onSwipe(canvas: Canvas, xAxisOffset: Float, viewBinder: ViewBinder) {
when {
xAxisOffset < 0 -> paintSwipeLeft(canvas, xAxisOffset, viewBinder.rootView)
}
}
override fun onSwipeComplete(model: PlaceModel, direction: SwipeDirection, viewBinder: ViewBinder) {
val alert = AlertDialog.Builder(this)
alert.setTitle("title")
alert.setCancelable(false);
alert.setPositiveButton("Yes") { dialogInterface: DialogInterface, i: Int ->
viewModel.deletePlace(model.placeId)
alert.setNegativeButton("No") {dialogInterface: DialogInterface, i: Int ->
oneAdapter.update(model)
alert.show()
}
}
This code is fully working with the sample project using SwipeEventHookActivity:
inner class MessageSwipeHook : SwipeEventHook<MessageModel>() {
override fun provideHookConfig(): SwipeEventHookConfig = object : SwipeEventHookConfig() {
override fun withSwipeDirection() = listOf(SwipeDirection.Left)
}
override fun onSwipe(canvas: Canvas, xAxisOffset: Float, viewBinder: ViewBinder) {
when {
xAxisOffset < 0 -> paintSwipeLeft(canvas, xAxisOffset, viewBinder.rootView)
}
}
override fun onSwipeComplete(model: MessageModel, direction: SwipeDirection, viewBinder: ViewBinder) {
when (direction) {
SwipeDirection.Left -> oneAdapter.remove(model)
SwipeDirection.Right -> {
val alert = AlertDialog.Builder(this@SwipeEventHookActivity)
alert.setTitle("title")
alert.setCancelable(false)
alert.setPositiveButton("Yes") { dialogInterface: DialogInterface, i: Int ->
oneAdapter.remove(model)
}
alert.setNegativeButton("No") { dialogInterface: DialogInterface, i: Int ->
oneAdapter.update(model)
}
alert.show()
}
}
}
}
Just for reference, here is a GIF:
Thanks for your attention, I will do better
not working to undo view