parent
f47401c565
commit
2571cd267f
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="$USER_HOME$/.android/avd/Pixel_4_API_16.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-01-16T15:41:03.616915Z" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
package fr.yobreuil.allomovies.data
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
const val GENRE_DEFAULT_ID = 0L
|
||||
|
||||
@Entity(tableName = "genres")
|
||||
data class Genre(var name: String = "",
|
||||
@PrimaryKey(autoGenerate = true) val id: Long = GENRE_DEFAULT_ID)
|
@ -0,0 +1,10 @@
|
||||
package fr.yobreuil.allomovies.data
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
const val MOVIE_DEFAULT_ID = 0L
|
||||
|
||||
@Entity(tableName = "movies")
|
||||
data class Movie(var name: String = "",
|
||||
@PrimaryKey(autoGenerate = true) val id: Long = MOVIE_DEFAULT_ID)
|
@ -0,0 +1,41 @@
|
||||
package fr.yobreuil.allomovies.data.persistance
|
||||
|
||||
import android.app.Application
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import fr.yobreuil.allomovies.data.Genre
|
||||
import fr.yobreuil.allomovies.data.Movie
|
||||
|
||||
private const val ALLO_MOVIES_DB_FILENAME = "allomovies.db"
|
||||
|
||||
@Database(entities = [Genre::class, Movie::class], version = 1, exportSchema = false)
|
||||
abstract class AlloMoviesDatabase : RoomDatabase() {
|
||||
abstract fun genreDao(): GenreDao
|
||||
|
||||
companion object {
|
||||
private lateinit var application: Application
|
||||
|
||||
@Volatile
|
||||
private var INSTANCE: AlloMoviesDatabase? = null
|
||||
|
||||
fun getInstance(): AlloMoviesDatabase {
|
||||
if (::application.isInitialized) {
|
||||
if (INSTANCE == null) {
|
||||
synchronized(this) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = Room.databaseBuilder(
|
||||
application.applicationContext,
|
||||
AlloMoviesDatabase::class.java,
|
||||
ALLO_MOVIES_DB_FILENAME
|
||||
).build()
|
||||
|
||||
INSTANCE?.genreDao()
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE!!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package fr.yobreuil.allomovies.data.persistance
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import fr.yobreuil.allomovies.data.Genre
|
||||
|
||||
@Dao
|
||||
interface GenreDao {
|
||||
@Query("SELECT * FROM genres")
|
||||
fun getAll(): List<Genre>
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package fr.yobreuil.allomovies.data.persistance
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
|
||||
@Dao
|
||||
interface MovieDao {
|
||||
@Query("")
|
||||
fun getAll();
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">AlloMovies</string>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
</resources>
|
@ -1,6 +1,6 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '7.3.1' apply false
|
||||
id 'com.android.library' version '7.3.1' apply false
|
||||
id 'com.android.application' version '7.4.0' apply false
|
||||
id 'com.android.library' version '7.4.0' apply false
|
||||
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#Tue Jan 10 17:21:25 CET 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
Loading…
Reference in new issue