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
rm -Rf /Applications/Android\ Studio.app | |
rm -Rf ~/Library/Preferences/AndroidStudio* | |
rm -Rf ~/Library/Preferences/Google/AndroidStudio* | |
rm -Rf ~/Library/Preferences/com.google.android.* | |
rm -Rf ~/Library/Preferences/com.android.* | |
rm -Rf ~/Library/Application\ Support/AndroidStudio* | |
rm -Rf ~/Library/Application\ Support/Google/AndroidStudio* | |
rm -Rf ~/Library/Logs/AndroidStudio* | |
rm -Rf ~/Library/Logs/Google/AndroidStudio* | |
rm -Rf ~/Library/Caches/AndroidStudio* |
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
/* | |
* Copyright 2019 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
@Composable | |
abstract fun buildUI() |
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 MyActivity: Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setupViewModel() | |
} | |
private fun setupViewModel() { | |
viewModel = //factory fancy way to get the instance of ViewModel | |
viewModel.viewState.observe(this, Observer { | |
when (it) { | |
MVIViewState.Loading -> { // show loading |
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 MVIViewModel : ViewModel() { | |
val viewState: MutableLiveData<MVIViewState>() | |
fun fetchData() { | |
myDataSource.fetchData() | |
.doOnSubscribe { | |
viewState.postValue(MVIViewState.Loading) | |
} | |
.observe( | |
{ |
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
sealed class MVIViewState { | |
object Loading: MVIViewState() | |
class Error(val reason: String): MVIViewState() | |
class Success(val result: String): MVIViewState() | |
} |
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 MyActivity: Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
CraneWrapper { | |
MyApp() | |
} | |
} | |
} | |
} |
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
@Composable | |
fun MyApp() { | |
MaterialTheme { Text("Hello there!") } | |
} |
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 MVIJetpackComposeActivity : AppCompatActivity() { | |
lateinit var myViewModel: MVIJetpackComposeViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
myViewModel = // factory to instantiate viewmodel | |
// just call setContent once | |
setContent { | |
CraneWrapper { |
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 MVIJetpackComposeViewModel : ViewModel() { | |
private val _jetpackComposeViewState = MutableLiveData<MVIJetpackComposeViewState>() | |
private val useCase = UseCase() | |
val jetpackComposeViewState: LiveData<MVIJetpackComposeViewState> | |
get() = _jetpackComposeViewState | |
init { | |
loadData() | |
} |
NewerOlder