Update tank is working!
65
compose/.gradle/kotlin/errors/errors-1702209062312.log
Normal file
@ -0,0 +1,65 @@
|
||||
kotlin version: 1.9.10
|
||||
error message: java.lang.Exception: Could not flush incremental caches in C:\Users\egore\Desktop\MyProjects\ULSTU\TankAppMobile\TanksApp\compose\app\build\kspCaches\debug\symbolLookups: lookups.tab
|
||||
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.forEachMapSafe(BasicMapsOwner.kt:64)
|
||||
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.flush(BasicMapsOwner.kt:48)
|
||||
at org.jetbrains.kotlin.incremental.LookupStorage.flush(LookupStorage.kt:155)
|
||||
at com.google.devtools.ksp.IncrementalContext.updateLookupCache(Incremental.kt:262)
|
||||
at com.google.devtools.ksp.IncrementalContext.updateCaches(Incremental.kt:486)
|
||||
at com.google.devtools.ksp.IncrementalContext.updateCachesAndOutputs(Incremental.kt:556)
|
||||
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:357)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:88)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:256)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42)
|
||||
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:247)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:181)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:87)
|
||||
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
|
||||
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168)
|
||||
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
|
||||
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100)
|
||||
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46)
|
||||
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
|
||||
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1497)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
|
||||
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
|
||||
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
|
||||
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
|
||||
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
|
||||
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
|
||||
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
|
||||
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
|
||||
at java.base/java.lang.Thread.run(Thread.java:833)
|
||||
Suppressed: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.io.OutputStream java.io.FilterOutputStream.out accessible: module java.base does not "opens java.io" to unnamed module @59fd97a8
|
||||
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
|
||||
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
|
||||
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
|
||||
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.IOUtil.syncStream(IOUtil.java:216)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMapValueStorage.appendBytes(PersistentHashMapValueStorage.java:188)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMapValueStorage.appendBytes(PersistentHashMapValueStorage.java:175)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl$2.onDropFromCache(PersistentMapImpl.java:237)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl$2.onDropFromCache(PersistentMapImpl.java:215)
|
||||
at org.jetbrains.kotlin.com.intellij.util.containers.SLRUMap.clear(SLRUMap.java:172)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.flushAppendCache(PersistentMapImpl.java:930)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.clearAppenderCaches(PersistentMapImpl.java:754)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.doForce(PersistentMapImpl.java:741)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.force(PersistentMapImpl.java:730)
|
||||
at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.force(PersistentHashMap.java:194)
|
||||
at org.jetbrains.kotlin.incremental.storage.CachingLazyStorage.flush(CachingLazyStorage.kt:115)
|
||||
at org.jetbrains.kotlin.incremental.storage.BasicMap.flush(BasicMap.kt:40)
|
||||
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner$flush$1.invoke(BasicMapsOwner.kt:48)
|
||||
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner$flush$1.invoke(BasicMapsOwner.kt:48)
|
||||
at org.jetbrains.kotlin.incremental.storage.BasicMapsOwner.forEachMapSafe(BasicMapsOwner.kt:56)
|
||||
... 38 more
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="ModuleClassLoaderOverlays">
|
||||
<paths>
|
||||
<option value="C:\Users\egore\AppData\Local\Temp\overlay12619265447938240062" />
|
||||
</paths>
|
||||
</component>
|
||||
</module>
|
8
compose/.idea/modules/app/pmu-demo.app.main.iml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$/../../../app/src/main">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../../app/src/main/assets" type="java-resource" />
|
||||
</content>
|
||||
</component>
|
||||
</module>
|
BIN
compose/app/src/main/assets/1.jpg
Normal file
After Width: | Height: | Size: 347 KiB |
BIN
compose/app/src/main/assets/10.jpg
Normal file
After Width: | Height: | Size: 1.8 MiB |
BIN
compose/app/src/main/assets/11.jpg
Normal file
After Width: | Height: | Size: 370 KiB |
BIN
compose/app/src/main/assets/2.jpg
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
compose/app/src/main/assets/3.jpg
Normal file
After Width: | Height: | Size: 950 KiB |
BIN
compose/app/src/main/assets/4.jpg
Normal file
After Width: | Height: | Size: 316 KiB |
BIN
compose/app/src/main/assets/5.jpg
Normal file
After Width: | Height: | Size: 584 KiB |
BIN
compose/app/src/main/assets/6.jpg
Normal file
After Width: | Height: | Size: 212 KiB |
BIN
compose/app/src/main/assets/7.jpg
Normal file
After Width: | Height: | Size: 270 KiB |
BIN
compose/app/src/main/assets/8.jpg
Normal file
After Width: | Height: | Size: 884 KiB |
BIN
compose/app/src/main/assets/9.jpg
Normal file
After Width: | Height: | Size: 845 KiB |
@ -29,6 +29,7 @@ import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@ -42,6 +43,7 @@ import ru.ulstu.`is`.pmu.R
|
||||
import ru.ulstu.`is`.pmu.composeui.navigation.Screen
|
||||
import ru.ulstu.`is`.pmu.tank.composeui.list.TankListViewModel
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tanks.composeui.image.CuteImage
|
||||
import ru.ulstu.`is`.pmu.ui.AppViewModelProvider
|
||||
import ru.ulstu.`is`.pmu.ui.theme.CustomDark
|
||||
import ru.ulstu.`is`.pmu.ui.theme.CustomOrange
|
||||
@ -121,12 +123,9 @@ fun ColumnItem(
|
||||
.padding(all = 5.dp)
|
||||
.clickable { onClick(tank.tankId) }
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = tank.image),
|
||||
contentDescription = stringResource(id = R.string.tanks_main_title),
|
||||
modifier = Modifier
|
||||
.height(150.dp)
|
||||
.padding(all = 5.dp)
|
||||
CuteImage(
|
||||
imageBitmap = tank.miniature.asImageBitmap(),
|
||||
modifier = Modifier.weight(0.5F)
|
||||
)
|
||||
Text(
|
||||
text = tank.name,
|
||||
|
@ -12,7 +12,10 @@ import com.application.ui.getEmptyBitmap
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.launch
|
||||
import ru.ulstu.`is`.pmu.tank.model.Level
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankExtra
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankImage
|
||||
import ru.ulstu.`is`.pmu.tank.repository.TankRepository
|
||||
import kotlin.math.tan
|
||||
|
||||
@ -61,6 +64,7 @@ class TankEditViewModel(
|
||||
&& price > 0
|
||||
&& levelId!! > 0
|
||||
&& nationId!! > 0
|
||||
&& imageId !! > 0
|
||||
&& image != null
|
||||
}
|
||||
}
|
||||
@ -87,6 +91,7 @@ fun TankDetails.toTank(uid: Long = 0): Tank = Tank(
|
||||
price = price,
|
||||
levelId = levelId,
|
||||
nationId = nationId,
|
||||
miniature = miniature,
|
||||
imageId = imageId
|
||||
)
|
||||
|
||||
@ -95,6 +100,7 @@ fun Tank.toDetails(): TankDetails = TankDetails(
|
||||
price = price,
|
||||
levelId = levelId,
|
||||
nationId = nationId,
|
||||
miniature = miniature,
|
||||
imageId = imageId
|
||||
)
|
||||
|
||||
|
@ -10,6 +10,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import ru.ulstu.`is`.pmu.tank.model.LevelWithTanks
|
||||
import ru.ulstu.`is`.pmu.tank.model.Nation
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankExtra
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankWithNationAndLevel
|
||||
|
||||
@Dao
|
||||
@ -18,12 +19,14 @@ interface TankDao {
|
||||
fun getAll(): Flow<List<Tank>>
|
||||
|
||||
//получить конкретный танк
|
||||
@Query("select * from tanks where tanks.tankId = :uid")
|
||||
@Query("select t.*, ti.data from tanks AS t " +
|
||||
"LEFT JOIN tank_images as ti on t.image_id = ti.image_id " +
|
||||
"where t.tankId = :uid")
|
||||
fun getTankUid(uid: Long): Flow<Tank?>
|
||||
|
||||
//получаем все танки пользователя по его Id
|
||||
@Query(
|
||||
"SELECT t.tankId, t.name, t.price, t.image_id, l.level, n.nationName FROM UserTankCrossRef AS ut " +
|
||||
"SELECT t.tankId, t.name, t.price, t.image_id, l.level, n.nationName, ti.data AS image FROM UserTankCrossRef AS ut " +
|
||||
"LEFT JOIN tanks as t on ut.tankId = t.tankId " +
|
||||
"LEFT JOIN tank_images as ti on t.image_id = ti.image_id " +
|
||||
"LEFT JOIN levels as l on t.levelId = l.uid " +
|
||||
|
@ -20,9 +20,10 @@ interface UserDao {
|
||||
|
||||
//получить конкретного пользователя
|
||||
@Query(
|
||||
"SELECT u.*, t.*, l.level, n.nationName FROM users AS u " +
|
||||
"SELECT u.*, t.*, l.level, n.nationName, ti.data AS image FROM users AS u " +
|
||||
"LEFT JOIN UserTankCrossRef as ut on u.userId = ut.userId " +
|
||||
"LEFT JOIN tanks as t on ut.tankId = t.tankId " +
|
||||
"LEFT JOIN tank_images as ti on ut.tankId = ti.image_id " +
|
||||
"LEFT JOIN levels as l on t.levelId = l.uid " +
|
||||
"LEFT JOIN nations as n on t.nationId = n.uid " +
|
||||
"WHERE u.userId = :uid"
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -17,12 +18,14 @@ import ru.ulstu.`is`.pmu.tank.dao.UserDao
|
||||
import ru.ulstu.`is`.pmu.tank.model.Level
|
||||
import ru.ulstu.`is`.pmu.tank.model.Nation
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankImage
|
||||
import ru.ulstu.`is`.pmu.tank.model.User
|
||||
import ru.ulstu.`is`.pmu.tank.model.UserTankCrossRef
|
||||
import ru.ulstu.`is`.pmu.tank.model.UserWithTanks
|
||||
|
||||
//тут, собственно говоря, всё и мутится с БД :)))
|
||||
@Database(entities = [Nation::class, Level::class, Tank::class, User::class, UserTankCrossRef::class], version = 1, exportSchema = false)
|
||||
@Database(entities = [Nation::class, Level::class, Tank::class, User::class, UserTankCrossRef::class, TankImage::class], version = 1, exportSchema = false)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun nationDao(): NationDao
|
||||
abstract fun levelDao(): LevelDao
|
||||
@ -31,7 +34,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun tankImageDao() : TankImageDao
|
||||
|
||||
companion object {
|
||||
private const val DB_NAME: String = "13-db"
|
||||
private const val DB_NAME: String = "17-db"
|
||||
|
||||
@Volatile
|
||||
private var INSTANCE: AppDatabase? = null
|
||||
@ -92,17 +95,17 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
//Tanks
|
||||
val tankDao = database.tankDao()
|
||||
val tank1 = Tank(20L,"МС-1", 1000, 1L, level1.uid, nation1.uid)
|
||||
val tank2 = Tank(21L, "Т-34-85", 960000, 1L, level6.uid, nation1.uid)
|
||||
val tank10 = Tank(22L, "Pershing", 1260000,3L, level8.uid, nation3.uid)
|
||||
val tank6 = Tank(23L, "Ferdinand", 2500000, 2L, level8.uid, nation2.uid)
|
||||
val tank3 = Tank(24L, "ИС-2", 1230000, 1L, level7.uid, nation1.uid)
|
||||
val tank4 = Tank(25L, "ИСУ-152", 2350000, 1L, level8.uid, nation1.uid)
|
||||
val tank5 = Tank(26L, "Tiger 1", 1430000,2L, level7.uid, nation2.uid)
|
||||
val tank7 = Tank(27L, "Tiger 2", 2500000, 2L, level8.uid, nation2.uid)
|
||||
val tank8 = Tank(28L, "Panther", 1350000, 2L, level7.uid, nation2.uid)
|
||||
val tank9 = Tank(29L, "M4A2E3", 990000, 3L, level6.uid, nation3.uid)
|
||||
val tank11 = Tank(30L, "Hellcat", 940000, 3L, level7.uid, nation3.uid)
|
||||
val tank1 = Tank(20L,"МС-1", 1000, PrepopulateStore.getProductMiniature(context, 1L), 1L, level1.uid, nation1.uid)
|
||||
val tank2 = Tank(21L, "Т-34-85", 960000, PrepopulateStore.getProductMiniature(context, 2L), 2L, level6.uid, nation1.uid)
|
||||
val tank10 = Tank(22L, "Pershing", 1260000, PrepopulateStore.getProductMiniature(context, 9L), 9L, level8.uid, nation3.uid)
|
||||
val tank6 = Tank(23L, "Ferdinand", 2500000, PrepopulateStore.getProductMiniature(context, 8L), 8L, level8.uid, nation2.uid)
|
||||
val tank3 = Tank(24L, "ИС-2", 1230000, PrepopulateStore.getProductMiniature(context, 3L), 3L, level7.uid, nation1.uid)
|
||||
val tank4 = Tank(25L, "ИСУ-152", 2350000, PrepopulateStore.getProductMiniature(context, 4L), 4L, level8.uid, nation1.uid)
|
||||
val tank5 = Tank(26L, "Tiger 1", 1430000,PrepopulateStore.getProductMiniature(context, 5L), 5L, level7.uid, nation2.uid)
|
||||
val tank7 = Tank(27L, "Tiger 2", 2500000, PrepopulateStore.getProductMiniature(context, 6L), 6L, level8.uid, nation2.uid)
|
||||
val tank8 = Tank(28L, "Panther", 1350000, PrepopulateStore.getProductMiniature(context, 7L), 7L, level7.uid, nation2.uid)
|
||||
val tank9 = Tank(29L, "M4A2E3", 990000, PrepopulateStore.getProductMiniature(context, 10L), 10L, level6.uid, nation3.uid)
|
||||
val tank11 = Tank(30L, "Hellcat", 940000, PrepopulateStore.getProductMiniature(context, 11L), 11L, level7.uid, nation3.uid)
|
||||
|
||||
tankDao.insert(tank1)
|
||||
tankDao.insert(tank2)
|
||||
|
@ -14,18 +14,26 @@ class PrepopulateStore {
|
||||
return listOf(
|
||||
TankImage(id = 1, data = getProductImage(context, 1)),
|
||||
TankImage(id = 2, data = getProductImage(context, 2)),
|
||||
TankImage(id = 3, data = getProductImage(context, 3))
|
||||
TankImage(id = 3, data = getProductImage(context, 3)),
|
||||
TankImage(id = 4, data = getProductImage(context, 4)),
|
||||
TankImage(id = 5, data = getProductImage(context, 5)),
|
||||
TankImage(id = 6, data = getProductImage(context, 6)),
|
||||
TankImage(id = 7, data = getProductImage(context, 7)),
|
||||
TankImage(id = 8, data = getProductImage(context, 8)),
|
||||
TankImage(id = 9, data = getProductImage(context, 9)),
|
||||
TankImage(id = 10, data = getProductImage(context, 10)),
|
||||
TankImage(id = 11, data = getProductImage(context, 11))
|
||||
)
|
||||
}
|
||||
|
||||
private fun getProductMiniature(context: Context, imageId: Int): Bitmap {
|
||||
fun getProductMiniature(context: Context, imageId: Long): Bitmap {
|
||||
val inputStream = context.assets.open("${imageId}.jpg")
|
||||
val bitmap = BitmapFactory.decodeStream(inputStream)
|
||||
return bitmap.resize(miniatureBound)
|
||||
}
|
||||
|
||||
private fun getProductImage(context: Context, imageId: Int): Bitmap {
|
||||
val inputStream = context.assets.open("${imageId}.jpg")
|
||||
private fun getProductImage(context: Context, imageName: Int): Bitmap {
|
||||
val inputStream = context.assets.open("${imageName}.jpg")
|
||||
val bitmap = BitmapFactory.decodeStream(inputStream)
|
||||
return bitmap.resize(tankImageBound)
|
||||
}
|
||||
|
@ -19,13 +19,7 @@ data class Level(
|
||||
level: Int
|
||||
) : this(null, level)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
other as Level
|
||||
if (uid != other.uid) return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
val DEMO_LEVEL = Level(
|
||||
@ -34,23 +28,21 @@ data class Level(
|
||||
)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Level
|
||||
|
||||
if (uid != other.uid) return false
|
||||
if (level != other.level) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return (uid ?: -1) as Int
|
||||
var result = uid?.hashCode() ?: 0
|
||||
result = 31 * result + level
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
fun getLevels(): List<Level> {
|
||||
return listOf(
|
||||
Level(1),
|
||||
Level(2),
|
||||
Level(3),
|
||||
Level(4),
|
||||
Level(5),
|
||||
Level(6),
|
||||
Level(7),
|
||||
Level(8),
|
||||
Level(9),
|
||||
Level(10)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -17,24 +17,30 @@ data class Nation(
|
||||
name: String
|
||||
) : this(null, name)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
other as Nation
|
||||
if (uid != other.uid) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return (uid ?: -1) as Int
|
||||
}
|
||||
|
||||
companion object {
|
||||
val DEMO_NATION = Nation(
|
||||
0,
|
||||
"СССР"
|
||||
)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Nation
|
||||
|
||||
if (uid != other.uid) return false
|
||||
if (nationName != other.nationName) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = uid?.hashCode() ?: 0
|
||||
result = 31 * result + nationName.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
fun getNations(): List<Nation> {
|
||||
|
@ -1,19 +0,0 @@
|
||||
package ru.ulstu.`is`.pmu.tank.model
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class Student(
|
||||
val firstName: String,
|
||||
val lastName: String,
|
||||
val group: String,
|
||||
val phone: String,
|
||||
val email: String
|
||||
) : Serializable
|
||||
|
||||
fun getStudents(): List<Student> {
|
||||
return listOf(
|
||||
Student("First1", "Last1", "Group1", "+79998887766", "email1@mail.ru"),
|
||||
Student("First2", "Last2", "Group1", "+79995553322", "email2@mail.ru"),
|
||||
Student("First3", "Last3", "Group2", "+79991114466", "email3@mail.ru")
|
||||
)
|
||||
}
|
@ -1,11 +1,15 @@
|
||||
package ru.ulstu.`is`.pmu.tank.model
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Ignore
|
||||
import androidx.room.PrimaryKey
|
||||
import androidx.room.TypeConverters
|
||||
import com.application.ui.getEmptyBitmap
|
||||
import ru.ulstu.`is`.pmu.R
|
||||
import ru.ulstu.`is`.pmu.tank.database.Converters
|
||||
|
||||
@Entity(
|
||||
tableName = "tanks",
|
||||
@ -26,6 +30,7 @@ data class Tank(
|
||||
val name: String,
|
||||
@ColumnInfo(name = "price")
|
||||
val price: Int,
|
||||
val miniature: Bitmap,
|
||||
@ColumnInfo(name = "image_id", index = true)
|
||||
val imageId: Long,
|
||||
@ColumnInfo(name = "levelId", index = true)
|
||||
@ -37,10 +42,11 @@ data class Tank(
|
||||
constructor(
|
||||
name: String,
|
||||
price: Int,
|
||||
miniature: Bitmap,
|
||||
imageId: Long,
|
||||
level: Level,
|
||||
nation: Nation
|
||||
) : this(null, name, price, imageId, level.uid, nation.uid)
|
||||
) : this(null, name, price, miniature, imageId, level.uid, nation.uid)
|
||||
|
||||
companion object {
|
||||
fun getTank(index: Long = 0): Tank {
|
||||
@ -48,6 +54,7 @@ data class Tank(
|
||||
index,
|
||||
"Первый танк",
|
||||
100000,
|
||||
miniature = getEmptyBitmap(),
|
||||
1L,
|
||||
1,
|
||||
1
|
||||
@ -58,13 +65,23 @@ data class Tank(
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Tank
|
||||
|
||||
if (tankId != other.tankId) return false
|
||||
if (name != other.name) return false
|
||||
if (price != other.price) return false
|
||||
if (miniature != other.miniature) return false
|
||||
if (imageId != other.imageId) return false
|
||||
if (levelId != other.levelId) return false
|
||||
if (nationId != other.nationId) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return (tankId ?: -1) as Int
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
package ru.ulstu.`is`.pmu.tank.model
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Embedded
|
||||
import com.application.ui.getEmptyBitmap
|
||||
|
||||
class TankExtra (
|
||||
@Embedded
|
||||
val tank: Tank,
|
||||
val image: Bitmap,
|
||||
) {
|
||||
companion object {
|
||||
fun getEmpty(): TankExtra {
|
||||
return TankExtra(
|
||||
tank = Tank.getTank(),
|
||||
image = getEmptyBitmap(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ import android.graphics.Bitmap
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import androidx.room.TypeConverters
|
||||
import ru.ulstu.`is`.pmu.tank.database.Converters
|
||||
|
||||
@Entity(tableName = "tank_images")
|
||||
data class TankImage(
|
||||
@ -13,24 +15,20 @@ data class TankImage(
|
||||
val data: Bitmap
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (javaClass != other?.javaClass) {
|
||||
return false
|
||||
}
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as TankImage
|
||||
|
||||
if (id != other.id) {
|
||||
return false
|
||||
}
|
||||
if (id != other.id) return false
|
||||
if (data != other.data) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return (id ?: -1) as Int
|
||||
var result = id?.hashCode() ?: 0
|
||||
result = 31 * result + data.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
@ -5,6 +5,8 @@ import androidx.room.ColumnInfo
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import androidx.room.TypeConverters
|
||||
import ru.ulstu.`is`.pmu.tank.database.Converters
|
||||
|
||||
data class TankWithNationAndLevel (
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
|
@ -43,12 +43,24 @@ data class User (
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as User
|
||||
|
||||
if (userId != other.userId) return false
|
||||
if (nickname != other.nickname) return false
|
||||
if (email != other.email) return false
|
||||
if (password != other.password) return false
|
||||
if (balance != other.balance) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return userId.toInt()
|
||||
var result = userId.hashCode()
|
||||
result = 31 * result + nickname.hashCode()
|
||||
result = 31 * result + email.hashCode()
|
||||
result = 31 * result + password.hashCode()
|
||||
result = 31 * result + balance
|
||||
return result
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import ru.ulstu.`is`.pmu.tank.dao.TankDao
|
||||
import ru.ulstu.`is`.pmu.tank.dao.TankImageDao
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankExtra
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankImage
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankWithNationAndLevel
|
||||
|
||||
|
@ -3,6 +3,7 @@ package ru.ulstu.`is`.pmu.tank.repository
|
||||
import android.graphics.Bitmap
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankExtra
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankWithNationAndLevel
|
||||
|
||||
interface TankRepository {
|
||||
|
@ -20,6 +20,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults.TrailingIcon
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
@ -267,6 +268,13 @@ private fun Constructor(
|
||||
modifier = Modifier
|
||||
.width(200.dp),
|
||||
)
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
value = tankUiState.tankDetails.name,
|
||||
onValueChange = { onUpdate(tankUiState.tankDetails.copy(name = it)) },
|
||||
label = { Text(text = "Название", color = CustomDark) },
|
||||
singleLine = true
|
||||
)
|
||||
Spacer(Modifier.height(10.dp))
|
||||
CuteImageUploader(
|
||||
bitmap = tankUiState.tankDetails.image,
|
||||
@ -316,7 +324,9 @@ private fun Constructor(
|
||||
containerColor = CustomOrange,
|
||||
contentColor = Color.Black
|
||||
),
|
||||
onClick = { onClick() }) {
|
||||
enabled = tankUiState.isEntryValid,
|
||||
onClick = onClick
|
||||
) {
|
||||
//"${student.firstName} ${student.lastName}"
|
||||
Text(text = stringResource(id = R.string.save_account_button), fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
@ -424,7 +434,8 @@ private fun Constructor(
|
||||
containerColor = CustomOrange,
|
||||
contentColor = Color.Black
|
||||
),
|
||||
onClick = { }) {
|
||||
onClick = onClick
|
||||
) {
|
||||
//"${student.firstName} ${student.lastName}"
|
||||
Text(text = stringResource(id = R.string.create_account_button), fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@ -55,6 +56,7 @@ import ru.ulstu.`is`.pmu.tank.model.Nation
|
||||
import ru.ulstu.`is`.pmu.tank.model.Tank
|
||||
import ru.ulstu.`is`.pmu.tank.model.TankWithNationAndLevel
|
||||
import ru.ulstu.`is`.pmu.tank.model.UserWithTanks
|
||||
import ru.ulstu.`is`.pmu.tanks.composeui.image.CuteImage
|
||||
import ru.ulstu.`is`.pmu.ui.AppViewModelProvider
|
||||
import ru.ulstu.`is`.pmu.ui.theme.CustomDark
|
||||
import ru.ulstu.`is`.pmu.ui.theme.CustomYellow
|
||||
@ -127,13 +129,9 @@ private fun Hangar(
|
||||
.size(width = 170.dp, height = 250.dp)
|
||||
.padding(10.dp, 0.dp, 10.dp, 0.dp)
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(
|
||||
id = tankList[index].image
|
||||
),
|
||||
contentDescription = stringResource(id = R.string.tanks_main_title),
|
||||
modifier = Modifier
|
||||
.height(130.dp)
|
||||
CuteImage(
|
||||
imageBitmap = tankList[index].image.asImageBitmap(),
|
||||
modifier = Modifier.weight(0.5F)
|
||||
)
|
||||
Text(
|
||||
text = tankList[index].name,
|
||||
|
BIN
compose/app/src/main/res/drawable/t_34_85.jpg
Normal file
After Width: | Height: | Size: 1.5 MiB |