View mvi_viewmodel_sample.kt
This file contains 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
enum class LoadState { | |
IDLE, | |
LOADING, | |
LOADED, | |
ERROR | |
} | |
data class CitiesState( | |
val loadState: LoadState, | |
val cities: List<CityResultModel>, |
View mvi_viewmodel.kt
This file contains 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
/** | |
* Marker class for the view state | |
*/ | |
interface State | |
/** | |
* Marker class for View Intents | |
*/ | |
interface MviIntent |
View mvvm_viewmodel_sample.kt
This file contains 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
enum class LoadState { | |
IDLE, | |
LOADING, | |
LOADED, | |
ERROR | |
} | |
@HiltViewModel | |
class CityViewModel @Inject constructor( | |
private val getCitiesInteractor: GetCitiesInteractor, |
View cities_mvi_viewmodel.kt
This file contains 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
enum class LoadState { | |
IDLE, | |
LOADING, | |
LOADED, | |
ERROR | |
} | |
data class CityState( | |
val loadState: LoadState, | |
val cities: List<CityResultModel>, |
View city_mvi_fragment.kt
This file contains 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
@AndroidEntryPoint | |
class CityFragment : Fragment() { | |
private lateinit var binding: FragmentCityBinding | |
private val viewModel: CityViewModel by viewModels() | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? |
View RecyclerViewBindingItem.kt
This file contains 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
interface Diffable { | |
val id: Long | |
} | |
interface RecyclerViewBindingItem : Diffable { | |
val type: Int | |
fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerViewViewHolder<*> | |
} |
View base_viewholder.kt
This file contains 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
abstract class RecyclerViewViewHolder<T : Diffable>( | |
protected val binding: ViewDataBinding | |
) : RecyclerView.ViewHolder(binding.root) { | |
abstract fun bind(bindingItem: T) | |
} |
View viewholder_forecast_header.xml
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="state" | |
type="com.francescsoftware.weathersample.presentation.feature.weather.tabs.forecast.ForecastHeaderState" /> |
View viewholder_forecast_card.xml
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:bind="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="state" |
View forecast_viewholders.kt
This file contains 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 ForecastHeaderViewHolder( | |
binding: ViewholderForecastHeaderBinding | |
) : RecyclerViewViewHolder<ForecastHeaderBindingItem>(binding) { | |
override fun bind(bindingItem: ForecastHeaderBindingItem) { | |
(binding as ViewholderForecastHeaderBinding).state = bindingItem.forecastHeaderState | |
binding.executePendingBindings() | |
} | |
} |
OlderNewer