basis for showing people on homepage

This commit is contained in:
Owen LeJeune
2022-02-28 21:23:35 -05:00
parent be23d58b1d
commit eebd5342ae
9 changed files with 42 additions and 5 deletions

View File

@@ -1,11 +1,13 @@
package com.owenlejeune.tvtime.api.tmdb
import com.owenlejeune.tvtime.api.tmdb.model.DetailPerson
import com.owenlejeune.tvtime.api.tmdb.model.HomePagePeopleResponse
import com.owenlejeune.tvtime.api.tmdb.model.PersonCreditsResponse
import com.owenlejeune.tvtime.api.tmdb.model.PersonImageCollection
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query
interface PeopleApi {
@@ -24,6 +26,9 @@ interface PeopleApi {
@GET("person/{id}/images")
suspend fun getImages(@Path("id") id: Int): Response<PersonImageCollection>
@GET("person/popular")
suspend fun getPopular(@Query("page") page: Int = 1): Response<HomePagePeopleResponse>
// @GET("persons/{id}/tagged_images")
// suspend fun getTaggedImages(@Path("id") id: Int, @Query("page") page: Int = 1): Response<PersonImageCollection>

View File

@@ -1,6 +1,7 @@
package com.owenlejeune.tvtime.api.tmdb
import com.owenlejeune.tvtime.api.tmdb.model.DetailPerson
import com.owenlejeune.tvtime.api.tmdb.model.HomePagePeopleResponse
import com.owenlejeune.tvtime.api.tmdb.model.PersonCreditsResponse
import com.owenlejeune.tvtime.api.tmdb.model.PersonImageCollection
import org.koin.core.component.KoinComponent
@@ -22,4 +23,8 @@ class PeopleService: KoinComponent {
return service.getImages(id)
}
suspend fun getPopular(page: Int = 1): Response<HomePagePeopleResponse> {
return service.getPopular(page)
}
}

View File

@@ -3,7 +3,8 @@ package com.owenlejeune.tvtime.api.tmdb.model
import com.google.gson.annotations.SerializedName
class HomePageMoviesResponse(
count: Int,
totalResults: Int,
totalPages: Int,
page: Int,
@SerializedName("results") override val results: List<HomePageMovie>
): HomePageResponse(count, page, results)
): HomePageResponse(totalResults, totalPages, page, results)

View File

@@ -0,0 +1,10 @@
package com.owenlejeune.tvtime.api.tmdb.model
import com.google.gson.annotations.SerializedName
class HomePagePeopleResponse(
@SerializedName("total_results") val totalResults: Int,
@SerializedName("total_pages") val totalPages: Int,
@SerializedName("page") val page: Int,
@SerializedName("results") val results: List<HomePagePerson>
)

View File

@@ -0,0 +1,12 @@
package com.owenlejeune.tvtime.api.tmdb.model
import com.google.gson.annotations.SerializedName
class HomePagePerson(
@SerializedName("profile_path") val profilePath: String,
@SerializedName("adult") val isAdult: Boolean,
@SerializedName("id") val id: Int,
@SerializedName("name") val name: String,
@SerializedName("popularity") val popularity: Float
// @SerializedName("known_for")
)

View File

@@ -3,7 +3,8 @@ package com.owenlejeune.tvtime.api.tmdb.model
import com.google.gson.annotations.SerializedName
abstract class HomePageResponse(
@SerializedName("total_results") val count: Int,
@SerializedName("total_results") val totalResults: Int,
@SerializedName("total_pages") val totalPages: Int,
@SerializedName("page") val page: Int,
@Transient open val results: List<TmdbItem>
)

View File

@@ -3,7 +3,8 @@ package com.owenlejeune.tvtime.api.tmdb.model
import com.google.gson.annotations.SerializedName
class HomePageTvResponse(
count: Int,
totalResults: Int,
totalPages: Int,
page: Int,
@SerializedName("results") override val results: List<HomePageTv>
): HomePageResponse(count, page, results)
): HomePageResponse(totalResults, totalPages, page, results)

View File

@@ -31,5 +31,6 @@ sealed class BottomNavItem(stringRes: Int, val icon: Int, val route: String): Ko
object Account: BottomNavItem(R.string.nav_account_title, R.drawable.ic_person, "account_route")
object Favourites: BottomNavItem(R.string.nav_favourites_title, R.drawable.ic_favorite, "favourites_route")
object Settings: BottomNavItem(R.string.nav_settings_title, R.drawable.ic_settings, "settings_route")
object People: BottomNavItem(R.string.nav_people_title, R.drawable.ic_person, "people_route")
}

View File

@@ -57,4 +57,5 @@
<string name="nav_rated_movies_title">Rated Movies</string>
<string name="nav_rated_shows_title">Rated TV Shows</string>
<string name="nav_rated_episodes_title">Rated TV Episodes</string>
<string name="nav_people_title">People</string>
</resources>