-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/tmdb api implementation #60
base: master
Are you sure you want to change the base?
Feature/tmdb api implementation #60
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good effort @Yasir896 but please make sure the data flow and right layer should do correct job ✨
@@ -82,4 +88,18 @@ dependencies { | |||
kapt(libs.hilt.compiler) | |||
// Hilt navigation | |||
implementation(libs.androidx.hilt.navigation.compose) | |||
|
|||
//Retrofit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will use ktor for network
import java.io.IOException | ||
import javax.inject.Inject | ||
|
||
class NowPlayingMovieSource @Inject constructor(private val repository: MoviesRepository): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Datasource should not consume the Repository, it's the other way around. Movies repository will consume data source and then usecase will consume the repository
viewmodel -> usecase -> repository -> data source
|
||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Movie> { | ||
return try { | ||
val nextPage = params.key ?: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val nextPage = params.key ?: 1 val nowPlayingMovies = repository.getNowPlayingMovies(nextPage) LoadResult.Page( data = nowPlayingMovies.searches, prevKey = if (nextPage == 1) null else nextPage - 1, nextKey = if (nowPlayingMovies.searches.isEmpty()) null else nowPlayingMovies.page + 1 )
This part is business logic and should be moved to usecase
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class MoviesViewModel @Inject constructor(private val useCase: MoviesUseCase): ViewModel() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct formating and spacing
TMDB database API implementation to get Now Playing Movies.