Undo function on Staggered Grid layout which caused app crash is now fixed.
This commit is contained in:
parent
d0280cc437
commit
b3c748edf9
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -72,21 +72,20 @@ class ListFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
mToDoViewModel.deleteItem(deletedItem)
|
||||
adapter.notifyItemRemoved(viewHolder.adapterPosition)
|
||||
// Restore Deleted Item
|
||||
restoreDeletedData(viewHolder.itemView, deletedItem, viewHolder.adapterPosition)
|
||||
restoreDeletedData(viewHolder.itemView, deletedItem)
|
||||
}
|
||||
}
|
||||
val itemTouchHelper = ItemTouchHelper(swipeToDeleteCallback)
|
||||
itemTouchHelper.attachToRecyclerView(recyclerView)
|
||||
}
|
||||
|
||||
private fun restoreDeletedData(view: View, deletedItem: ToDoData, position: Int) {
|
||||
private fun restoreDeletedData(view: View, deletedItem: ToDoData) {
|
||||
val snackBar = Snackbar.make(
|
||||
view, "Deleted '${deletedItem.title}'",
|
||||
Snackbar.LENGTH_LONG
|
||||
)
|
||||
snackBar.setAction("Undo") {
|
||||
mToDoViewModel.insertData(deletedItem)
|
||||
adapter.notifyItemChanged(position)
|
||||
}
|
||||
snackBar.show()
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.0.0"
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
|
||||
|
Loading…
x
Reference in New Issue
Block a user