Added start and detail fragments and beginning of the gyroscope for the soccer ball
continuous-integration/drone/push Build is passing Details

fragment_navigation
Emre KARTAL 2 years ago
parent 0c06af628b
commit f7205e70fa

@ -1,4 +0,0 @@
<changelist name="Uncommitted_changes_before_Update_at_21_03_2023_09_05_[Changes]" date="1679385937643" recycled="true" deleted="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_21_03_2023_09_05_[Changes]/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Update at 21/03/2023 09:05 [Changes]" />
</changelist>

@ -13,7 +13,7 @@ class StubData : DataManager() {
override val areaMgr: AreaManager = StubAreaManager(this)
override val peopleMgr: PeopleManager = StubPeopleManager(this)
override val matchesMgr: MatchesManager = StubMatchesManager(this)
override val competitionsMgr: CompetitionsManager = StubCompetitionsManager()
override val competitionsMgr: CompetitionsManager = StubCompetitionsManager(this)
override val teamsMgr: TeamsManager = StubTeamsManager(this)
private val areaList = listOf(
@ -374,6 +374,33 @@ class StubData : DataManager() {
)
}
val competitionList: MutableList<Competition> = mutableListOf()
fun initCompetitions() {
competitionList.add(
Competition(
1,
"Campeonato Brasileiro Série A",
"BSA",
"LEAGUE",
"https://crests.football-data.org/764.svg",
Season(1557, Calendar.getInstance().apply { set(2023, Calendar.MARCH, 15) }, Calendar.getInstance().apply { set(2022, Calendar.DECEMBER, 3) },1, null),
areaList[2],
)
)
competitionList.add(
Competition(
2,
"Championship",
"ELC",
"LEAGUE",
"https://crests.football-data.org/PL.png",
Season(1557, Calendar.getInstance().apply { set(2023, Calendar.MARCH, 15) }, Calendar.getInstance().apply { set(2022, Calendar.DECEMBER, 3) },1, null),
areaList[2],
)
)
}
class StubAreaManager(private val parent: StubData) : AreaManager {
override fun getItemsByName(substring: String) =
@ -402,18 +429,13 @@ class StubData : DataManager() {
}
class StubCompetitionsManager : CompetitionsManager {
override fun getItemsByName(substring: String): List<Competition> {
throw java.lang.Exception("Don't call this function")
}
class StubCompetitionsManager(private val parent: StubData) : CompetitionsManager {
override fun getItemsByName(substring: String) =
parent.competitionList.filter { it.name.contains(substring, ignoreCase = true) }
override fun getItems(): List<Competition> {
throw java.lang.Exception("Don't call this function")
}
override fun getItems() = parent.competitionList
override fun getItemById(id: Int): Competition? {
throw java.lang.Exception("Don't call this function")
}
override fun getItemById(id: Int) = parent.competitionList.find { it.id == id }
}

@ -1,11 +1,11 @@
package uca.iut.clermont.model
import java.util.Date
import java.util.Calendar
class Season(
val id: Int,
val startDate: Date,
val endDate: Date,
val startDate: Calendar,
val endDate: Calendar,
val currentMatchday: Int,
val winner: Int
val winner: Int?
)

@ -4,8 +4,17 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageButton
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import uca.iut.clermont.R
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.MatchesAdapter
class FavoriteFragment: Fragment() {
override fun onCreateView(
@ -13,6 +22,34 @@ class FavoriteFragment: Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_favorite, container, false)
val view = inflater.inflate(R.layout.fragment_favorite, container, false)
val competitions = (activity as MainActivity).manager.competitionsMgr.getItems()
var buttonHome = view.findViewById<ImageButton>(R.id.buttonHome)
val buttonTextFavorite = view.findViewById<Button>(R.id.buttonTextHome)
buttonHome.setOnClickListener {
navigate()
}
buttonTextFavorite.setOnClickListener {
navigate()
}
initRecyclerView(view, competitions)
return view
}
fun navigate() {
findNavController().navigate(R.id.homeFragment)
}
private fun initRecyclerView(view: View, favorites: List<Competition>) {
val recyclerViewFavorites = view.findViewById<RecyclerView>(R.id.listFavorites)
with(recyclerViewFavorites) {
layoutManager = LinearLayoutManager(view.context)
adapter = FavoritesAdapter(favorites.toList().toTypedArray())
}
}
}

@ -4,7 +4,9 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import uca.iut.clermont.R
@ -22,12 +24,18 @@ class HomeFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_home, container, false)
val matches = (activity as MainActivity).manager.matchesMgr.getItems()
val buttonFavorite = view.findViewById<ImageButton>(R.id.buttonFavorite)
buttonFavorite.setOnClickListener {
findNavController().navigate(R.id.favoriteFragment)
}
initRecyclerView(view, matches)
return view
}
private fun initRecyclerView(view: View, matches: List<Match>) {
val recyclerViewMatches = view.findViewById<RecyclerView>(R.id.ListRecentsMatches)
val recyclerViewMatches = view.findViewById<RecyclerView>(R.id.listRecentsMatches)
with(recyclerViewMatches) {
layoutManager = LinearLayoutManager(view.context)
adapter = MatchesAdapter(matches.toList().toTypedArray())

@ -44,18 +44,13 @@ class MainActivity : AppCompatActivity() {
manager.initTeams()
manager.initMatches()
manager.initCompetitions()
val navHostFragment =
supportFragmentManager.findFragmentById(R.id.fragment) as NavHostFragment
val navController = navHostFragment.navController
//val imageFirstTeam = findViewById<ImageView>(R.id.ImageFirstTeam)
/*Glide.with(this)
.load("https://crests.football-data.org/1765.svg")
.error(R.drawable.imagenotfound)
.into(imageFirstTeam)*/
}

@ -0,0 +1,82 @@
package uca.iut.clermont.view
import android.animation.ObjectAnimator
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.fragment.app.Fragment
import uca.iut.clermont.R
class StartFragment : Fragment(), SensorEventListener {
private lateinit var ball: ImageView
private lateinit var sensorManager: SensorManager
private lateinit var accelerometer: Sensor
private var lastX = 0f
private var lastY = 0f
private var lastZ = 0f
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_start, container, false)
ball = view.findViewById(R.id.ball)
sensorManager = activity?.getSystemService(Context.SENSOR_SERVICE) as SensorManager
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL)
return view
}
override fun onSensorChanged(event: SensorEvent) {
val x = event.values[0]
val y = event.values[1]
val z = event.values[2]
val angleX = x / 9.81f
val angleY = y / 9.81f
if (Math.abs(angleX) > 0.1) {
// Déplacer la balle à droite ou à gauche en fonction de la direction du mouvement
val deltaX = angleX * 20f // La vitesse de déplacement est de 20 pixels par seconde
ObjectAnimator.ofFloat(ball, View.TRANSLATION_X, ball.x + deltaX).start()
// Faire tourner la balle pendant qu'elle se déplace
ObjectAnimator.ofFloat(ball, View.ROTATION, -angleX * 70f).start()
}
lastX = x
lastY = y
lastZ = z
}
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {
}
override fun onResume() {
super.onResume()
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL)
}
override fun onPause() {
super.onPause()
sensorManager.unregisterListener(this)
}
}

@ -0,0 +1,30 @@
package uca.iut.clermont.view.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import uca.iut.clermont.R
import uca.iut.clermont.model.Competition
import uca.iut.clermont.view.viewHolder.FavoriteHolder
class FavoritesAdapter(private val favoriteCompetition: Array<Competition> ) : RecyclerView.Adapter<FavoriteHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FavoriteHolder {
return FavoriteHolder(
LayoutInflater.from(parent.context).inflate(R.layout.cellule_favorite, parent, false)
)
}
override fun onBindViewHolder(holder: FavoriteHolder, position: Int) {
holder.textFavorites.text = favoriteCompetition[position].name
Glide.with(holder.itemView.context)
.load(favoriteCompetition[position].emblem)
.error(R.drawable.imagenotfound)
.into(holder.imageFavorites)
}
override fun getItemCount() = favoriteCompetition.size
}

@ -0,0 +1,17 @@
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)
}
}

@ -12,12 +12,10 @@ class MatchHolder(view: View) : RecyclerView.ViewHolder(view) {
val scoreAwayTeam: TextView
init {
// Define click listener for the ViewHolder's View
titleFirstTeam = view.findViewById(R.id.TitleFirstTeam)
titleSecondTeam = view.findViewById(R.id.TitleSecondTeam)
scoreHomeTeam = view.findViewById(R.id.ScoreHomeTeam)
scoreAwayTeam = view.findViewById(R.id.ScoreAwayTeam)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -15,7 +15,6 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:defaultNavHost="true"
app:navGraph="@navigation/my_nav" />

@ -22,12 +22,12 @@
android:layout_marginVertical="10dp" />
<TextView
android:id="@+id/textFavorites"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/mulish_bold"
android:maxLines="3"
android:text="Campeonato Brasileiro Série A"
android:textColor="@color/black"
android:textSize="18dp" />

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

@ -17,19 +17,23 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
<ImageButton
android:id="@+id/buttonHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/arrow" />
<TextView
<Button
android:id="@+id/buttonTextHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@android:color/transparent"
android:fontFamily="@font/mulish_bold"
android:text="Exit"
android:textColor="@color/title"
android:textSize="26dp" />
android:textSize="26dp"
android:textAllCaps="false" />
</LinearLayout>
@ -45,5 +49,13 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/exitContainer" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listFavorites"
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/textFavorites" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -7,17 +7,35 @@
android:paddingHorizontal="30dp"
tools:context=".view.HomeFragment">
<TextView
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
<FrameLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Hello Varun"
android:textColor="@color/title"
android:textSize="20sp"
android:textStyle="bold"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textColor="@color/title"
android:textSize="20sp"
android:textStyle="bold" />
<ImageButton
android:id="@+id/buttonFavorite"
android:layout_width="34dp"
android:layout_height="34dp"
android:layout_gravity="right"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/icon_like" />
</FrameLayout>
<TextView
android:id="@+id/textViewSubtitle"
@ -29,7 +47,7 @@
android:textColor="@color/title"
android:textSize="28sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewTitle" />
app:layout_constraintTop_toBottomOf="@+id/header" />
<LinearLayout
android:id="@+id/searchBarContainer"
@ -78,7 +96,7 @@
app:layout_constraintTop_toBottomOf="@+id/searchBarContainer" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ListRecentsMatches"
android:id="@+id/listRecentsMatches"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/ball"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ball"
android:layout_centerInParent="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -2,7 +2,16 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_nav"
app:startDestination="@id/homeFragment">
app:startDestination="@id/startFragment">
<fragment
android:id="@+id/startFragment"
android:name="uca.iut.clermont.view.StartFragment"
android:label="StartFragment" >
<action
android:id="@+id/action_startFragment_to_homeFragment2"
app:destination="@id/homeFragment" />
</fragment>
<fragment
android:id="@+id/homeFragment"
@ -12,6 +21,7 @@
android:id="@+id/action_homeFragment_to_favoriteFragment"
app:destination="@id/favoriteFragment" />
</fragment>
<fragment
android:id="@+id/favoriteFragment"
android:name="uca.iut.clermont.view.FavoriteFragment"
@ -20,4 +30,5 @@
android:id="@+id/action_favoriteFragment_to_homeFragment"
app:destination="@id/homeFragment" />
</fragment>
</navigation>
Loading…
Cancel
Save