Remove animation of to-do item
This commit is contained in:
parent
27a6271b39
commit
a59d9a44a3
4 changed files with 12 additions and 11 deletions
|
|
@ -9,7 +9,7 @@ object Repository {
|
||||||
|
|
||||||
// Room
|
// Room
|
||||||
private val db get() = ToDoApp.db
|
private val db get() = ToDoApp.db
|
||||||
val todoDao = db.toDoRoomDao()
|
private val todoDao = db.toDoRoomDao()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param toDoRoom 要插入的数据
|
* @param toDoRoom 要插入的数据
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
package cn.super12138.todo.logic.model
|
package cn.super12138.todo.logic.model
|
||||||
|
|
||||||
data class ToDo(val uuid: String, val state:Int, val content: String, val subject: String) {
|
data class ToDo(val uuid: String, val state:Int, val content: String, val subject: String) {
|
||||||
var isAnimated = false
|
// var isAnimated = false
|
||||||
}
|
}
|
||||||
|
|
@ -41,11 +41,11 @@ class AllTasksAdapter(private val todoList: MutableList<ToDo>,
|
||||||
infoBottomSheet.show(fragmentManager, InfoBottomSheet.TAG)
|
infoBottomSheet.show(fragmentManager, InfoBottomSheet.TAG)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!todo.isAnimated) {
|
/*if (!todo.isAnimated) {
|
||||||
holder.itemView.alpha = 0f
|
holder.itemView.alpha = 0f
|
||||||
holder.itemView.animate().alpha(1f).duration = 200
|
holder.itemView.animate().alpha(1f).duration = 200
|
||||||
todo.isAnimated = true
|
todo.isAnimated = true
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = todoList.size
|
override fun getItemCount() = todoList.size
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import com.google.android.material.snackbar.Snackbar
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class ToDoAdapter(val todoList: MutableList<ToDo>, val viewModelStoreOwner: ViewModelStoreOwner) :
|
class ToDoAdapter(private val todoList: MutableList<ToDo>, private val viewModelStoreOwner: ViewModelStoreOwner) :
|
||||||
RecyclerView.Adapter<ToDoAdapter.ViewHolder>() {
|
RecyclerView.Adapter<ToDoAdapter.ViewHolder>() {
|
||||||
|
|
||||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
@ -29,9 +29,9 @@ class ToDoAdapter(val todoList: MutableList<ToDo>, val viewModelStoreOwner: View
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val progressViewModel =
|
val progressViewModel =
|
||||||
ViewModelProvider(viewModelStoreOwner).get(ProgressFragmentViewModel::class.java)
|
ViewModelProvider(viewModelStoreOwner)[ProgressFragmentViewModel::class.java]
|
||||||
val todoViewModel =
|
val todoViewModel =
|
||||||
ViewModelProvider(viewModelStoreOwner).get(ToDoFragmentViewModel::class.java)
|
ViewModelProvider(viewModelStoreOwner)[ToDoFragmentViewModel::class.java]
|
||||||
|
|
||||||
val view = LayoutInflater.from(parent.context)
|
val view = LayoutInflater.from(parent.context)
|
||||||
.inflate(R.layout.item_todo, parent, false)
|
.inflate(R.layout.item_todo, parent, false)
|
||||||
|
|
@ -87,8 +87,6 @@ class ToDoAdapter(val todoList: MutableList<ToDo>, val viewModelStoreOwner: View
|
||||||
}
|
}
|
||||||
todoList.add(ToDo(todo.uuid, 0, todo.content, todo.subject))
|
todoList.add(ToDo(todo.uuid, 0, todo.content, todo.subject))
|
||||||
|
|
||||||
todoViewModel.refreshData.value = 1
|
|
||||||
|
|
||||||
todoViewModel.insertTask(
|
todoViewModel.insertTask(
|
||||||
ToDoRoom(
|
ToDoRoom(
|
||||||
todo.uuid,
|
todo.uuid,
|
||||||
|
|
@ -97,6 +95,9 @@ class ToDoAdapter(val todoList: MutableList<ToDo>, val viewModelStoreOwner: View
|
||||||
todo.content
|
todo.content
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
todoViewModel.refreshData.value = 1
|
||||||
|
|
||||||
progressViewModel.updateProgress()
|
progressViewModel.updateProgress()
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
|
|
@ -108,11 +109,11 @@ class ToDoAdapter(val todoList: MutableList<ToDo>, val viewModelStoreOwner: View
|
||||||
val todo = todoList[position]
|
val todo = todoList[position]
|
||||||
holder.todoContext.text = todo.content
|
holder.todoContext.text = todo.content
|
||||||
holder.todoSubject.text = todo.subject
|
holder.todoSubject.text = todo.subject
|
||||||
if (!todo.isAnimated) {
|
/*if (!todo.isAnimated) {
|
||||||
holder.itemView.alpha = 0f
|
holder.itemView.alpha = 0f
|
||||||
holder.itemView.animate().alpha(1f).duration = 200
|
holder.itemView.animate().alpha(1f).duration = 200
|
||||||
todo.isAnimated = true
|
todo.isAnimated = true
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = todoList.size
|
override fun getItemCount() = todoList.size
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue