This file contains hidden or 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
class MovieRemoteDataSourceImpl(private val movieApi: MovieApi):MovieRemoteDataSource { | |
override suspend fun getPopularMovies()= movieApi.getPopularMovies(BuildConfig.API_KEY) | |
} |
This file contains hidden or 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
data class Movie( | |
@SerializedName("id") | |
val id: Int, | |
@SerializedName("overview") | |
val overview: String?, | |
@SerializedName("poster_path") | |
val posterPath: String?, | |
@SerializedName("title") | |
val title: String?, | |
@SerializedName("vote_average") |
This file contains hidden or 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
class MovieRepositoryImpl(private val movieRemoteDataSource: MovieRemoteDataSource) : | |
MovieRepository { | |
override suspend fun getPopularMovies() = responseToRequest(movieRemoteDataSource.getPopularMovies()) | |
private fun responseToRequest(response: Response<MovieList>):Result<MovieList>{ | |
if(response.isSuccessful){ | |
response.body()?.let {result-> | |
return Result.Success(result) | |
} | |
} |
This file contains hidden or 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
@HiltViewModel | |
class HomeViewModel @Inject constructor( | |
private val getPopularMoviesUseCase: GetPopularMoviesUseCase | |
) : ViewModel() { | |
private val _movieState = mutableStateOf<Result<MovieList>>(Result.Loading()) | |
val movieState: State<Result<MovieList>> = _movieState | |
init { | |
getPopularMovies() | |
} |
This file contains hidden or 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
@Composable | |
fun HomeScreen(navController: NavHostController, viewModel: HomeViewModel = hiltViewModel()) { | |
val systemUiController = rememberSystemUiController() | |
val systemBarColor = MaterialTheme.colors.statusBarColor | |
val titleColor = MaterialTheme.colors.titleColor | |
val topAppbarBackgroundColor = MaterialTheme.colors.topAppbarBackgroundColor | |
SideEffect { | |
systemUiController.setStatusBarColor( |
This file contains hidden or 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
@Entity(tableName = "users") | |
data class User( | |
@PrimaryKey(autoGenerate = true) | |
@ColumnInfo(name = "user_id") | |
var id: Int, | |
@ColumnInfo(name = "user_name") | |
var name: String, |
This file contains hidden or 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
@Database( | |
entities = [User::class], | |
version = 1, | |
) |
This file contains hidden or 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
@ColumnInfo(name = "user_address") | |
var address: String? = null |
This file contains hidden or 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
@Database( | |
entities = [User::class], | |
version = 2, | |
autoMigrations = [AutoMigration(from = 1, to = 2)], | |
exportSchema = true | |
) |
This file contains hidden or 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
kapt { | |
arguments { | |
arg("room.schemaLocation", "$projectDir/schemas") | |
} | |
} |