feat - add entities and begin DAO

main
DJYohann 2 years ago
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>

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="testRunner" value="GRADLE" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

@ -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>

@ -37,6 +37,9 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1' implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0' implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.room:room-common:2.4.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.room:room-ktx:2.4.2'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

@ -11,6 +11,16 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AlloMovies" android:theme="@style/Theme.AlloMovies"
tools:targetApi="31" /> tools:targetApi="31">
<activity
android:name=".ui.activity.GenreListActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> </manifest>

@ -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> <resources>
<string name="app_name">AlloMovies</string> <string name="app_name">AlloMovies</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>

@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { plugins {
id 'com.android.application' version '7.3.1' apply false id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.3.1' apply false id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' 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 #Tue Jan 10 17:21:25 CET 2023
distributionBase=GRADLE_USER_HOME 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 distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

Loading…
Cancel
Save