Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

En/fix/todo #487

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ data class Todo(
@SerializedName("type")
var type: String,
@SerializedName("is_pinned")
var isPinned: Int//是否置顶
var isPinned: Int,//是否置顶
@SerializedName("end_time")
var endTime: String
) : Serializable {
companion object {
fun generateEmptyTodo(): Todo {
Expand All @@ -39,7 +41,8 @@ data class Todo(
RemindMode.generateDefaultRemindMode(),
System.currentTimeMillis(),
"other",
0
0,
""
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ class AddAffairFragment : BaseFragment(R.layout.affair_fragment_add_affair) {
RemindMode(0, arrayListOf(), arrayListOf(), arrayListOf(), translationToCalendar()),
System.currentTimeMillis(),
"other",
0
0,
translationToCalendar()
)

// 将时间转换为日历
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "406674d78acdddc2b83f25ff88982f6a",
"entities": [
{
"tableName": "todo_list",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`todoId` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `title` TEXT NOT NULL, `detail` TEXT NOT NULL, `isChecked` INTEGER NOT NULL, `remindMode` TEXT NOT NULL, `lastModifyTime` INTEGER NOT NULL, `type` TEXT NOT NULL, `endTime` TEXT, `isOver` INTEGER NOT NULL, `isPinned` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "todoId",
"columnName": "todoId",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "title",
"columnName": "title",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "detail",
"columnName": "detail",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isChecked",
"columnName": "isChecked",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "remindMode",
"columnName": "remindMode",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lastModifyTime",
"columnName": "lastModifyTime",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "endTime",
"columnName": "endTime",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "isOver",
"columnName": "isOver",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "isPinned",
"columnName": "isPinned",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"todoId"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '406674d78acdddc2b83f25ff88982f6a')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ class RepeatTimeRvAdapter(private val position: Int) :
*/

private var mClick: ((Int) -> Unit)? = null
private var mChangeRepeatTime: (() -> Unit)? = null
fun setOnItemClick(listener: (Int) -> Unit) {
mClick = listener
}
fun setOnChangeRepeatTime(listener: () -> Unit) {
mChangeRepeatTime = listener
}


inner class RepeatTimeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
Expand All @@ -48,6 +52,9 @@ class RepeatTimeRvAdapter(private val position: Int) :
repeatTimeCancel.setOnClickListener {
mClick?.invoke(absoluteAdapterPosition)
}
repeatTimeText.setOnClickListener {
mChangeRepeatTime?.invoke()
}
}

fun bind(repeatTime: String) {
Expand All @@ -65,6 +72,9 @@ class RepeatTimeRvAdapter(private val position: Int) :
imgDetailCancel.setOnClickListener {
mClick?.invoke(absoluteAdapterPosition)
}
tvDetailRepeat.setOnClickListener {
mChangeRepeatTime?.invoke()
}
}

fun bind(repeatTime: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SwipeDeleteRecyclerView @JvmOverloads constructor(

if (item != null) {
if (item.isPinned==1) {
mMenuViewWidth = menuView.width + layoutParams.leftMargin + layoutParams.rightMargin
mMenuViewWidth = menuView.width+menuView.width + layoutParams.leftMargin + layoutParams.rightMargin
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,18 @@ class TodoAllAdapter(private val listener: OnItemClickListener) :

if (isEnabled) {
if (item.isPinned==1){
type= if (item.endTime == "") VIEW_TYPE_MANAGE_PINNED else VIEW_TYPE_MANAGE_PINNED_NO
type= if (item.remindMode.notifyDateTime == "") VIEW_TYPE_MANAGE_PINNED else VIEW_TYPE_MANAGE_PINNED_NO
}else {
type = if (item.endTime == "") VIEW_TYPE_MANAGE else VIEW_TYPE_MANAGE_NO
type = if (item.remindMode.notifyDateTime == "") VIEW_TYPE_MANAGE else VIEW_TYPE_MANAGE_NO
}
} else {
// 检查置顶和 endTime 为空的条件
if (item.isPinned == 1) {
type = if (item.endTime != "") VIEW_TYPE_PINNED else VIEW_TYPE_PINNED_NO
} else if (currentTime > itemTime && item.endTime != "") {
type = if (item.remindMode.notifyDateTime != "") VIEW_TYPE_PINNED else VIEW_TYPE_PINNED_NO
} else if (currentTime > itemTime && item.remindMode.notifyDateTime != "") {
// 如果时间已过期
type = VIEW_TYPE_DELAY
} else if (item.endTime == "") {
} else if (item.remindMode.notifyDateTime == "") {
// endTime 为空的默认类型
type = VIEW_TYPE_DEFAULT_NO
}
Expand Down Expand Up @@ -349,7 +349,7 @@ class TodoAllAdapter(private val listener: OnItemClickListener) :
}
}
// 如果当前项是置顶项,则隐藏置顶按钮
topbutton.visibility = if (item.isPinned == 1) View.GONE else View.VISIBLE
// topbutton.visibility = if (item.isPinned == 1) View.GONE else View.VISIBLE
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.util.Locale
* date: 2024/8/22 19:09
*/
class TodoFeedAdapter :
ListAdapter<Todo, TodoFeedAdapter.todoFeedViewHolder>(DIFF_CALLBACK) {
ListAdapter<Todo, TodoFeedAdapter.TodoFeedViewHolder>(DIFF_CALLBACK) {

companion object {
private val DIFF_CALLBACK = object : DiffUtil.ItemCallback<Todo>() {
Expand All @@ -47,31 +47,33 @@ class TodoFeedAdapter :
mClick = listener
}

inner class todoFeedViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val todoTitle = itemView.findViewById<AppCompatTextView>(R.id.todo_tv_feed_title)
val todoFeedIv = itemView.findViewById<AppCompatImageView>(R.id.todo_iv_feed_bell)
val todoFeedTime = itemView.findViewById<AppCompatTextView>(R.id.todo_tv_feed_notify_time)
val icRight = itemView.findViewById<ImageView>(R.id.todo_iv_check_feed)
val defaultCheckbox = itemView.findViewById<CheckLineView>(R.id.todo_iv_todo_feed)
inner class TodoFeedViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val todoTitle = itemView.findViewById<AppCompatTextView>(R.id.todo_tv_feed_title)
private val todoFeedIv = itemView.findViewById<AppCompatImageView>(R.id.todo_iv_feed_bell)
private val todoFeedTime =
itemView.findViewById<AppCompatTextView>(R.id.todo_tv_feed_notify_time)
private val icRight = itemView.findViewById<ImageView>(R.id.todo_iv_check_feed)
private val defaultCheckbox = itemView.findViewById<CheckLineView>(R.id.todo_iv_todo_feed)

init {
defaultCheckbox.setOnClickListener {
defaultCheckbox.setStatusWithAnime(true){
mClick?.invoke(absoluteAdapterPosition)
}
todoTitle.setTextColor(
ContextCompat.getColor(
itemView.context,
R.color.todo_check_item_color
)
defaultCheckbox.setStatusWithAnime(true){
mClick?.invoke(absoluteAdapterPosition)
}
todoTitle.setTextColor(
ContextCompat.getColor(
itemView.context,
R.color.todo_check_item_color
)
todoFeedTime.setTextColor(
ContextCompat.getColor(
itemView.context,
R.color.todo_check_item_color
)
)
todoFeedTime.setTextColor(
ContextCompat.getColor(
itemView.context,
R.color.todo_check_item_color
)
todoFeedIv.setImageResource(R.drawable.todo_ic_addtodo_notice2)
icRight.visible()
)
todoFeedIv.setImageResource(R.drawable.todo_ic_addtodo_notice2)
icRight.visible()
}
todoTitle.setOnClickListener {
startActivity(getItem(absoluteAdapterPosition),itemView.context)
Expand All @@ -84,11 +86,13 @@ class TodoFeedAdapter :
defaultCheckbox.apply {
setStatusWithAnime(false)
}
todoTitle.setTextColor(getColor(com.mredrock.cyxbs.config.R.color.config_level_two_font_color))
icRight.gone()
if (todo.remindMode.notifyDateTime == "") {
todoFeedIv.visible()
todoFeedTime.visible()
if (todo.endTime == "") {
todoFeedIv.gone()
todoFeedTime.gone()
updateUi(false)
} else {
todoFeedTime.text = endTime
val itemTime = if (!todo.endTime.isNullOrEmpty()) {
Expand All @@ -103,23 +107,26 @@ class TodoFeedAdapter :
0L
}
val currentTime = System.currentTimeMillis()
if (currentTime > itemTime && itemTime != 0L){
defaultCheckbox.uncheckedColor = getColor(R.color.todo_check_overtime_color)
todoTitle.setTextColor(getColor(R.color.todo_text_overtime_color) )
todoFeedTime.setTextColor(getColor(R.color.todo_textTime_overtime_color))
todoFeedIv.setImageResource(R.drawable.todo_ic_addtodo_overtime_notice)
}
updateUi(currentTime > itemTime && itemTime != 0L)
}
}

private fun updateUi(isOverTime: Boolean) {
defaultCheckbox.uncheckedColor =
getColor(if (isOverTime) R.color.todo_check_overtime_color else R.color.todo_inner_check_eclipse_color)
todoTitle.setTextColor(getColor(if (isOverTime) R.color.todo_text_overtime_color else com.mredrock.cyxbs.config.R.color.config_level_two_font_color))
todoFeedTime.setTextColor(getColor(if (isOverTime) R.color.todo_textTime_overtime_color else R.color.todo_item_nf_time_color))
todoFeedIv.setImageResource(if (isOverTime) R.drawable.todo_ic_addtodo_overtime_notice else R.drawable.todo_ic_addtodo_notice2)
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): todoFeedViewHolder {
return todoFeedViewHolder(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoFeedViewHolder {
return TodoFeedViewHolder(
View.inflate(parent.context, R.layout.todo_rv_item_feed, null)
)
}

override fun onBindViewHolder(holder: todoFeedViewHolder, position: Int) {
override fun onBindViewHolder(holder: TodoFeedViewHolder, position: Int) {
holder.bind(getItem(position))
}
}
Loading
Loading