Realization of the masterdetail
continuous-integration/drone/push Build is passing Details

Gyroscope
Emre KARTAL 2 years ago
parent 14ebcb8554
commit 47fc7d8e15

@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageButton import android.widget.ImageButton
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import uca.iut.clermont.R import uca.iut.clermont.R
class DetailFragment : Fragment() { class DetailFragment : Fragment() {
@ -17,9 +18,15 @@ class DetailFragment : Fragment() {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
val view = inflater.inflate(R.layout.fragment_detail, container, false) val view = inflater.inflate(R.layout.fragment_detail, container, false)
val button = view.findViewById<ImageButton>(R.id.buttonLike) val button = view.findViewById<ImageButton>(R.id.buttonLike)
val buttonExit = view.findViewById<ImageButton>(R.id.buttonExit)
buttonExit.setOnClickListener {
findNavController().navigate(R.id.favoriteFragment)
}
button.setOnClickListener { button.setOnClickListener {
isLiked = !isLiked isLiked = !isLiked

@ -6,38 +6,34 @@ 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 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 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.model.Match
import uca.iut.clermont.view.adapter.FavoritesAdapter import uca.iut.clermont.view.adapter.FavoritesAdapter
import uca.iut.clermont.view.adapter.MatchesAdapter
class FavoriteFragment : Fragment() { class FavoriteFragment : Fragment(), FavoritesAdapter.OnItemClickListener {
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): 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()
val competitions = (activity as MainActivity).manager.competitionsMgr.getItems()
var buttonHome = view.findViewById<ImageButton>(R.id.buttonHome) var buttonHome = view.findViewById<ImageButton>(R.id.buttonHome)
val buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome) val buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome)
buttonHome.setOnClickListener { buttonHome.setOnClickListener {
navigate() navigate()
} }
buttonTextFavorite.setOnClickListener { buttonTextFavorite.setOnClickListener {
navigate() navigate()
} }
initRecyclerView(view, competitions, this)
initRecyclerView(view, competitions)
return view return view
} }
@ -45,11 +41,19 @@ class FavoriteFragment : Fragment() {
findNavController().navigate(R.id.homeFragment) findNavController().navigate(R.id.homeFragment)
} }
private fun initRecyclerView(view: View, favorites: List<Competition>) {
private fun initRecyclerView(view: View, 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)
adapter = FavoritesAdapter(favorites.toList().toTypedArray()) adapter = FavoritesAdapter(favorites.toList().toTypedArray(), listener)
} }
} }
override fun onItemClick(position: Int) {
var competitions = (activity as MainActivity).manager.competitionsMgr.getItems()
val bundle = bundleOf("idItem" to competitions[position].id)
findNavController().navigate(R.id.action_favoriteFragment_to_detailFragment, bundle)
}
} }

@ -44,7 +44,7 @@ class StartFragment : Fragment(), SensorEventListener {
val buttonFavorite = view.findViewById<ImageButton>(R.id.nextButton) val buttonFavorite = view.findViewById<ImageButton>(R.id.nextButton)
buttonFavorite.setOnClickListener { buttonFavorite.setOnClickListener {
findNavController().navigate(R.id.detailFragment) findNavController().navigate(R.id.homeFragment)
} }
return view return view

@ -1,15 +1,39 @@
package uca.iut.clermont.view.adapter package uca.iut.clermont.view.adapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
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
import uca.iut.clermont.model.Competition import uca.iut.clermont.model.Competition
import uca.iut.clermont.view.viewHolder.FavoriteHolder
class FavoritesAdapter(private val favoriteCompetition: Array<Competition>) : class FavoritesAdapter(
RecyclerView.Adapter<FavoriteHolder>() { private val favoriteCompetition: Array<Competition>,
private val listener: OnItemClickListener,
) :
RecyclerView.Adapter<FavoritesAdapter.FavoriteHolder>() {
inner class FavoriteHolder(view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {
val imageFavorites: ImageView
val textFavorites: TextView
init {
itemView.setOnClickListener(this)
imageFavorites = view.findViewById(R.id.imageFavorites)
textFavorites = view.findViewById(R.id.textFavorites)
}
override fun onClick(v: View?) {
val position = adapterPosition
listener.onItemClick(position)
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteHolder {
return FavoriteHolder( return FavoriteHolder(
LayoutInflater.from(parent.context).inflate(R.layout.cellule_favorite, parent, false) LayoutInflater.from(parent.context).inflate(R.layout.cellule_favorite, parent, false)
@ -23,9 +47,14 @@ class FavoritesAdapter(private val favoriteCompetition: Array<Competition>) :
.load(favoriteCompetition[position].emblem) .load(favoriteCompetition[position].emblem)
.error(R.drawable.imagenotfound) .error(R.drawable.imagenotfound)
.into(holder.imageFavorites) .into(holder.imageFavorites)
}
interface OnItemClickListener {
fun onItemClick(position: Int)
} }
override fun getItemCount() = favoriteCompetition.size
override fun getItemCount() = favoriteCompetition.size
} }

@ -1,17 +0,0 @@
package uca.iut.clermont.view.viewHolder
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import uca.iut.clermont.R
class FavoriteHolder(view: View) : RecyclerView.ViewHolder(view) {
val imageFavorites: ImageView
val textFavorites: TextView
init {
imageFavorites = view.findViewById(R.id.imageFavorites)
textFavorites = view.findViewById(R.id.textFavorites)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

@ -5,7 +5,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:layout_width="360dp" android:layout_width="350dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="@drawable/background" android:background="@drawable/background"

@ -13,9 +13,20 @@
android:layout_marginTop="0dp" android:layout_marginTop="0dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background" android:src="@drawable/ic_launcher_background"
app:layout_constraintHeight_percent="0.2" app:layout_constraintHeight_percent="0.25"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/buttonExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:background="@android:color/transparent"
android:src="@drawable/exit_button"
app:layout_constraintStart_toStartOf="@+id/imageDetail"
app:layout_constraintTop_toTopOf="@+id/imageDetail" />
<ImageButton <ImageButton
android:id="@+id/buttonLike" android:id="@+id/buttonLike"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -27,4 +38,171 @@
app:layout_constraintEnd_toEndOf="@+id/imageDetail" app:layout_constraintEnd_toEndOf="@+id/imageDetail"
app:layout_constraintTop_toTopOf="@+id/imageDetail" /> app:layout_constraintTop_toTopOf="@+id/imageDetail" />
<TextView
android:id="@+id/textViewRecentMatches"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/mulish_black"
android:text="CA Paranaense"
android:textColor="#FF2B2B"
android:textSize="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageDetail" />
<TextView
android:id="@+id/currentSeason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:fontFamily="@font/mulish_bold"
android:text="Current season"
android:textColor="@color/title"
android:textSize="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewRecentMatches" />
<LinearLayout
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/currentSeason">
<LinearLayout
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/background"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingHorizontal="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:fontFamily="@font/mulish_bold"
android:maxLines="2"
android:text="2023-04-15"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1DFDF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="@font/mulish_bold"
android:maxLines="1"
android:text="Start"
android:textColor="@color/text"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:paddingHorizontal="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:fontFamily="@font/mulish_bold"
android:maxLines="1"
android:text="14"
android:textColor="@color/black"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1DFDF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="@font/mulish_bold"
android:maxLines="1"
android:text="Number matches"
android:textColor="@color/text"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="90dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/background"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingHorizontal="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:fontFamily="@font/mulish_bold"
android:maxLines="3"
android:text="2023-12-15"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E1DFDF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:fontFamily="@font/mulish_bold"
android:maxLines="1"
android:text="End"
android:textColor="@color/text"
android:textSize="18dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/latestMatch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:fontFamily="@font/mulish_bold"
android:text="Latest Match"
android:textColor="@color/title"
android:textSize="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listRecentsMatches"
android:layout_width="wrap_content"
android:layout_height="500dp"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/latestMatch"
tools:itemCount="100" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -102,6 +102,6 @@
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"
tools:itemCount="100" /> tools:itemCount="10" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -10,7 +10,7 @@
android:label="StartFragment"> android:label="StartFragment">
<action <action
android:id="@+id/action_startFragment_to_detailFragment" android:id="@+id/action_startFragment_to_detailFragment"
app:destination="@id/detailFragment" /> app:destination="@id/homeFragment" />
</fragment> </fragment>
<fragment <fragment
@ -29,10 +29,17 @@
<action <action
android:id="@+id/action_favoriteFragment_to_homeFragment" android:id="@+id/action_favoriteFragment_to_homeFragment"
app:destination="@id/homeFragment" /> app:destination="@id/homeFragment" />
<action
android:id="@+id/action_favoriteFragment_to_detailFragment"
app:destination="@id/detailFragment" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/detailFragment" android:id="@+id/detailFragment"
android:name="uca.iut.clermont.view.DetailFragment" android:name="uca.iut.clermont.view.DetailFragment"
android:label="DetailFragment" /> android:label="DetailFragment">
<action
android:id="@+id/action_detailFragment_to_favoriteFragment"
app:destination="@id/favoriteFragment" />
</fragment>
</navigation> </navigation>
Loading…
Cancel
Save