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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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