diff --git a/.gradle/8.0/checksums/checksums.lock b/.gradle/8.0/checksums/checksums.lock
index 4860e5b..27d9b8e 100644
Binary files a/.gradle/8.0/checksums/checksums.lock and b/.gradle/8.0/checksums/checksums.lock differ
diff --git a/.gradle/8.0/checksums/md5-checksums.bin b/.gradle/8.0/checksums/md5-checksums.bin
index bc15731..2dd2fed 100644
Binary files a/.gradle/8.0/checksums/md5-checksums.bin and b/.gradle/8.0/checksums/md5-checksums.bin differ
diff --git a/.gradle/8.0/checksums/sha1-checksums.bin b/.gradle/8.0/checksums/sha1-checksums.bin
index b419c8d..41955ce 100644
Binary files a/.gradle/8.0/checksums/sha1-checksums.bin and b/.gradle/8.0/checksums/sha1-checksums.bin differ
diff --git a/.gradle/8.0/executionHistory/executionHistory.bin b/.gradle/8.0/executionHistory/executionHistory.bin
index 50fcb99..1577863 100644
Binary files a/.gradle/8.0/executionHistory/executionHistory.bin and b/.gradle/8.0/executionHistory/executionHistory.bin differ
diff --git a/.gradle/8.0/executionHistory/executionHistory.lock b/.gradle/8.0/executionHistory/executionHistory.lock
index 876eab6..ceba8be 100644
Binary files a/.gradle/8.0/executionHistory/executionHistory.lock and b/.gradle/8.0/executionHistory/executionHistory.lock differ
diff --git a/.gradle/8.0/fileHashes/fileHashes.bin b/.gradle/8.0/fileHashes/fileHashes.bin
index e59113a..6fcc407 100644
Binary files a/.gradle/8.0/fileHashes/fileHashes.bin and b/.gradle/8.0/fileHashes/fileHashes.bin differ
diff --git a/.gradle/8.0/fileHashes/fileHashes.lock b/.gradle/8.0/fileHashes/fileHashes.lock
index 723c175..3b78ce0 100644
Binary files a/.gradle/8.0/fileHashes/fileHashes.lock and b/.gradle/8.0/fileHashes/fileHashes.lock differ
diff --git a/.gradle/8.0/fileHashes/resourceHashesCache.bin b/.gradle/8.0/fileHashes/resourceHashesCache.bin
index f1f9823..cb82d5d 100644
Binary files a/.gradle/8.0/fileHashes/resourceHashesCache.bin and b/.gradle/8.0/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index f0e4f8a..9d1bfd3 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
index 2456e0c..007ac5b 100644
Binary files a/.gradle/buildOutputCleanup/outputFiles.bin and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe
index c853116..f552e8a 100644
Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 0fc3113..51f6d40 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,9 @@
+
+
+
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 3ba9b9e..7d57701 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,7 +9,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -18,25 +27,25 @@
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
@@ -84,14 +93,16 @@
@@ -100,7 +111,7 @@
-
+
@@ -119,17 +130,20 @@
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"cidr.known.project.marker": "true",
"com.android.tools.idea.devicemanager.tab": "Physical",
- "last_opened_file_path": "C:/Users/Kate/AndroidStudioProjects/Ihonkina_PIbd-31_PMU/app/src/main/java/com/example/pmuapp/composeui/navigation",
- "settings.editor.selected.configurable": "experimental"
+ "last_opened_file_path": "C:/Users/Kate/AndroidStudioProjects/lab4compose",
+ "project.structure.last.edited": "Modules",
+ "project.structure.proportion": "0.17",
+ "project.structure.side.proportion": "0.2",
+ "settings.editor.selected.configurable": "project.kotlinCompiler"
}
}]]>
+
-
@@ -141,6 +155,7 @@
+
@@ -270,7 +285,28 @@
1697086828529
-
+
+ 1698235676591
+
+
+
+ 1698235676591
+
+
+ 1698258901683
+
+
+
+ 1698258901683
+
+
+ 1698258953508
+
+
+
+ 1698258953508
+
+
@@ -284,7 +320,7 @@
-
+
@@ -304,6 +340,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index ab6bc55..8277fc1 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -1,13 +1,13 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
+ id("com.google.devtools.ksp")
}
android {
namespace = "com.example.pmuapp"
compileSdk = 34
-
defaultConfig {
applicationId = "com.example.pmuapp"
minSdk = 24
@@ -31,17 +31,17 @@ android {
}
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
- jvmTarget = "1.8"
+ jvmTarget = "11"
}
buildFeatures {
compose = true
}
composeOptions {
- kotlinCompilerExtensionVersion = "1.4.3"
+ kotlinCompilerExtensionVersion = "1.4.5"
}
packaging {
resources {
@@ -50,10 +50,14 @@ android {
}
}
+
+
dependencies {
- implementation ("io.coil-kt:coil-compose:1.4.0")
+ // Core
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
+
+ // UI
implementation("androidx.activity:activity-compose:1.7.2")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.navigation:navigation-compose:2.6.0")
@@ -61,9 +65,18 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
- implementation("com.google.android.engage:engage-core:1.3.0")
- implementation("androidx.appcompat:appcompat:1.6.1")
- implementation("androidx.compose.ui:ui-graphics-android:1.5.3")
+ implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2")
+
+
+ // Room
+ val room_version = "2.5.2"
+ implementation("androidx.room:room-runtime:$room_version")
+ annotationProcessor("androidx.room:room-compiler:$room_version")
+ ksp("androidx.room:room-compiler:$room_version")
+ implementation("androidx.room:room-ktx:$room_version")
+ implementation("androidx.room:room-paging:$room_version")
+
+ // Tests
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
diff --git a/app/src/main/java/com/example/pmuapp/MainComposeActivity.kt b/app/src/main/java/com/example/pmuapp/MainComposeActivity.kt
index 646229f..a00b757 100644
--- a/app/src/main/java/com/example/pmuapp/MainComposeActivity.kt
+++ b/app/src/main/java/com/example/pmuapp/MainComposeActivity.kt
@@ -1,9 +1,11 @@
package com.example.pmuapp
import android.content.res.Configuration
+import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
+import androidx.annotation.RequiresApi
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
@@ -14,6 +16,7 @@ import com.example.pmuapp.composeui.navigation.MainNavbar
import com.example.pmuapp.ui.theme.PMUappTheme
class MainComposeActivity : ComponentActivity() {
+ @RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
@@ -29,6 +32,7 @@ class MainComposeActivity : ComponentActivity() {
}
}
+@RequiresApi(Build.VERSION_CODES.O)
@Preview(name = "Light Mode", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO)
@Preview(name = "Dark Mode", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
diff --git a/app/src/main/java/com/example/pmuapp/models/user/Dao/PetDao.kt b/app/src/main/java/com/example/pmuapp/models/user/Dao/PetDao.kt
new file mode 100644
index 0000000..a190a8f
--- /dev/null
+++ b/app/src/main/java/com/example/pmuapp/models/user/Dao/PetDao.kt
@@ -0,0 +1,36 @@
+package com.example.pmuapp.models.user.Dao;
+
+
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Transaction
+import androidx.room.Update;
+import com.example.pmuapp.models.user.model.Pet
+import com.example.pmuapp.models.user.model.PetWithImage
+
+import com.example.pmuapp.models.user.model.User;
+import kotlinx.coroutines.flow.Flow
+
+import java.util.List;
+
+
+@Dao
+interface PetDao {
+ @Query("SELECT * FROM pets")
+ fun getAllPets(): Flow>
+
+ @Insert
+ suspend fun insertPet(pet: Pet)
+
+ @Update
+ suspend fun updatePet(pet: Pet)
+
+ @Delete
+ suspend fun deletePet(pet: Pet)
+
+ @Transaction
+ @Query("SELECT * FROM pets WHERE id = :petId")
+ fun getPetWithImageById(petId: Int): Flow
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pmuapp/models/user/Dao/PetImageDao.kt b/app/src/main/java/com/example/pmuapp/models/user/Dao/PetImageDao.kt
new file mode 100644
index 0000000..3ceb406
--- /dev/null
+++ b/app/src/main/java/com/example/pmuapp/models/user/Dao/PetImageDao.kt
@@ -0,0 +1,24 @@
+package com.example.pmuapp.models.user.Dao
+
+import androidx.room.Dao
+import androidx.room.Delete
+import androidx.room.Insert
+import androidx.room.Query
+import androidx.room.Update
+import com.example.pmuapp.models.user.model.PetImage
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface PetImageDao {
+ @Insert
+ suspend fun insertPetImage(petImage: PetImage)
+
+ @Update
+ suspend fun updatePetImage(petImage: PetImage)
+
+ @Delete
+ suspend fun deletePetImage(petImage: PetImage)
+
+ @Query("SELECT * FROM pet_images WHERE pet_id = :petId")
+ fun getPetImagesByPetId(petId: Int): Flow>
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pmuapp/models/user/Dao/UserDao.kt b/app/src/main/java/com/example/pmuapp/models/user/Dao/UserDao.kt
new file mode 100644
index 0000000..f68d25e
--- /dev/null
+++ b/app/src/main/java/com/example/pmuapp/models/user/Dao/UserDao.kt
@@ -0,0 +1,34 @@
+package com.example.pmuapp.models.user.Dao;
+
+
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Update;
+
+import com.example.pmuapp.models.user.model.User;
+
+import java.util.List;
+
+
+@Dao
+interface UserDao {
+ @Query("select * from users")
+ suspend fun getAll(): List
+
+ @Insert
+ suspend fun insert(user: User)
+
+ @Update
+ suspend fun update(user: User)
+
+ @Delete
+ suspend fun delete(user: User)
+
+ @Query("SELECT * FROM users WHERE login = :login AND password = :password")
+ suspend fun getUserByLoginAndPassword(login: String, password: String): User?
+
+ @Query("SELECT * FROM users WHERE id = :userId")
+ suspend fun getUserWithPetsById(userId: Int): User?
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pmuapp/models/user/database/AppDatabase.kt b/app/src/main/java/com/example/pmuapp/models/user/database/AppDatabase.kt
new file mode 100644
index 0000000..27085a2
--- /dev/null
+++ b/app/src/main/java/com/example/pmuapp/models/user/database/AppDatabase.kt
@@ -0,0 +1,74 @@
+package com.example.pmuapp.models.user.database
+
+import android.content.Context
+import androidx.room.Database
+import androidx.room.Room
+import androidx.room.RoomDatabase
+import androidx.sqlite.db.SupportSQLiteDatabase
+import com.example.pmuapp.R
+import com.example.pmuapp.models.user.Dao.PetDao
+import com.example.pmuapp.models.user.Dao.PetImageDao
+import com.example.pmuapp.models.user.Dao.UserDao
+import com.example.pmuapp.models.user.model.Pet
+import com.example.pmuapp.models.user.model.PetImage
+import com.example.pmuapp.models.user.model.User
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+
+@Database(entities = [User::class, Pet::class], version = 1, exportSchema = false)
+abstract class AppDatabase : RoomDatabase() {
+ abstract fun userDao(): UserDao
+ abstract fun petDao(): PetDao
+ abstract fun petImageDao(): PetImageDao
+ companion object {
+ private const val DB_NAME: String = "pmy-db"
+
+ @Volatile
+ private var INSTANCE: AppDatabase? = null
+
+ private suspend fun populateDatabase() {
+ INSTANCE?.let { database ->
+ // Groups
+ val userDao = database.userDao()
+ val user1 = User(1, "Иван", "ivan", "111",R.drawable.avatar)
+ val user2 = User(2, "Анна", "ann", "111",R.drawable.avatar)
+ val user3 = User(3, "Макс", "max", "111",R.drawable.avatar)
+
+ userDao.insert(user1)
+ userDao.insert(user2)
+ userDao.insert(user3)
+
+
+ val petImageDao = database.petImageDao()
+ val petImage1 = PetImage(1, 1, R.drawable.pet1)
+ val petImage2 = PetImage(2, 2, R.drawable.pet2)
+ val petImage3 = PetImage(3, 3, R.drawable.pet3)
+
+ petImageDao.insertPetImage(petImage1)
+ petImageDao.insertPetImage(petImage2)
+ petImageDao.insertPetImage(petImage3)
+ }
+ }
+
+ fun getInstance(appContext: Context): AppDatabase {
+ return INSTANCE ?: synchronized(this) {
+ Room.databaseBuilder(
+ appContext,
+ AppDatabase::class.java,
+ DB_NAME
+ )
+ .addCallback(object : Callback() {
+ override fun onCreate(db: SupportSQLiteDatabase) {
+ super.onCreate(db)
+ CoroutineScope(Dispatchers.IO).launch {
+ populateDatabase()
+ }
+ }
+ })
+ .build()
+ .also { INSTANCE = it }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pmuapp/models/user/model/Pet.kt b/app/src/main/java/com/example/pmuapp/models/user/model/Pet.kt
index 75ee84c..111aa21 100644
--- a/app/src/main/java/com/example/pmuapp/models/user/model/Pet.kt
+++ b/app/src/main/java/com/example/pmuapp/models/user/model/Pet.kt
@@ -4,65 +4,41 @@ import android.media.Image
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.Ignore
+import androidx.room.PrimaryKey
+import androidx.room.Relation
import com.example.pmuapp.R
import java.io.Serializable
+@Entity(tableName = "pets")
data class Pet(
- var id: Int,
+ @PrimaryKey(autoGenerate = true)
+ val id: Int,
val name: String,
+ @ColumnInfo(name = "image_res_id")
val imageResId: Int,
val notes: String
-) : Serializable
+) {
+ @Ignore
+ constructor(name: String, imageResId: Int, notes: String) :
+ this(0, name, imageResId, notes)
-class PetViewModel : ViewModel() {
- var pets: MutableState> = mutableStateOf(
- emptyList()
- )
- val availablePetImages: List = listOf(
- R.drawable.pet1,
- R.drawable.pet2,
- R.drawable.pet3,
- R.drawable.pet4,
- R.drawable.pet5,
- R.drawable.pet6,
- R.drawable.pet7,
- R.drawable.pet8,
- )
+ @Relation(parentColumn = "id", entityColumn = "pet_id")
+ var petImage: PetImage? = null
- fun createPet(newPet: Pet): Pet {
- newPet.id = pets.value.size.toInt()
- val updatedPets = pets.value.toMutableList()
- updatedPets.add(newPet)
- pets.value = updatedPets
- return newPet
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (javaClass != other?.javaClass) return false
+ other as Pet
+ if (id != other.id) return false
+ return true
}
- fun deletePet(pet: Pet) {
- val updatedPets = pets.value.toMutableList()
- updatedPets.remove(pet)
- pets.value = updatedPets
- }
-
- fun updatePet(updatedPet: Pet) {
- val updatedPets = pets.value.toMutableList()
- val index = updatedPets.indexOfFirst { it.id == updatedPet.id }
-
- if (index != -1) {
- updatedPets[index] = updatedPet
- pets.value = updatedPets
- }
+ override fun hashCode(): Int {
+ return id ?: -1
}
}
-
-
-// fun updateUser(updatedUser: User) {
-// val updatedUsers = users.value.toMutableList()
-// val index = updatedUsers.indexOfFirst { it.login == updatedUser.login }
-// if (index != -1) {
-// updatedUsers[index] = updatedUser
-// users.value = updatedUsers
-// }
-// }
-
-
diff --git a/app/src/main/java/com/example/pmuapp/models/user/model/PetImage.kt b/app/src/main/java/com/example/pmuapp/models/user/model/PetImage.kt
new file mode 100644
index 0000000..cab88fa
--- /dev/null
+++ b/app/src/main/java/com/example/pmuapp/models/user/model/PetImage.kt
@@ -0,0 +1,26 @@
+package com.example.pmuapp.models.user.model
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.PrimaryKey
+
+@Entity(tableName = "pet_images")
+data class PetImage(
+ @PrimaryKey(autoGenerate = true)
+ val id: Int,
+ @ColumnInfo(name = "pet_id")
+ val petId: Int,
+ val imageData: Int
+) {
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (javaClass != other?.javaClass) return false
+ other as PetImage
+ if (id != other.id) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ return id ?: -1
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/pmuapp/models/user/model/PetWithImage.kt b/app/src/main/java/com/example/pmuapp/models/user/model/PetWithImage.kt
new file mode 100644
index 0000000..6252508
--- /dev/null
+++ b/app/src/main/java/com/example/pmuapp/models/user/model/PetWithImage.kt
@@ -0,0 +1,13 @@
+package com.example.pmuapp.models.user.model
+
+import androidx.room.Embedded
+import androidx.room.Relation
+
+data class PetWithImage(
+ @Embedded val pet: Pet,
+ @Relation(
+ parentColumn = "id",
+ entityColumn = "pet_id"
+ )
+ val petImage: PetImage?
+)
diff --git a/app/src/main/java/com/example/pmuapp/models/user/model/User.kt b/app/src/main/java/com/example/pmuapp/models/user/model/User.kt
index f9f22a8..9e33af1 100644
--- a/app/src/main/java/com/example/pmuapp/models/user/model/User.kt
+++ b/app/src/main/java/com/example/pmuapp/models/user/model/User.kt
@@ -1,129 +1,47 @@
package com.example.pmuapp.models.user.model
-import android.net.Uri
-import androidx.compose.runtime.MutableState
-import androidx.compose.runtime.mutableStateOf
-import androidx.lifecycle.ViewModel
-import com.example.pmuapp.R
-import java.io.Serializable
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.Ignore
+import androidx.room.PrimaryKey
+import androidx.room.Relation
+
+@Entity(tableName = "users")
data class User(
+ @PrimaryKey(autoGenerate = true)
val id: Int,
val name: String,
val login: String,
val password: String,
- val petId: List,
- val imageResId: String // Добавляем поле для хранения ID ресурса изображения пользователя
-) : Serializable
-
-
-class UserViewModel : ViewModel() {
- val imageUri: Uri = Uri.parse("android.resource://com.example.pmuapp/${R.drawable.avatar}")
-
- var users: MutableState> = mutableStateOf(
- listOf(
- User(0,"Иван", "ivan", "111111", emptyList(),imageUri.toString()),
- User(1,"Анна", "ann", "111111", emptyList(),imageUri.toString()),
- User(2,"Лиза", "liza", "111111",emptyList(),imageUri.toString())
- )
+ @Relation(
+ entity = Pet::class,
+ parentColumn = "id",
+ entityColumn = "user_id"
)
- val availablePetImages: List = listOf(
- R.drawable.pet1,
- R.drawable.pet2,
- R.drawable.pet3,
- R.drawable.pet4,
- R.drawable.pet5,
- R.drawable.pet6,
- R.drawable.pet7,
- R.drawable.pet8,
- )
-
- fun getUsers(): List {
- return users.value
+ val pets: List,
+ @ColumnInfo(name = "image_res_id")
+ val imageResId: String
+) {
+ @Ignore
+ constructor(id: Int, name: String, login: String, password: String, imageResId: Int) :
+ this(id, name, login, password, emptyList(), imageResId)
+ fun addPet(pet: Pet): User {
+ val updatedPets = pets.toMutableList()
+ updatedPets.add(pet)
+ return copy(pets = updatedPets)
}
- fun getUser(id:Int): User {
- return users.value.get(id)
- }
- fun getPets(id:Int): List {
- return users.value.get(id).petId
- }
- // Function to add a pet to a user
- fun addPetToUser(userId: Int, newPet: Pet) {
- val updatedUsers = users.value.toMutableList()
- val user = updatedUsers.find { it.id == userId }
-
- user?.let {
- val updatedPets = user.petId.toMutableList()
- updatedPets.add(newPet)
- val updatedUser = user.copy(petId = updatedPets)
- val userIndex = updatedUsers.indexOf(user)
- updatedUsers[userIndex] = updatedUser
- users.value = updatedUsers
- }
- }
- fun deletePet(userId: Int, petIdToDelete: Int) {
- val updatedUsers = users.value.toMutableList()
-
- // Найдем пользователя по userId
- val user = updatedUsers.find { it.id == userId }
-
- user?.let { user ->
- val updatedPets = user.petId.toMutableList()
-
- // Найдем питомца по petId и удалим его из списка питомцев
- val petToDelete = updatedPets.find { it.id == petIdToDelete }
-
- petToDelete?.let { pet ->
- updatedPets.remove(pet)
- }
-
- // Обновим пользователя с обновленным списком питомцев
- val updatedUser = user.copy(petId = updatedPets)
-
- // Обновим список пользователей
- val userIndex = updatedUsers.indexOf(user)
- updatedUsers[userIndex] = updatedUser
- users.value = updatedUsers
- }
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (javaClass != other?.javaClass) return false
+ other as User
+ if (id != other.id) return false
+ return true
}
- fun updatePetOnUser(userId: Int, updatedPet: Pet) {
- val updatedUsers = users.value.toMutableList()
-
- // Найдем пользователя по userId
- val user = updatedUsers.find { it.id == userId }
-
- user?.let { user ->
- val updatedPets = user.petId.toMutableList()
-
- // Найдем питомца по petId и обновим его
- val petToUpdate = updatedPets.find { it.id == updatedPet.id }
-
- petToUpdate?.let { pet ->
- val petIndex = updatedPets.indexOf(pet)
- updatedPets[petIndex] = updatedPet
- }
-
- // Обновим пользователя с обновленным списком питомцев
- val updatedUser = user.copy(petId = updatedPets)
-
- // Обновим список пользователей
- val userIndex = updatedUsers.indexOf(user)
- updatedUsers[userIndex] = updatedUser
- users.value = updatedUsers
- }
- }
-
- fun updateUser(updatedUser: User) {
- val updatedUsers = users.value.toMutableList()
- val index = updatedUsers.indexOfFirst { it.login == updatedUser.login }
- if (index != -1) {
- updatedUsers[index] = updatedUser
- users.value = updatedUsers
- }
+ override fun hashCode(): Int {
+ return id ?: -1
}
}
-
-
diff --git a/app/src/main/res/drawable/JNuFnEwXb10.jpg b/app/src/main/res/drawable/JNuFnEwXb10.jpg
deleted file mode 100644
index d82b600..0000000
Binary files a/app/src/main/res/drawable/JNuFnEwXb10.jpg and /dev/null differ
diff --git a/app/src/main/res/drawable/skNIwe8OnDc.jpg b/app/src/main/res/drawable/skNIwe8OnDc.jpg
deleted file mode 100644
index 85de550..0000000
Binary files a/app/src/main/res/drawable/skNIwe8OnDc.jpg and /dev/null differ
diff --git a/app/src/main/res/drawable/Лекция 6.pdf b/app/src/main/res/drawable/Лекция 6.pdf
deleted file mode 100644
index e67c07a..0000000
Binary files a/app/src/main/res/drawable/Лекция 6.pdf and /dev/null differ
diff --git a/build.gradle.kts b/build.gradle.kts
index 9861456..57bbd4b 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,5 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id("com.android.application") version "8.1.1" apply false
- id("org.jetbrains.kotlin.android") version "1.8.10" apply false
-}
\ No newline at end of file
+ id("com.android.application") version "8.1.2" apply false
+ id("org.jetbrains.kotlin.android") version "1.8.20" apply false
+ id("com.google.devtools.ksp") version "1.8.20-1.0.11" apply false
+}
+
+
diff --git a/gradle.properties b/gradle.properties
index 39aa0e0..2cbd6d1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -21,4 +21,3 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
-android.overridePathCheck=true