-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement cached pagination for now playing movies, now playing tv sh…
…ows, top rated tv shows.
- Loading branch information
1 parent
b34346a
commit 807b6da
Showing
53 changed files
with
762 additions
and
408 deletions.
There are no files selected for viewing
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
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
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
20 changes: 20 additions & 0 deletions
20
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/NowPlayingTvShowDao.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.adesso.movee.data.local.database.dao | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import com.adesso.movee.data.local.database.entity.NowPlayingTvShowEntity | ||
import com.adesso.movee.data.local.database.entity.NowPlayingTvShowWithGenres | ||
|
||
@Dao | ||
abstract class NowPlayingTvShowDao : BaseDao<NowPlayingTvShowEntity> { | ||
|
||
@Transaction | ||
@Query("SELECT * FROM now_playing_tv_show") | ||
abstract fun getPagingSource(): PagingSource<Int, NowPlayingTvShowWithGenres> | ||
|
||
@Transaction | ||
@Query("DELETE FROM now_playing_tv_show") | ||
abstract suspend fun clear() | ||
} |
12 changes: 0 additions & 12 deletions
12
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/NowPlayingTvShowIdDao.kt
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/NowPlayingTvShowIdPageDao.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.adesso.movee.data.local.database.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import com.adesso.movee.data.local.database.entity.NowPlayingTvShowIdPageEntity | ||
import com.adesso.movee.data.local.database.entity.TABLE_NOW_PLAYING_TV_SHOW_ID_PAGE | ||
|
||
@Dao | ||
abstract class NowPlayingTvShowIdPageDao : BaseDao<NowPlayingTvShowIdPageEntity> { | ||
|
||
@Query("SELECT page FROM $TABLE_NOW_PLAYING_TV_SHOW_ID_PAGE") | ||
abstract suspend fun getPages(): List<Int> | ||
|
||
@Query("DELETE FROM $TABLE_NOW_PLAYING_TV_SHOW_ID_PAGE") | ||
abstract suspend fun clear() | ||
} |
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
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
20 changes: 20 additions & 0 deletions
20
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/TopRatedTvShowDao.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.adesso.movee.data.local.database.dao | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import androidx.room.Transaction | ||
import com.adesso.movee.data.local.database.entity.TopRatedTvShowEntity | ||
import com.adesso.movee.data.local.database.entity.TopRatedTvShowWithGenres | ||
|
||
@Dao | ||
abstract class TopRatedTvShowDao : BaseDao<TopRatedTvShowEntity> { | ||
|
||
@Transaction | ||
@Query("SELECT * FROM top_rated_tv_show") | ||
abstract fun getPagingSource(): PagingSource<Int, TopRatedTvShowWithGenres> | ||
|
||
@Transaction | ||
@Query("DELETE FROM top_rated_tv_show") | ||
abstract suspend fun clear() | ||
} |
12 changes: 0 additions & 12 deletions
12
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/TopRatedTvShowIdDao.kt
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/TopRatedTvShowIdPageDao.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.adesso.movee.data.local.database.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import com.adesso.movee.data.local.database.entity.TABLE_TOP_RATED_TV_SHOW_ID_PAGE | ||
import com.adesso.movee.data.local.database.entity.TopRatedTvShowIdPageEntity | ||
|
||
@Dao | ||
abstract class TopRatedTvShowIdPageDao : BaseDao<TopRatedTvShowIdPageEntity> { | ||
@Query("SELECT page FROM $TABLE_TOP_RATED_TV_SHOW_ID_PAGE") | ||
abstract suspend fun getPages(): List<Int> | ||
|
||
@Query("DELETE FROM $TABLE_TOP_RATED_TV_SHOW_ID_PAGE") | ||
abstract suspend fun clear() | ||
} |
15 changes: 0 additions & 15 deletions
15
app/src/main/kotlin/com/adesso/movee/data/local/database/dao/TvShowDao.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
app/src/main/kotlin/com/adesso/movee/data/local/database/entity/BaseIdEntity.kt
This file was deleted.
Oops, something went wrong.
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
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
10 changes: 0 additions & 10 deletions
10
app/src/main/kotlin/com/adesso/movee/data/local/database/entity/NowPlayingTvShowIdEntity.kt
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...c/main/kotlin/com/adesso/movee/data/local/database/entity/NowPlayingTvShowIdPageEntity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.adesso.movee.data.local.database.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
const val TABLE_NOW_PLAYING_TV_SHOW_ID_PAGE = "now_playing_tv_show_id_page" | ||
|
||
@Entity(tableName = TABLE_NOW_PLAYING_TV_SHOW_ID_PAGE) | ||
class NowPlayingTvShowIdPageEntity( | ||
@ColumnInfo(name = "id") val id: Long, | ||
@ColumnInfo(name = "page") val page: Int | ||
) { | ||
@PrimaryKey(autoGenerate = true) | ||
var uId: Int = 0 | ||
} |
31 changes: 31 additions & 0 deletions
31
...src/main/kotlin/com/adesso/movee/data/local/database/entity/NowPlayingTvShowWithGenres.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.adesso.movee.data.local.database.entity | ||
|
||
import androidx.room.Embedded | ||
import androidx.room.Junction | ||
import androidx.room.Relation | ||
import com.adesso.movee.internal.extension.convertTvShowGenres | ||
import com.adesso.movee.uimodel.TvShowUiModel | ||
|
||
data class NowPlayingTvShowWithGenres( | ||
@Embedded val tvShow: NowPlayingTvShowEntity, | ||
@Relation( | ||
parentColumn = "id", | ||
entityColumn = "genre_id", | ||
associateBy = Junction( | ||
value = TvShowGenreCrossRefEntity::class | ||
) | ||
) | ||
val genres: List<TvShowGenreEntity> | ||
) { | ||
fun toUiModel() = TvShowUiModel( | ||
id = tvShow.id, | ||
title = tvShow.title, | ||
overview = tvShow.overview, | ||
genres = genres.convertTvShowGenres(), | ||
posterPath = tvShow.posterPath, | ||
backdropPath = tvShow.backdropPath, | ||
popularity = tvShow.popularity, | ||
average = tvShow.average, | ||
releaseDate = tvShow.releaseDate | ||
) | ||
} |
Oops, something went wrong.