diff --git a/src/app/src/main/java/uca/iut/clermont/view/adapter/MatchesAdapter.kt b/src/app/src/main/java/uca/iut/clermont/view/adapter/MatchesAdapter.kt index b54566b..c3ad4b5 100644 --- a/src/app/src/main/java/uca/iut/clermont/view/adapter/MatchesAdapter.kt +++ b/src/app/src/main/java/uca/iut/clermont/view/adapter/MatchesAdapter.kt @@ -2,6 +2,7 @@ package uca.iut.clermont.view.adapter import android.view.LayoutInflater import android.view.ViewGroup +import androidx.core.view.marginTop import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import uca.iut.clermont.R @@ -33,10 +34,31 @@ class MatchesAdapter(private val recentMatches: Array) : } val date = recentMatches[position].date - - val formatter = SimpleDateFormat("dd-MM-yyyy", Locale.US) + date.add(Calendar.HOUR_OF_DAY, 2) + val formatter = SimpleDateFormat("dd/MM/yyyy' 'HH:mm", Locale.US) val formattedDate = formatter.format(date.time) + if (recentMatches[position].status == "IN_PLAY") { + with(holder.iconStatus) { + setImageResource(R.drawable.live) + layoutParams.width = 130 + layoutParams.height = 130 + (layoutParams as ViewGroup.MarginLayoutParams).apply { + topMargin = 0 + bottomMargin = 0 + } + } + + } + + if (recentMatches[position].status == "PAUSED") { + with(holder.iconStatus) { + setImageResource(R.drawable.mi_temp) + layoutParams.width = 100 + layoutParams.height = 100 + } + } + holder.dateCompetition.text = recentMatches[position].competition.name.plus(" : ").plus(formattedDate) Glide.with(holder.itemView.context) diff --git a/src/app/src/main/java/uca/iut/clermont/view/viewHolder/MatchHolder.kt b/src/app/src/main/java/uca/iut/clermont/view/viewHolder/MatchHolder.kt index cd63f51..6869eb1 100644 --- a/src/app/src/main/java/uca/iut/clermont/view/viewHolder/MatchHolder.kt +++ b/src/app/src/main/java/uca/iut/clermont/view/viewHolder/MatchHolder.kt @@ -13,6 +13,7 @@ class MatchHolder(view: View) : RecyclerView.ViewHolder(view) { val scoreAwayTeam: TextView val imageHomeTeam: ImageView val imageAwayTeam: ImageView + val iconStatus: ImageView val dateCompetition: TextView init { @@ -23,6 +24,7 @@ class MatchHolder(view: View) : RecyclerView.ViewHolder(view) { imageHomeTeam = view.findViewById(R.id.ImageFirstTeam) imageAwayTeam = view.findViewById(R.id.ImageSecondTeam) dateCompetition = view.findViewById(R.id.DateCompetition) + iconStatus = view.findViewById(R.id.iconStatus) } diff --git a/src/app/src/main/java/uca/iut/clermont/view/viewModel/HomeViewModel.kt b/src/app/src/main/java/uca/iut/clermont/view/viewModel/HomeViewModel.kt index 996ce80..4176542 100644 --- a/src/app/src/main/java/uca/iut/clermont/view/viewModel/HomeViewModel.kt +++ b/src/app/src/main/java/uca/iut/clermont/view/viewModel/HomeViewModel.kt @@ -14,7 +14,7 @@ class HomeViewModel : ViewModel() { fun loadMatches() = viewModelScope.launch { val matchResult = manager.matchesMgr.getItems() - matches.value = matchResult.filter { it.status == "FINISHED" } + matches.value = matchResult.filter { it.status != "TIMED" }.sortedByDescending { it.date } } } \ No newline at end of file diff --git a/src/app/src/main/res/drawable/live.png b/src/app/src/main/res/drawable/live.png new file mode 100644 index 0000000..127a50c Binary files /dev/null and b/src/app/src/main/res/drawable/live.png differ diff --git a/src/app/src/main/res/drawable/mi_temp.png b/src/app/src/main/res/drawable/mi_temp.png new file mode 100644 index 0000000..b3da61e Binary files /dev/null and b/src/app/src/main/res/drawable/mi_temp.png differ diff --git a/src/app/src/main/res/layout/cellule_favorite.xml b/src/app/src/main/res/layout/cellule_favorite.xml index 1afd0d7..949c04d 100644 --- a/src/app/src/main/res/layout/cellule_favorite.xml +++ b/src/app/src/main/res/layout/cellule_favorite.xml @@ -1,11 +1,11 @@ + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="5dp"> + + + + + + + android:baselineAligned="false" + android:gravity="center" + android:orientation="horizontal">