Commit 4ccdaeff authored by Niklas Fix's avatar Niklas Fix 🎓

add #61

parent be60e2f5
......@@ -43,7 +43,7 @@ class ChallengeSection(
}
override fun onBindHeaderViewHolder(holder: RecyclerView.ViewHolder?) {
(holder as DuelSectionViewHolder).bind(context.getString(R.string.challenges))
(holder as DuelSectionViewHolder).bind(context.getString(R.string.challenges), false)
}
override fun getHeaderViewHolder(view: View?): RecyclerView.ViewHolder {
......
......@@ -29,7 +29,7 @@ class FinishedDuelSection(
}
override fun onBindItemViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
(holder as DuelViewHolder).bind(sectionDuels[position])
(holder as DuelViewHolder).bind(sectionDuels[position], true)
}
override fun getItemViewHolder(view: View?): RecyclerView.ViewHolder {
......@@ -42,7 +42,7 @@ class FinishedDuelSection(
}
override fun onBindHeaderViewHolder(holder: RecyclerView.ViewHolder?) {
(holder as DuelSectionViewHolder).bind(context.getString(R.string.finished_duels))
(holder as DuelSectionViewHolder).bind(context.getString(R.string.finished_duels), true)
}
override fun getHeaderViewHolder(view: View?): RecyclerView.ViewHolder {
......
......@@ -29,7 +29,7 @@ class RunningDuelSection(
}
override fun onBindItemViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
(holder as DuelViewHolder).bind(sectionDuels[position])
(holder as DuelViewHolder).bind(sectionDuels[position], false)
}
override fun getItemViewHolder(view: View?): RecyclerView.ViewHolder {
......@@ -42,7 +42,7 @@ class RunningDuelSection(
}
override fun onBindHeaderViewHolder(holder: RecyclerView.ViewHolder?) {
(holder as DuelSectionViewHolder).bind(context.getString(R.string.running_duels))
(holder as DuelSectionViewHolder).bind(context.getString(R.string.running_duels), false)
}
override fun getHeaderViewHolder(view: View?): RecyclerView.ViewHolder {
......
......@@ -9,7 +9,10 @@ class DuelSectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
private var mSectionName: TextView = itemView.findViewById(R.id.textView_duel_section_name)
fun bind(sectionName: String) {
fun bind(sectionName: String, finished: Boolean) {
mSectionName.text = sectionName
if (finished) {
mSectionName.alpha = 0.5f
}
}
}
\ No newline at end of file
......@@ -6,6 +6,8 @@ import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.RecyclerView
import de.akamu.tudarmstadt.R
import de.akamu.tudarmstadt.features.dashboard.duels.listener.DuelClickListener
......@@ -13,10 +15,16 @@ import de.akamu.tudarmstadt.model.Duel
import de.akamu.tudarmstadt.model.DuelPlayer
import de.akamu.tudarmstadt.util.AkamuResource
class DuelViewHolder(itemView: View, var context: Context, private var duelClickListener: DuelClickListener, private var ID_ME: Int) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
class DuelViewHolder(
itemView: View,
var context: Context,
private var duelClickListener: DuelClickListener,
private var ID_ME: Int
) : RecyclerView.ViewHolder(itemView), View.OnClickListener {
private lateinit var mDuel: Duel
private var mCardParent: CardView = itemView.findViewById(R.id.CardParent)
private var mOpponentName: TextView = itemView.findViewById(R.id.duel_item_opp_username)
private var mOpponentTitle: TextView = itemView.findViewById(R.id.duel_item_opp_title)
private var mOpponentAvatar: ImageView = itemView.findViewById(R.id.duel_item_opp_avatar)
......@@ -27,7 +35,7 @@ class DuelViewHolder(itemView: View, var context: Context, private var duelClick
buttonDuelAction.setOnClickListener(this)
}
fun bind(duel: Duel) {
fun bind(duel: Duel, finished: Boolean) {
mDuel = duel
val duelPlayers = duel.participants
......@@ -35,7 +43,7 @@ class DuelViewHolder(itemView: View, var context: Context, private var duelClick
val me: DuelPlayer
val opp: DuelPlayer
if(duelPlayers == null) {
if (duelPlayers == null) {
return
}
......@@ -58,6 +66,9 @@ class DuelViewHolder(itemView: View, var context: Context, private var duelClick
buttonDuelAction.text = getDuelButtonText(duel, me, opp)
buttonDuelAction.background = getDuelButtonBackground(buttonDuelAction.text)
if (finished) {
mCardParent.alpha = 0.5f
}
}
private fun getDuelButtonText(duel: Duel, me: DuelPlayer, opp: DuelPlayer): CharSequence? {
......
<?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="140dp"
app:cardUseCompatPadding="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/CardParent"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ConstraintLayoutDuelAction"
android:layout_width="160dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/duel_item_score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="40dp"
android:paddingEnd="4dp"
android:text="28 : 23"
android:textAlignment="center"
android:textColor="@color/darkText"
android:textSize="22sp"
android:textStyle="bold"
android:maxLines="1"
app:layout_constraintBottom_toTopOf="@id/buttonDuelAction"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText,RtlSymmetry"/>
<Button
android:id="@+id/buttonDuelAction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPlayWon"
android:foreground="?selectableItemBackground"
android:paddingStart="20dp"
android:text="PLAY"
android:textAlignment="center"
android:textColor="@color/textWhite"
android:textSize="21sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:ignore="HardcodedText,RtlSymmetry"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/DuelPolygonShit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="95dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlSymmetry">
<include layout="@layout/item_duel_list_background"/>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ConstraintLayoutOpponentInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="5dp"
app:layout_constraintEnd_toStartOf="@id/GuidelineNameConstraint"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/duel_item_opp_avatar"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:contentDescription="@string/user_avatar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/ConstraintLayoutOpponentInfo"/>
<LinearLayout
android:id="@+id/LinearLayoutUserTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:orientation="vertical"
app:layout_constraintStart_toEndOf="@+id/duel_item_opp_avatar"
app:layout_constraintTop_toTopOf="@+id/duel_item_opp_avatar"
app:layout_constraintEnd_toEndOf="@id/ConstraintLayoutOpponentInfo">
<TextView
android:id="@+id/duel_item_opp_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="Man-in-the-middle"
android:textColor="@color/textWhite"
tools:ignore="HardcodedText"/>
<TextView
android:id="@+id/duel_item_opp_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="@string/app_name"
android:textColor="@color/textWhite"
android:textSize="18sp"
android:textStyle="bold"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/GuidelineNameConstraint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintGuide_end="125dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="140dp"
android:id="@+id/CardParent"
app:cardUseCompatPadding="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ConstraintLayoutDuelAction"
android:layout_width="160dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/duel_item_score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingStart="40dp"
android:paddingEnd="4dp"
android:text="28 : 23"
android:textAlignment="center"
android:textColor="@color/darkText"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@id/buttonDuelAction"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText,RtlSymmetry" />
<Button
android:id="@+id/buttonDuelAction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPlayWon"
android:foreground="?selectableItemBackground"
android:paddingStart="20dp"
android:text="PLAY"
android:textAlignment="center"
android:textColor="@color/textWhite"
android:textSize="21sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:ignore="HardcodedText,RtlSymmetry" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:id="@+id/DuelPolygonShit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="95dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlSymmetry">
<include layout="@layout/item_duel_list_background" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ConstraintLayoutOpponentInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="5dp"
app:layout_constraintEnd_toStartOf="@id/GuidelineNameConstraint"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/duel_item_opp_avatar"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:contentDescription="@string/user_avatar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/ConstraintLayoutOpponentInfo" />
<LinearLayout
android:id="@+id/LinearLayoutUserTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="@id/ConstraintLayoutOpponentInfo"
app:layout_constraintStart_toEndOf="@+id/duel_item_opp_avatar"
app:layout_constraintTop_toTopOf="@+id/duel_item_opp_avatar">
<TextView
android:id="@+id/duel_item_opp_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="Man-in-the-middle"
android:textColor="@color/textWhite"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/duel_item_opp_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="@string/app_name"
android:textColor="@color/textWhite"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/GuidelineNameConstraint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintGuide_end="125dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
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