A modern Android application built with Kotlin that brings the latest space flight news to your fingertips. The app fetches articles from the Space Flight News API and presents them in a beautiful, user-friendly interface.
Manages UI components, ViewModels, and user interactions using MVVM pattern.
// Example: Fragment with ViewModel@AndroidEntryPointclass ArticlesFragment : Fragment() { private val viewModel: ArticlesViewModel by viewModels() private fun observeArticle() { viewModel.articles.observe(viewLifecycleOwner) { resource -> when (resource) { is Resource.Success -> loadData(resource.data) is Resource.Loading -> showLoading() is Resource.Error -> showError() } } }}
The app uses a sealed class pattern to handle different states of data loading:
sealed class Resource<out T> { data class Success<out T>(val data: T?) : Resource<T>() data class Error<out T>(val code: String?, val msg: String, val error: Throwable? = null) : Resource<T>() data class Loading<out T>(val data: T? = null) : Resource<T>()}
This pattern provides a clean way to handle loading states, success responses, and error cases throughout the app.