-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from piashcse/tvSeries
- Implemented TV Series
- Loading branch information
Showing
73 changed files
with
2,004 additions
and
356 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
2 changes: 1 addition & 1 deletion
2
...ce/remote/paging/GenrePagingDataSource.kt → ...aging_datasource/GenrePagingDataSource.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
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
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
39 changes: 39 additions & 0 deletions
39
...data/datasource/remote/paging_datasource/tv_series/AiringTodayTvSeriesPagingDataSource.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,39 @@ | ||
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.tv_series | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.ApiService | ||
import com.piashcse.hilt_mvvm_compose_movie.data.model.TvSeriesItem | ||
import retrofit2.HttpException | ||
import timber.log.Timber | ||
import java.io.IOException | ||
import javax.inject.Inject | ||
|
||
class AiringTodayTvSeriesPagingDataSource @Inject constructor( | ||
private val apiService: ApiService, | ||
private val genreId: String? | ||
) : | ||
PagingSource<Int, TvSeriesItem>() { | ||
|
||
override fun getRefreshKey(state: PagingState<Int, TvSeriesItem>): Int? { | ||
return state.anchorPosition | ||
} | ||
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, TvSeriesItem> { | ||
return try { | ||
val nextPage = params.key ?: 1 | ||
val movieList = apiService.airingTodayTvSeries(nextPage, genreId) | ||
LoadResult.Page( | ||
data = movieList.results, | ||
prevKey = if (nextPage == 1) null else nextPage - 1, | ||
nextKey = if (movieList.results.isNotEmpty()) movieList.page + 1 else null | ||
) | ||
} catch (exception: IOException) { | ||
Timber.e("exception ${exception.message}") | ||
return LoadResult.Error(exception) | ||
} catch (httpException: HttpException) { | ||
Timber.e("httpException ${httpException.message}") | ||
return LoadResult.Error(httpException) | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...ie/data/datasource/remote/paging_datasource/tv_series/OnTheAirTvSeriesPagingDataSource.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,39 @@ | ||
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.tv_series | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.ApiService | ||
import com.piashcse.hilt_mvvm_compose_movie.data.model.TvSeriesItem | ||
import retrofit2.HttpException | ||
import timber.log.Timber | ||
import java.io.IOException | ||
import javax.inject.Inject | ||
|
||
class OnTheAirTvSeriesPagingDataSource @Inject constructor( | ||
private val apiService: ApiService, | ||
private val genreId: String? | ||
) : | ||
PagingSource<Int, TvSeriesItem>() { | ||
|
||
override fun getRefreshKey(state: PagingState<Int, TvSeriesItem>): Int? { | ||
return state.anchorPosition | ||
} | ||
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, TvSeriesItem> { | ||
return try { | ||
val nextPage = params.key ?: 1 | ||
val movieList = apiService.onTheAirTvSeries(nextPage, genreId) | ||
LoadResult.Page( | ||
data = movieList.results, | ||
prevKey = if (nextPage == 1) null else nextPage - 1, | ||
nextKey = if (movieList.results.isNotEmpty()) movieList.page + 1 else null | ||
) | ||
} catch (exception: IOException) { | ||
Timber.e("exception ${exception.message}") | ||
return LoadResult.Error(exception) | ||
} catch (httpException: HttpException) { | ||
Timber.e("httpException ${httpException.message}") | ||
return LoadResult.Error(httpException) | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...vie/data/datasource/remote/paging_datasource/tv_series/PopularTvSeriesPagingDataSource.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,39 @@ | ||
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.tv_series | ||
|
||
import androidx.paging.PagingSource | ||
import androidx.paging.PagingState | ||
import com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.ApiService | ||
import com.piashcse.hilt_mvvm_compose_movie.data.model.TvSeriesItem | ||
import retrofit2.HttpException | ||
import timber.log.Timber | ||
import java.io.IOException | ||
import javax.inject.Inject | ||
|
||
class PopularTvSeriesPagingDataSource @Inject constructor( | ||
private val apiService: ApiService, | ||
private val genreId: String? | ||
) : | ||
PagingSource<Int, TvSeriesItem>() { | ||
|
||
override fun getRefreshKey(state: PagingState<Int, TvSeriesItem>): Int? { | ||
return state.anchorPosition | ||
} | ||
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, TvSeriesItem> { | ||
return try { | ||
val nextPage = params.key ?: 1 | ||
val movieList = apiService.popularTvSeries(nextPage, genreId) | ||
LoadResult.Page( | ||
data = movieList.results, | ||
prevKey = if (nextPage == 1) null else nextPage - 1, | ||
nextKey = if (movieList.results.isNotEmpty()) movieList.page + 1 else null | ||
) | ||
} catch (exception: IOException) { | ||
Timber.e("exception ${exception.message}") | ||
return LoadResult.Error(exception) | ||
} catch (httpException: HttpException) { | ||
Timber.e("httpException ${httpException.message}") | ||
return LoadResult.Error(httpException) | ||
} | ||
} | ||
} |
Oops, something went wrong.