many things done

This commit is contained in:
Raphael
2025-03-10 16:54:05 +01:00
parent e46b7c2e26
commit 6177e0d51f
7 changed files with 203 additions and 203 deletions

View File

@@ -1,62 +1,62 @@
package com.dreamteam.timelapse package com.dreamteam.timelapse
import android.content.Context import android.content.Context
import android.graphics.Bitmap import android.graphics.Bitmap
import android.util.Log import android.util.Log
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.ImageView import android.widget.ImageView
import android.widget.Toast import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget import com.bumptech.glide.request.target.SimpleTarget
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.IOException import java.io.IOException
import com.bumptech.glide.request.transition.Transition import com.bumptech.glide.request.transition.Transition
class ImageAdapter(private val imageUrls: List<String>) : RecyclerView.Adapter<ImageAdapter.ImageViewHolder>() { class ImageAdapter(private val imageUrls: List<String>) : RecyclerView.Adapter<ImageAdapter.ImageViewHolder>() {
// ViewHolder qui contient l'ImageView // ViewHolder qui contient l'ImageView
class ImageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { class ImageViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val imageView: ImageView = itemView.findViewById(R.id.imageView) val imageView: ImageView = itemView.findViewById(R.id.imageView)
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ImageViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_image, parent, false) val view = LayoutInflater.from(parent.context).inflate(R.layout.item_image, parent, false)
return ImageViewHolder(view) return ImageViewHolder(view)
} }
override fun onBindViewHolder(holder: ImageViewHolder, position: Int) { override fun onBindViewHolder(holder: ImageViewHolder, position: Int) {
val imageUrl = imageUrls[position] val imageUrl = imageUrls[position]
//Log.e("ImageAdapter", imageUrl) //Log.e("ImageAdapter", imageUrl)
Glide.with(holder.itemView.context) Glide.with(holder.itemView.context)
.load(imageUrl) // Charge l'image via Glide .load(imageUrl) // Charge l'image via Glide
.into(holder.imageView) // Affiche l'image dans l'ImageView .into(holder.imageView) // Affiche l'image dans l'ImageView
} }
private fun downloadImage(url: String, context: Context) { private fun downloadImage(url: String, context: Context) {
Glide.with(context) Glide.with(context)
.asBitmap() .asBitmap()
.load(url) .load(url)
.into(object : SimpleTarget<Bitmap>() { .into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) { override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
// Save the image to the app's internal storage // Save the image to the app's internal storage
val file = File(context.filesDir, "downloaded_image.jpg") val file = File(context.filesDir, "downloaded_image.jpg")
try { try {
val fileOutputStream = FileOutputStream(file) val fileOutputStream = FileOutputStream(file)
resource.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream) resource.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream)
fileOutputStream.flush() fileOutputStream.flush()
fileOutputStream.close() fileOutputStream.close()
Toast.makeText(context, "Image downloaded successfully", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Image downloaded successfully", Toast.LENGTH_SHORT).show()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
Toast.makeText(context, "Error downloading image", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Error downloading image", Toast.LENGTH_SHORT).show()
} }
} }
}) })
} }
override fun getItemCount(): Int = imageUrls.size override fun getItemCount(): Int = imageUrls.size
} }

View File

@@ -1,8 +1,8 @@
package com.dreamteam.timelapse.data package com.dreamteam.timelapse.data
data class Confirmation ( data class Confirmation (
val message: String, val message: String,
val id: Int val id: Int
){ ){
} }

View File

@@ -1,14 +1,14 @@
package com.dreamteam.timelapse.data package com.dreamteam.timelapse.data
import java.util.Date import java.util.Date
data class Measurement( data class Measurement(
val id: Int, val id: Int,
val project_id: Int, val project_id: Int,
val timestamp: Date, val timestamp: Date,
val path: String, val path: String,
val temperature: Float, val temperature: Float,
val humidity: Float, val humidity: Float,
val order_id: Int val order_id: Int
) { ) {
} }

View File

@@ -1,74 +1,74 @@
package com.dreamteam.timelapse.data package com.dreamteam.timelapse.data
import android.os.Parcel import android.os.Parcel
import android.os.Parcelable import android.os.Parcelable
import android.util.Log import android.util.Log
import com.dreamteam.timelapse.R import com.dreamteam.timelapse.R
import java.util.Date import java.util.Date
//{ //{
// "id": 1, // "id": 1,
// "creation": "2024-10-24T13:46:04.513Z", // "creation": "2024-10-24T13:46:04.513Z",
// "status": "test", // "status": "test",
// "description": "Projet de Test", // "description": "Projet de Test",
// "titre": "Test Project" // "titre": "Test Project"
//} //}
data class Project( data class Project(
val id: Int, val id: Int,
val name: String, val name: String,
val description: String, val description: String,
val start_date: Date, val start_date: Date,
val status: Int, val status: Int,
val thumbnail_url: String? val thumbnail_url: String?
) : Parcelable { ) : Parcelable {
fun getStatusText(): String{ fun getStatusText(): String{
Log.i("Project", "Status $status being trasnlated") Log.i("Project", "Status $status being trasnlated")
val statusArr = arrayOf("Brouillon", "En Cours", "Terminé", "Annulé") val statusArr = arrayOf("Brouillon", "En Cours", "Terminé", "Annulé")
return statusArr[status] return statusArr[status]
} }
fun getStatusColor(): Int{ fun getStatusColor(): Int{
return when (status) { return when (status) {
0 -> R.color.brouillon 0 -> R.color.brouillon
1 -> R.color.en_cours 1 -> R.color.en_cours
2 -> R.color.termine 2 -> R.color.termine
3 -> R.color.annule 3 -> R.color.annule
else -> R.color.default_badge else -> R.color.default_badge
} }
} }
// Constructor to recreate from Parcel // Constructor to recreate from Parcel
constructor(parcel: Parcel) : this( constructor(parcel: Parcel) : this(
parcel.readInt(), parcel.readInt(),
parcel.readString() ?: "", parcel.readString() ?: "",
parcel.readString() ?: "", parcel.readString() ?: "",
Date(parcel.readLong()), Date(parcel.readLong()),
parcel.readInt(), parcel.readInt(),
parcel.readString() parcel.readString()
) )
// Write object to Parcel // Write object to Parcel
override fun writeToParcel(parcel: Parcel, flags: Int) { override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(id) parcel.writeInt(id)
parcel.writeString(name) parcel.writeString(name)
parcel.writeString(description) parcel.writeString(description)
parcel.writeLong(start_date.time) parcel.writeLong(start_date.time)
parcel.writeInt(status) parcel.writeInt(status)
} }
// Describe the contents of the Parcel // Describe the contents of the Parcel
override fun describeContents(): Int = 0 override fun describeContents(): Int = 0
companion object CREATOR : Parcelable.Creator<Project> { companion object CREATOR : Parcelable.Creator<Project> {
override fun createFromParcel(parcel: Parcel): Project { override fun createFromParcel(parcel: Parcel): Project {
return Project(parcel) return Project(parcel)
} }
override fun newArray(size: Int): Array<Project?> { override fun newArray(size: Int): Array<Project?> {
return arrayOfNulls(size) return arrayOfNulls(size)
} }
} }
// fun getThumbnail(): String { // fun getThumbnail(): String {
// return images[0] // return images[0]
// } // }
} }

View File

@@ -1,12 +1,12 @@
package com.dreamteam.timelapse.data package com.dreamteam.timelapse.data
data class Video ( data class Video (
val id: Int, val id: Int,
val project_id: Int, val project_id: Int,
val measurement_ids: List<Int>, val measurement_ids: List<Int>,
val video_file: String?, val video_file: String?,
val resolution:String, val resolution:String,
val duration: Int, val duration: Int,
val status: Int, //0 pas fini, 1 fini val status: Int, //0 pas fini, 1 fini
val name: String val name: String
){} ){}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:adjustViewBounds="true"/> android:adjustViewBounds="true"/>

View File

@@ -1,31 +1,31 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root" android:id="@+id/layout_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:padding="16dp"> android:padding="16dp">
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="37dp" android:layout_height="37dp"
android:textSize="25dp" android:textSize="25dp"
android:text="Creation d'un projet" /> android:text="Creation d'un projet" />
<EditText <EditText
android:id="@+id/project_name_dialog" android:id="@+id/project_name_dialog"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Nom du projet" android:hint="Nom du projet"
android:inputType="text" /> android:inputType="text" />
<EditText <EditText
android:id="@+id/project_desc_dialog" android:id="@+id/project_desc_dialog"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Description du projet" android:hint="Description du projet"
android:inputType="text" android:inputType="text"
android:layout_marginTop="8dp"/> android:layout_marginTop="8dp"/>
</LinearLayout> </LinearLayout>