I'm an Android Engineer at Spotify
I think my favorite thing to talk about is software architecture.
Thanks for checking out my profile.
Android architecture sample with dynamic feature modularisation, clean architecture with MVI (Uni-directional data flow), dagger hilt, DFM Navigation, kotlin coroutines with StateFlow and Exo player.
License: Apache License 2.0
After a while researching for clean architecture examples see here
Fernando Cejas using Either
for handling throwable and success type and possible to reduce declaring each ViewResult
with Error(throwable)
Is there any concern why using data class RecipeViewState
instead of using sealed class RecipeViewState
?
Equivalent to your existing code using sealed class
sealed class RecipeViewState : ViewState {
object Loading : RecipeViewState()
object Refreshing : RecipeViewState()
data class LoadedRecipes(val recipes: List<RecipeModel>) : RecipeViewState()
data class LikedRecipe(val recipe: RecipeModel) : RecipeViewState() // adding a new state for liked item
data class Error(val error: String?, val errorEvent: ViewEvent<String>?, val isEmpty: Boolean) // Unavailable, No data or empty etc
}
// in Fragment
// instead of:
override fun render(state: RecipeViewState) {
when {
state.isDataUnavailable -> binding.renderEmptyState(state)
state.isDataAvailableError -> binding.renderDataAvailableErrorState(state)
state.isNoDataError -> binding.renderNoDataErrorState(state)
state.isLoading -> binding.renderLoadingState()
state.isRefreshing -> binding.renderRefreshState()
else -> binding.renderSuccessState(state)
}
}
// modifed to:
override fun render(state: RecipeViewState) {
when (state) {
is Error -> {
if (state.error != null) binding.renderNoDataErrorState(state)
if (state.errorEvent != null) binding.renderDataAvailableErrorState(state)
if (state.isEmpty) binding.renderEmptyState(state)
}
Loading -> binding.renderLoadingState()
Refreshing -> binding.renderRefreshState()
is LikedRecipe -> binding.renderLikedState(state)
is LoadedRecipes -> binding.renderSuccessState(state)
// no else branch
}
}
Pros:
RecipeViewState
using .copy
with a new stateoverride fun render
RecipeViewState
, e.g for current approach: val *state: RecipeViewState get() = /* this.copy(isLoading = false, etc) */
Does the current view state handle retrofit exception? E.g: 4xx or 5xx Retrofit error response/body
CMIIW, I cannot find try-catch
blocks in your ViewModel, Processor, Remote & Repository to handle that
Hi Ezike, The current version of the project is using Bintray Repository and the AGP Version is also not compatible.
I'm currently using Android Studio Dolphin Canary.
Hello,
thank you for your great job. when I try to build project I got this error:
This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.2 or newer.
-- I use android studio 4.1 version (is there available android studio 4.2 in this time?)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.