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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout 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" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="center" | |
android:orientation="vertical" | |
tools:context=".MainActivity"> |
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
sealed class Interaction { | |
object BackButtonClick : Interaction() | |
object SkipButtonClick : Interaction() | |
object SaveButtonClick : Interaction() | |
data class NameChange(val name: String) : Interaction() | |
} |
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
object RepositoryData | |
class Repository { | |
fun observeChanges(observer: (RepositoryData) -> Unit) { | |
//some logic | |
observer.invoke(RepositoryData) | |
} | |
} |
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 ModelData( | |
val progressVisible: Boolean, | |
) | |
class ViewModel( | |
private val repository: Repository, | |
private val navigator: Navigator | |
) : ViewModel() { | |
private val _liveData = MutableLiveData<ModelData>() |
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 Fragment : Fragment() { | |
@Inject | |
lateinit var viewModel: ViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
viewModel.liveData.observe(this, Observer { data -> /* update the view */ }) |
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 Interactor( | |
private val repository: Repository, | |
private val navigator: Navigator, | |
private val viewModel: ViewModel | |
) { | |
fun onInteraction(interaction: Interaction) { | |
when (interaction) { | |
is Interaction.BackButtonClick -> onBackButtonClicked() | |
is Interaction.SkipButtonClick -> onSkipButtonClicked() |
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 ModelData( | |
val progressVisible: Boolean, | |
) | |
class ViewModel( | |
repository: Repository | |
) : ViewModel() { | |
private val _liveData = MutableLiveData<ModelData>() | |
val liveData: LiveData<ModelData> = _liveData |
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 Fragment : Fragment() { | |
@Inject | |
lateinit var viewModel: ViewModel | |
@Inject | |
lateinit var interactor: Interactor | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) |
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 SettingsViewModel( | |
settingsRepository: SettingsRepository | |
) : ViewModel() { | |
private val _firstName = MutableLiveData<String>() | |
val firstName: LiveData<String> = _firstName | |
private val _lastName = MutableLiveData<String>() | |
val lastName: LiveData<String> = _lastName |
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 SettingsRepository { | |
val settings: Settings get() = /* retrieving settings */ | |
} |