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
fun main() = runBlocking { | |
println("runBlocking main") | |
val scope = CoroutineScope(Job()) | |
println("scope created. Create job...") | |
val job = scope.launch { | |
... | |
} |
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
fun main() = runBlocking { | |
println("runBlocking main") | |
val scope = CoroutineScope(Job()) | |
println("scope created. Create job...") | |
val job = scope.launch { | |
val task1 = runBlocking { | |
println(" task1") |
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
fun main() = runBlocking { | |
println("runBlocking main") | |
val task1 = runBlocking { | |
println(" task1") | |
// simulate a background task | |
delay(1000) | |
println(" task1: Done background task") | |
} |
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 ErrorViewState { | |
object Content : ErrorViewState() | |
} | |
class ErrorViewModel : ViewModel() { | |
private val _viewState = MutableLiveData<ErrorViewState>() | |
val viewState: LiveData<ErrorViewState> = _viewState | |
init { | |
_viewState.value = ErrorViewState.Content |
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 InvasiveSpeciesMapFragment: Fragment() { | |
private val navigator by lazy { (requireActivity() as MainActivity).navigator } | |
private val viewModel by viewModels<InvasiveSpeciesMapViewModel>() | |
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = | |
inflater.inflate(R.layout.fragment_invasive_species_map, container, false) | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) |
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 InvasiveSpeciesMapFragment: Fragment() { | |
private val navController by lazy { | |
Navigation.findNavController(requireActivity(), R.id.fragment_container) | |
} | |
private val viewModel by viewModels<InvasiveSpeciesMapViewModel> { | |
InvasiveSpeciesMapViewModelFactory(navigator = Navigator(navController, resources)) | |
} |
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"?> | |
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/app_background" | |
android:orientation="vertical" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<ProgressBar |
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 MainActivityViewState { | |
object Loading : MainActivityViewState() | |
object Content : MainActivityViewState() | |
} | |
class MainActivityViewModel: ViewModel() { | |
private val _viewState = MutableLiveData<MainActivityViewState>() | |
val viewState: LiveData<MainActivityViewState> = _viewState |
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 MainActivity : SingleFragmentActivity() { | |
... | |
private val navController by lazy { | |
val navHostFragment = | |
supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment | |
navHostFragment.navController | |
} | |
val navigator by lazy { Navigator(navController, resources) } |
NewerOlder