Commit a7e7fa9f authored by Lukas Bersinger's avatar Lukas Bersinger
Browse files

bugfixes, show dueDate in list

parent d3df56d6
......@@ -7,6 +7,7 @@ import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import ch.ost.rj.mge.miniproject.tasktracker.R
import ch.ost.rj.mge.miniproject.tasktracker.models.Task
import java.text.DateFormat
class TaskListAdapter(private val dataset: List<Task>) :
......@@ -26,6 +27,9 @@ class TaskListAdapter(private val dataset: List<Task>) :
val titleView = holder.cardView.findViewById<TextView>(R.id.txtTitle)
titleView.text = activeTask.name
val dueDateView = holder.cardView.findViewById<TextView>(R.id.txtCardDueDate)
dueDateView.text = DateFormat.getDateInstance().format(activeTask.dueDate!!.time)
}
override fun getItemCount(): Int {
......
......@@ -18,7 +18,7 @@ import ch.ost.rj.mge.miniproject.tasktracker.repositories.TaskRepository
* create an instance of this fragment.
*/
class TaskListFragment : Fragment() {
private lateinit var tasks: List<Task>
private var tasks: List<Task>? = null
private lateinit var recyclerView: RecyclerView
private lateinit var viewAdapter: RecyclerView.Adapter<*>
......@@ -26,9 +26,6 @@ class TaskListFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewManager = LinearLayoutManager(context)
viewAdapter = TaskListAdapter(tasks)
}
override fun onCreateView(
......@@ -38,6 +35,9 @@ class TaskListFragment : Fragment() {
// Inflate the layout for this fragment
val fragment = inflater.inflate(R.layout.fragment_task_list, container, false)
viewManager = LinearLayoutManager(context)
viewAdapter = tasks?.let { TaskListAdapter(it) }!!
recyclerView = fragment.findViewById(R.id.rvTaskList)
recyclerView.apply {
setHasFixedSize(true)
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
app:contentPadding="16dp">
<TextView
android:id="@+id/txtTitle"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txtCardDueDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txtTitle" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment