Task list improvements

This commit is contained in:
Phillip Thelen 2022-07-07 11:09:43 +02:00
parent 0e99d17812
commit 24aeaab80a
8 changed files with 52 additions and 14 deletions

View file

@ -2,10 +2,10 @@ package com.habitrpg.wearos.habitica.ui.adapters
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.habitrpg.android.habitica.databinding.RowSectionHeaderBinding
import com.habitrpg.android.habitica.databinding.RowTaskHeaderBinding
import com.habitrpg.common.habitica.extensions.layoutInflater
import com.habitrpg.wearos.habitica.models.tasks.Task
import com.habitrpg.wearos.habitica.ui.viewHolders.HeaderSectionViewHolder
import com.habitrpg.wearos.habitica.ui.viewHolders.HeaderTaskViewHolder
import com.habitrpg.wearos.habitica.ui.viewHolders.tasks.TaskViewHolder
open class TaskListAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(), BaseAdapter {
@ -25,7 +25,7 @@ open class TaskListAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(), Ba
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val inflater = parent.context.layoutInflater
return HeaderSectionViewHolder(RowSectionHeaderBinding.inflate(inflater, parent, false).root)
return HeaderTaskViewHolder(RowTaskHeaderBinding.inflate(inflater, parent, false).root)
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
@ -38,14 +38,14 @@ open class TaskListAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(), Ba
holder.itemView.setOnClickListener {
onTaskTapped?.invoke(item)
}
} else if (holder is HeaderSectionViewHolder){
} else if (holder is HeaderTaskViewHolder){
if (position == 0) {
holder.bind(title)
holder.bind(title, data.firstOrNull() is String)
holder.itemView.setOnClickListener {
onRefresh?.invoke()
}
} else {
holder.bind(data[position - 1] as String)
holder.bind(data[position - 1] as String, false)
}
}
}

View file

@ -0,0 +1,15 @@
package com.habitrpg.wearos.habitica.ui.viewHolders
import android.view.View
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import com.habitrpg.android.habitica.databinding.RowTaskHeaderBinding
class HeaderTaskViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind(title: String, showDone: Boolean) {
binding.header.textView.text = title
binding.doneView.isVisible = showDone
}
val binding = RowTaskHeaderBinding.bind(itemView)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/watch_purple_200"
tools:text="Header Text"
style="@style/Text.Body1"
android:layout_margin="6dp"/>
android:textColor="@color/watch_purple_200"
tools:text="Header Text"
style="@style/Text.Body1"
android:layout_margin="6dp"/>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
<include
layout="@layout/row_section_header"
android:id="@+id/header" />
<TextView
android:id="@+id/done_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/all_done_today"
android:layout_marginHorizontal="@dimen/spacing_xlarge"
android:drawableTop="@drawable/done_sparkles"
android:drawablePadding="4dp"
style="@style/Text.Body1"
android:textColor="@color/watch_gray_200"
android:layout_marginTop="24dp"
android:layout_marginBottom="32dp"/>
</LinearLayout>

View file

@ -37,4 +37,5 @@
<string name="some_food">Some Food</string>
<string name="continue_on_your_phone">Continue on your phone</string>
<string name="levelup_description">You leveled up through all your hard work!</string>
<string name="all_done_today">All done today!</string>
</resources>