Skip to content

Commit

Permalink
add repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ratanparai committed Apr 23, 2019
1 parent cf27a11 commit 71c25c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/ratanparai/moviedog/db/dao/MovieDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ import com.ratanparai.moviedog.Movie
interface MovieDao {
@Query("SELECT * FROM movies ORDER BY title")
fun getMovies() : LiveData<List<Movie>>

@Query("SELECT * FROM movies WHERE id = :movieId")
fun getMovie(movieId : Int) : LiveData<Movie>

@Query("SELECT * FROM movies WHERE imdbId = :imdbId")
fun getMovie(imdbId : String) : LiveData<Movie>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class Movie (
@PrimaryKey @ColumnInfo(name = "id") val id: String,
val title : String,
val description : String,
val imdbId : String,
val cardImage : String,
val backgroundImage : String?,
val videoUrl : String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ratanparai.moviedog.db.repository

import com.ratanparai.moviedog.db.dao.MovieDao
import com.ratanparai.moviedog.scrapper.DekhvhaiScrapper

class MovieRepository private constructor(private val movieDao : MovieDao){

companion object {
@Volatile private var instance : MovieRepository? = null

fun getInstance(movieDao: MovieDao) = instance ?: synchronized(this) {
instance ?: MovieRepository(movieDao).also { instance = it }
}
}
}

0 comments on commit 71c25c9

Please sign in to comment.