Correct error Date Matches 🐛
continuous-integration/drone/push Build is passing Details

pull/8/head
Emre KARTAL 2 years ago
parent 405f968c83
commit 31d8f6d0cf

@ -29,8 +29,10 @@ class HomeFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_home, container, false) val view = inflater.inflate(R.layout.fragment_home, container, false)
val text = view.findViewById<TextView>(R.id.textEmpty) val buttonFavorite = view.findViewById<ImageButton>(R.id.buttonFavorite)
val restartMatches = view.findViewById<ImageButton>(R.id.restartMatches)
val text = view.findViewById<TextView>(R.id.textEmpty)
viewModel.matches.observe(viewLifecycleOwner, Observer { matches -> viewModel.matches.observe(viewLifecycleOwner, Observer { matches ->
matches?.let { matches?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
@ -41,14 +43,16 @@ class HomeFragment : Fragment() {
} }
}) })
viewModel.loadMatches() displayMatches(view)
val buttonFavorite = view.findViewById<ImageButton>(R.id.buttonFavorite)
buttonFavorite.setOnClickListener { buttonFavorite.setOnClickListener {
findNavController().navigate(R.id.favoriteFragment) findNavController().navigate(R.id.favoriteFragment)
} }
restartMatches.setOnClickListener {
displayMatches(view)
}
return view return view
} }
@ -62,5 +66,9 @@ class HomeFragment : Fragment() {
} }
private fun displayMatches(view: View) {
viewModel.loadMatches()
}
} }

@ -2,7 +2,6 @@ package uca.iut.clermont.view.adapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.marginTop
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import uca.iut.clermont.R import uca.iut.clermont.R
@ -34,7 +33,6 @@ class MatchesAdapter(private val recentMatches: Array<Match>) :
} }
val date = recentMatches[position].date val date = recentMatches[position].date
date.add(Calendar.HOUR_OF_DAY, 2)
val formatter = SimpleDateFormat("dd/MM/yyyy' 'HH:mm", Locale.US) val formatter = SimpleDateFormat("dd/MM/yyyy' 'HH:mm", Locale.US)
val formattedDate = formatter.format(date.time) val formattedDate = formatter.format(date.time)

@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import uca.iut.clermont.api.ApiManager import uca.iut.clermont.api.ApiManager
import uca.iut.clermont.model.Match import uca.iut.clermont.model.Match
import java.util.*
class HomeViewModel : ViewModel() { class HomeViewModel : ViewModel() {
@ -13,8 +14,11 @@ class HomeViewModel : ViewModel() {
val matches = MutableLiveData<List<Match>?>() val matches = MutableLiveData<List<Match>?>()
fun loadMatches() = viewModelScope.launch { fun loadMatches() = viewModelScope.launch {
val matchResult = manager.matchesMgr.getItems() val matchResults = manager.matchesMgr.getItems()
matches.value = matchResult.filter { it.status != "TIMED" }.sortedByDescending { it.date } matches.value = matchResults.filter { it.status != "TIMED" }
.apply { forEach { it.date.add(Calendar.HOUR_OF_DAY, 2) } }
.sortedBy { it.competition.name }
.sortedByDescending { it.date }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

@ -95,21 +95,34 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/searchBarContainer" /> app:layout_constraintTop_toBottomOf="@+id/searchBarContainer" />
<ImageButton
android:id="@+id/restartMatches"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="20dp"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/restart"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/searchBarContainer" />
<TextView <TextView
android:id="@+id/textEmpty" android:id="@+id/textEmpty"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/title" android:textColor="@color/title"
android:textSize="20dp" android:textSize="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches" /> app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/listRecentsMatches" android:id="@+id/listRecentsMatches"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingBottom="200dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches" app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches"

Loading…
Cancel
Save