Added start and detail fragments and beginning of the gyroscope for the soccer ball ⚽
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
0c06af628b
commit
f7205e70fa
File diff suppressed because one or more lines are too long
@ -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>
|
@ -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?
|
||||
)
|
@ -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)
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
@ -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>
|
@ -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>
|
Loading…
Reference in new issue