Update UI detail
continuous-integration/drone/push Build is passing Details

Masterdetail_Next_Step
Emre KARTAL 2 years ago
parent 47fc7d8e15
commit 8c0b5a4464

@ -4,14 +4,20 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import com.bumptech.glide.Glide
import uca.iut.clermont.R import uca.iut.clermont.R
import uca.iut.clermont.model.Competition
class DetailFragment : Fragment() { class DetailFragment : Fragment() {
private var isLiked = false private var isLiked = false
private lateinit var competition: Competition
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
@ -21,8 +27,19 @@ class DetailFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_detail, container, false) val view = inflater.inflate(R.layout.fragment_detail, container, false)
val id = arguments?.getInt("idItem")!!
competition = (activity as MainActivity).manager.competitionsMgr.getItemById(id)!!
initializeView(view)
return view;
}
private fun initializeView(view: View) {
val button = view.findViewById<ImageButton>(R.id.buttonLike) val button = view.findViewById<ImageButton>(R.id.buttonLike)
val buttonExit = view.findViewById<ImageButton>(R.id.buttonExit) val buttonExit = view.findViewById<ImageButton>(R.id.buttonExit)
var ImageHeader = view.findViewById<ImageView>(R.id.imageDetail)
var titleHeader = view.findViewById<TextView>(R.id.title)
buttonExit.setOnClickListener { buttonExit.setOnClickListener {
findNavController().navigate(R.id.favoriteFragment) findNavController().navigate(R.id.favoriteFragment)
@ -30,11 +47,15 @@ class DetailFragment : Fragment() {
button.setOnClickListener { button.setOnClickListener {
isLiked = !isLiked isLiked = !isLiked
button.setImageResource(if (isLiked) R.drawable.full_like else R.drawable.empty_like) button.setImageResource(if (isLiked) R.drawable.full_like else R.drawable.empty_like)
} }
return view; Glide.with(view.context)
.load(competition.emblem)
.error(R.drawable.imagenotfound)
.into(ImageHeader)
titleHeader.text = competition.name
} }
} }

@ -6,11 +6,13 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button import android.widget.Button
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.ImageView
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import uca.iut.clermont.R import uca.iut.clermont.R
import uca.iut.clermont.model.Competition import uca.iut.clermont.model.Competition
import uca.iut.clermont.view.adapter.FavoritesAdapter import uca.iut.clermont.view.adapter.FavoritesAdapter
@ -24,8 +26,20 @@ class FavoriteFragment : Fragment(), FavoritesAdapter.OnItemClickListener {
): View? { ): View? {
val view = inflater.inflate(R.layout.fragment_favorite, container, false) val view = inflater.inflate(R.layout.fragment_favorite, container, false)
var competitions = (activity as MainActivity).manager.competitionsMgr.getItems() var competitions = (activity as MainActivity).manager.competitionsMgr.getItems()
initRecyclerView(view, competitions, this)
initializeView(view)
return view
}
private fun navigate() {
findNavController().navigate(R.id.homeFragment)
}
private fun initializeView(view: View) {
var buttonHome = view.findViewById<ImageButton>(R.id.buttonHome) var buttonHome = view.findViewById<ImageButton>(R.id.buttonHome)
val buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome) var buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome)
buttonHome.setOnClickListener { buttonHome.setOnClickListener {
navigate() navigate()
@ -33,17 +47,14 @@ class FavoriteFragment : Fragment(), FavoritesAdapter.OnItemClickListener {
buttonTextFavorite.setOnClickListener { buttonTextFavorite.setOnClickListener {
navigate() navigate()
} }
initRecyclerView(view, competitions, this)
return view
}
fun navigate() {
findNavController().navigate(R.id.homeFragment)
} }
private fun initRecyclerView(
view: View,
private fun initRecyclerView(view: View, favorites: List<Competition>, listener: FavoritesAdapter.OnItemClickListener) { favorites: List<Competition>,
listener: FavoritesAdapter.OnItemClickListener
) {
val recyclerViewFavorites = view.findViewById<RecyclerView>(R.id.listFavorites) val recyclerViewFavorites = view.findViewById<RecyclerView>(R.id.listFavorites)
with(recyclerViewFavorites) { with(recyclerViewFavorites) {
layoutManager = LinearLayoutManager(view.context) layoutManager = LinearLayoutManager(view.context)

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 602 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

@ -8,12 +8,14 @@
<ImageView <ImageView
android:id="@+id/imageDetail" android:id="@+id/imageDetail"
android:layout_width="match_parent" android:layout_width="200dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginTop="0dp" android:layout_marginTop="30dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background" android:src="@drawable/ic_launcher_background"
app:layout_constraintHeight_percent="0.25" app:layout_constraintHeight_percent="0.25"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageButton <ImageButton
@ -24,8 +26,8 @@
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:src="@drawable/exit_button" android:src="@drawable/exit_button"
app:layout_constraintStart_toStartOf="@+id/imageDetail" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/imageDetail" /> app:layout_constraintTop_toTopOf="parent" />
<ImageButton <ImageButton
android:id="@+id/buttonLike" android:id="@+id/buttonLike"
@ -35,17 +37,16 @@
android:layout_marginRight="15dp" android:layout_marginRight="15dp"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:src="@drawable/empty_like" android:src="@drawable/empty_like"
app:layout_constraintEnd_toEndOf="@+id/imageDetail" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/imageDetail" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/textViewRecentMatches" android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:fontFamily="@font/mulish_black" android:fontFamily="@font/mulish_black"
android:text="CA Paranaense" android:textColor="@color/black"
android:textColor="#FF2B2B"
android:textSize="25dp" android:textSize="25dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -62,7 +63,7 @@
android:textColor="@color/title" android:textColor="@color/title"
android:textSize="16dp" android:textSize="16dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches" /> app:layout_constraintTop_toBottomOf="@+id/title" />
<LinearLayout <LinearLayout
android:id="@+id/header" android:id="@+id/header"

Loading…
Cancel
Save