equal
deleted
inserted
replaced
32 /** |
32 /** |
33 * Manage opensource license information and allow to display them in an UI |
33 * Manage opensource license information and allow to display them in an UI |
34 */ |
34 */ |
35 class OpenSourceLicensesViewModel( |
35 class OpenSourceLicensesViewModel( |
36 private val licenseInfoRepository: LicenseInfoRepository, |
36 private val licenseInfoRepository: LicenseInfoRepository, |
37 private val browserLauncher: BrowserLauncher, |
|
38 ) : ViewModel() { |
37 ) : ViewModel() { |
39 init { |
|
40 browserLauncher.warmUp() |
|
41 } |
|
42 |
38 |
43 private val licensesInfo = flow { |
39 private val licensesInfo = flow { |
44 emit(licenseInfoRepository.getLicensesInfo()) |
40 emit(licenseInfoRepository.getLicensesInfo()) |
45 }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyMap()) |
41 }.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyMap()) |
46 |
42 |
50 |
46 |
51 fun getLicenseDependency(dependency: String) = flow { |
47 fun getLicenseDependency(dependency: String) = flow { |
52 emit(licenseInfoRepository.getLicenseFor(dependency)) |
48 emit(licenseInfoRepository.getLicenseFor(dependency)) |
53 } |
49 } |
54 |
50 |
55 fun openLinkInBrowser(link: String) { |
|
56 browserLauncher.launchUrl(link) |
|
57 } |
|
58 |
|
59 fun mayLaunchUrl(vararg uris: String) = browserLauncher.mayLaunchUrl(*uris) |
|
60 |
|
61 override fun onCleared() { |
|
62 browserLauncher.shutdown() |
|
63 } |
|
64 |
|
65 companion object |
51 companion object |
66 } |
52 } |