merge api
continuous-integration/drone/push Build is passing Details

viewmodel
Lucas Delanier 2 years ago
parent ab0f8a0462
commit b04739859f

@ -33,6 +33,11 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
}
apply plugin: 'kotlin-kapt'
dependencies {
@ -48,8 +53,16 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation "androidx.room:room-runtime:2.5.1"
kapt "androidx.room:room-compiler:2.5.1"
implementation "androidx.room:room-ktx:2.5.1"
kapt "androidx.room:room-compiler:2.5.1"
androidTestImplementation "androidx.room:room-testing:2.5.1"
//Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
//Coroutine
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
}

@ -0,0 +1,15 @@
package com.example.shakecraft.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.shakecraft.model.Item
@Dao
interface ItemDao {
@Query("SELECT * FROM item")
suspend fun getAllItems(): List<Item>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertItem(item: Item)
}

@ -0,0 +1,16 @@
package com.example.shakecraft.data.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.shakecraft.model.Player
@Dao
interface PlayerDao {
@Query("SELECT * FROM player")
suspend fun getAllPlayers(): List<Player>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertPlayer(player: Player)
}

@ -2,11 +2,15 @@ package com.example.shakecraft.model
import android.os.Parcel
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "items")
open class Item(
val type: ItemType,
var stack: Int = 1,
) : Parcelable {
@PrimaryKey(autoGenerate = true) val id: String = type.name
override fun describeContents(): Int {

Loading…
Cancel
Save