Created
May 21, 2021 06:10
-
-
Save adityawid/862db45cb7d77f22e400d59c24e3a479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Class Entity | |
*/ | |
@Parcelize | |
@Entity(tableName = "popular_movies") | |
data class Movie( | |
@PrimaryKey | |
@SerializedName("id") | |
val id: Int, | |
@SerializedName("overview") | |
val overview: String, | |
@SerializedName("poster_path") | |
val posterPath: String, | |
@SerializedName("release_date") | |
val releaseDate: String, | |
@SerializedName("title") | |
val title: String, | |
@SerializedName("backdrop_path") | |
val backdropPath: String, | |
@SerializedName("popularity") | |
val popularity: Double, | |
@SerializedName("vote_average") | |
val voteAverage: Double, | |
@SerializedName("vote_count") | |
val voteCount: Int | |
) : Parcelable | |
/** | |
Data access object | |
*/ | |
@Dao | |
abstract class MovieDao { | |
@Query("SELECT * FROM popular_movies") | |
abstract fun getAllFavMovie(): PagingSource<Int, Movie> | |
} | |
/** | |
Room Database | |
*/ | |
@Database(entities = [Movie::class], version = 1) | |
abstract class MovieDatabase : RoomDatabase() { | |
abstract fun movieDao(): MovieDao | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment