// Эта часть части находится внутри фрагмента // Код является Kotlin
recyclerView.addOnItemTouchListener (CardViewRecyclerViewItemTouchListener (recyclerView, intArrayOf (R.id.editBtn, R.id.deleteBtn),
object : CardViewRecyclerViewItemTouchListener.CarViewClickListener {
override fun onEditBtnClick(view: View, position: Int) {
// Могу ли я получить автоматически сгенерированный идентификатор из позиции
Toast.makeText(
view.context,strong text
"CardView Button EDIT click on id = action on position = $position",
Toast.LENGTH_LONG
).show()
val updateDialog = LayoutInflater.from(activity).inflate(R.layout.update_dialog, null)
val dialogBtnBuilder = AlertDialog.Builder(activity)
.setView(updateDialog)
.setTitle("Modify Activiy")
val updateAlertBuilder = dialogBtnBuilder.show()
updateDialog.updateBtn.setOnClickListener {
updateAlertBuilder.dismiss()
val sta = updateDialog.uStart.text.toString()
val en = updateDialog.uEnd.text.toString()
val dtit = updateDialog.uTitle.text.toString()
val cose = updateDialog.uCourse.text.toString()
val lect = updateDialog.uLecturer.text.toString()
val ven = updateDialog.uVenue.text.toString()
Toast.makeText(view.context, "update SuccessFull on = $position with id = ", Toast.LENGTH_LONG)
.show()
//mondayViewModel.update(id,strt,end,tle,cos,lect,venue)
}
}
override fun onDeleteBtnClick(view: View, position: Int) {
val itemId = view.id
Toast.makeText(
view.context,
"CardView Button Delete click action on id= $itemId on position = $position",
Toast.LENGTH_LONG
).show()
mondayViewModel.delete(itemId)
}
override fun onClick(view: View, position: Int) {
//Toast.makeText(view.context, "Single click action on position = $position", Toast.LENGTH_LONG).show()
}
override fun onLongClick(view: View, position: Int) {
//Toast.makeText(view.context, "CardView long click action on position = $position", Toast.LENGTH_LONG).show()
}
}))