Achieve match icon status
continuous-integration/drone/push Build is passing Details

pull/8/head
Emre KARTAL 2 years ago
parent 81513146aa
commit 405f968c83

@ -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<Match>) :
}
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)

@ -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)
}

@ -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 }
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="350dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/border_rounded"

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<LinearLayout
android:layout_width="350dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="4dp"
android:background="@drawable/background"
android:gravity="center"
android:orientation="vertical"
@ -15,11 +16,24 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iconStatus"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="right"
android:layout_marginTop="8dp"
android:layout_marginBottom="7dp" />
</FrameLayout>
<TextView
android:id="@+id/DateCompetition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:ellipsize="end"
android:fontFamily="@font/mulish_bold"
@ -32,14 +46,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:baselineAligned="false">
android:baselineAligned="false"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
@ -110,7 +125,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView

Loading…
Cancel
Save