Skip to content

Commit

Permalink
Merge pull request #7 from piashcse/tvSeries
Browse files Browse the repository at this point in the history
- Implemented TV Series
  • Loading branch information
piashcse authored Oct 9, 2024
2 parents a1ef4ff + b65da87 commit f8a1962
Show file tree
Hide file tree
Showing 73 changed files with 2,004 additions and 356 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Movie World app using [The Movie DB](https://www.themoviedb.org) built with jetp


<p float="left">
<img width="30%" height="50%" src="https://github.com/piashcse/Hilt-MVVM-Compose-Movie/blob/master/screenshots/Screenshot_20220420_022455.png" />
<img width="30%" height="50%" src="https://github.com/piashcse/Hilt-MVVM-Compose-Movie/blob/master/screenshots/Screenshot_20220420_022546.png" />
<img width="30%" height="50%" src="https://github.com/piashcse/Hilt-MVVM-Compose-Movie/blob/master/screenshots/Screenshot_20220420_021842.png" />
<img width="30%" height="50%" src="https://github.com/piashcse/Hilt-MVVM-Compose-Movie/blob/master/screenshots/1728491749752.PNG" />
<img width="30%" height="50%" src="https://github.com/piashcse/Hilt-MVVM-Compose-Movie/blob/master/screenshots/1728491749751.PNG" />
<img width="30%" height="50%" src="https://github.com/piashcse/Hilt-MVVM-Compose-Movie/blob/master/screenshots/1728491749753.PNG" />
</p>

# Main Features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote

import com.piashcse.hilt_mvvm_compose_movie.BuildConfig
import com.piashcse.hilt_mvvm_compose_movie.data.model.BaseModel
import com.piashcse.hilt_mvvm_compose_movie.data.model.BaseModelMovie
import com.piashcse.hilt_mvvm_compose_movie.data.model.BaseModelTvSeries
import com.piashcse.hilt_mvvm_compose_movie.data.model.Genres
import com.piashcse.hilt_mvvm_compose_movie.data.model.SearchBaseModel
import com.piashcse.hilt_mvvm_compose_movie.data.model.artist.Artist
import com.piashcse.hilt_mvvm_compose_movie.data.model.artist.ArtistDetail
import com.piashcse.hilt_mvvm_compose_movie.data.model.moviedetail.MovieDetail
import com.piashcse.hilt_mvvm_compose_movie.data.model.tv_series_detail.TvSeriesDetail
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {
@GET("movie/now_playing")
suspend fun nowPlayingMovieList(
suspend fun nowPlayingMovies(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
): BaseModelMovie

@GET("movie/popular")
suspend fun popularMovieList(
suspend fun popularMovies(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
): BaseModelMovie

@GET("movie/top_rated")
suspend fun topRatedMovieList(
suspend fun topRatedMovies(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
): BaseModelMovie

@GET("movie/upcoming")
suspend fun upcomingMovieList(
suspend fun upcomingMovies(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
): BaseModelMovie

@GET("movie/{movieId}")
suspend fun movieDetail(
Expand All @@ -46,14 +49,13 @@ interface ApiService {

@GET("movie/{movieId}/recommendations")
suspend fun recommendedMovie(
@Path("movieId") movieId: Int,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
@Path("movieId") movieId: Int, @Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModelMovie

@GET("search/movie?page=1&include_adult=false")
suspend fun search(
suspend fun searchMovie(
@Query("query") searchKey: String, @Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
): SearchBaseModel

@GET("genre/movie/list")
suspend fun genreList(@Query("api_key") api_key: String = BuildConfig.API_KEY): Genres
Expand All @@ -63,7 +65,7 @@ interface ApiService {
@Query("page") page: Int,
@Query("with_genres") genreId: String,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModel
): BaseModelMovie

@GET("movie/{movieId}/credits")
suspend fun movieCredit(
Expand All @@ -74,4 +76,53 @@ interface ApiService {
suspend fun artistDetail(
@Path("personId") personId: Int, @Query("api_key") api_key: String = BuildConfig.API_KEY
): ArtistDetail

@GET("tv/airing_today")
suspend fun airingTodayTvSeries(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModelTvSeries

@GET("tv/on_the_air")
suspend fun onTheAirTvSeries(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModelTvSeries

@GET("tv/popular")
suspend fun popularTvSeries(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModelTvSeries

@GET("tv/top_rated")
suspend fun topRatedTvSeries(
@Query("page") page: Int,
@Query("with_genres") genreId: String?,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModelTvSeries

@GET("tv/{seriesId}")
suspend fun tvSeriesDetail(
@Path("seriesId") seriesId: Int, @Query("api_key") api_key: String = BuildConfig.API_KEY
): TvSeriesDetail

@GET("tv/{seriesId}/recommendations")
suspend fun recommendedTvSeries(
@Path("seriesId") seriesId: Int, @Query("api_key") api_key: String = BuildConfig.API_KEY
): BaseModelTvSeries

@GET("tv/{seriesId}/credits")
suspend fun tvSeriesCredit(
@Path("seriesId") seriesId: Int, @Query("api_key") api_key: String = BuildConfig.API_KEY
): Artist

@GET("search/tv?page=1&include_adult=false")
suspend fun searchTvSeries(
@Query("query") searchKey: String,
@Query("api_key") api_key: String = BuildConfig.API_KEY
): SearchBaseModel
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.movie

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand All @@ -9,7 +9,7 @@ import timber.log.Timber
import java.io.IOException
import javax.inject.Inject

class PopularPagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
class NowPlayingMoviePagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
PagingSource<Int, MovieItem>() {

override fun getRefreshKey(state: PagingState<Int, MovieItem>): Int? {
Expand All @@ -19,7 +19,7 @@ class PopularPagingDataSource @Inject constructor(private val apiService: ApiSer
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MovieItem> {
return try {
val nextPage = params.key ?: 1
val movieList = apiService.popularMovieList(nextPage, genreId)
val movieList = apiService.nowPlayingMovies(nextPage, genreId)
LoadResult.Page(
data = movieList.results,
prevKey = if (nextPage == 1) null else nextPage - 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.movie

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand All @@ -9,7 +9,7 @@ import timber.log.Timber
import java.io.IOException
import javax.inject.Inject

class NowPlayingPagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
class PopularMoviePagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
PagingSource<Int, MovieItem>() {

override fun getRefreshKey(state: PagingState<Int, MovieItem>): Int? {
Expand All @@ -19,7 +19,7 @@ class NowPlayingPagingDataSource @Inject constructor(private val apiService: Api
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MovieItem> {
return try {
val nextPage = params.key ?: 1
val movieList = apiService.nowPlayingMovieList(nextPage, genreId)
val movieList = apiService.popularMovies(nextPage, genreId)
LoadResult.Page(
data = movieList.results,
prevKey = if (nextPage == 1) null else nextPage - 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.movie

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand All @@ -9,7 +9,7 @@ import timber.log.Timber
import java.io.IOException
import javax.inject.Inject

class TopRatedPagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
class TopRatedMoviePagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
PagingSource<Int, MovieItem>() {

override fun getRefreshKey(state: PagingState<Int, MovieItem>): Int? {
Expand All @@ -19,7 +19,7 @@ class TopRatedPagingDataSource @Inject constructor(private val apiService: ApiSe
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MovieItem> {
return try {
val nextPage = params.key ?: 1
val movieList = apiService.topRatedMovieList(nextPage, genreId)
val movieList = apiService.topRatedMovies(nextPage, genreId)
LoadResult.Page(
data = movieList.results,
prevKey = if (nextPage == 1) null else nextPage - 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging
package com.piashcse.hilt_mvvm_compose_movie.data.datasource.remote.paging_datasource.movie

import androidx.paging.PagingSource
import androidx.paging.PagingState
Expand All @@ -9,7 +9,7 @@ import timber.log.Timber
import java.io.IOException
import javax.inject.Inject

class UpcomingPagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
class UpcomingMoviePagingDataSource @Inject constructor(private val apiService: ApiService, private val genreId:String?) :
PagingSource<Int, MovieItem>() {

override fun getRefreshKey(state: PagingState<Int, MovieItem>): Int? {
Expand All @@ -19,7 +19,7 @@ class UpcomingPagingDataSource @Inject constructor(private val apiService: ApiSe
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MovieItem> {
return try {
val nextPage = params.key ?: 1
val movieList = apiService.upcomingMovieList(nextPage, genreId)
val movieList = apiService.upcomingMovies(nextPage, genreId)
LoadResult.Page(
data = movieList.results,
prevKey = if (nextPage == 1) null else nextPage - 1,
Expand Down
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)
}
}
}
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)
}
}
}
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)
}
}
}
Loading

0 comments on commit f8a1962

Please sign in to comment.