Finir l'ajout des dao et des entities

features/retrofit/1
Jordan ARTZET 2 years ago
parent dce004b4a6
commit d73138ebe5

@ -0,0 +1,33 @@
package fr.iut.pm.movieapplication.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "genre_table")
data class Genre(
@PrimaryKey
@ColumnInfo(name = "id")
var id : Int,
@ColumnInfo(name = "name")
var name : String
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Genre
if (id != other.id) return false
if (name != other.name) return false
return true
}
override fun hashCode(): Int {
var result = id
result = 31 * result + name.hashCode()
return result
}
}

@ -0,0 +1,67 @@
package fr.iut.pm.movieapplication.model
import androidx.room.ColumnInfo
import androidx.room.Embedded
import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.Relation
import java.util.Date
@Entity(tableName = "movies_table")
data class Movie(
@ColumnInfo(name = "adult")
var adult: Boolean,
@ColumnInfo(name = "budget")
var budget: Int,
@ColumnInfo(name = "genres")
var genres: Array<Genre>,
@ColumnInfo(name = "homepage")
var homePage: String?,
@PrimaryKey
@ColumnInfo(name = "id")
var movieId: Int,
@ColumnInfo(name = "original_language")
var originalLanguage: String,
@ColumnInfo(name = "original_title")
var originalTitle: String,
var overview: String?,
var popularity: Int,
//var posterPath : String?,
@Embedded
var productionCompanies: Array<ProductionCompany>,
@Relation(
parentColumn = "movieId",
entityColumn = ""
)
var productionCountries: Array<ProductionCountry>,
var releaseDate: Date,
var revenue: Int,
var runtime: Int?,
//var spokenLanguages : Array<SpokenLanguage>,
var status: String,
var tagLine: String?,
var title: String,
@ColumnInfo(name = "vote_average")
var voteAverage: Number,
@ColumnInfo(name = "vote_count")
var voteCount : Int
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Movie
if (movieId != other.movieId) return false
return true
}
override fun hashCode(): Int {
return movieId
}
}

@ -0,0 +1,32 @@
package fr.iut.pm.movieapplication.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "production_companies_table")
data class ProductionCompany(
var name : String,
@PrimaryKey
@ColumnInfo(name = "id")
var productionCompanyId : Int,
//var logoPath : String?,
@ColumnInfo(name="origin_country")
var originCountry : String
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as ProductionCompany
if (productionCompanyId != other.productionCompanyId) return false
return true
}
override fun hashCode(): Int {
return productionCompanyId
}
}

@ -0,0 +1,11 @@
package fr.iut.pm.movieapplication.model
import androidx.room.Entity
@Entity(tableName = "production_country_table")
data class ProductionCountry(
var iso_3611_1 : String,
var name : String
) {
}

@ -0,0 +1,8 @@
package fr.iut.pm.movieapplication.model
data class SpokenLanguage(
var iso_639_1 : String,
var name : String
) {
}

@ -0,0 +1,12 @@
package fr.iut.pm.movieapplication.ui.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import fr.iut.pm.movieapplication.R
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activity.MainActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save