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>, |
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 |
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, |
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>, |
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? |
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<*> | |
} |
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) | |
} |
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" /> |
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" |
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