mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Using liveData builder for appTimer, hilt update
This commit is contained in:
1 parent
c929e94d0e
commit
a8f3c5eb77
2 files changed
+9
-14
No files matched your search
@@ -42,7 +42,6 @@ class SharedViewModel @Inject constructor(
|
|||||||
private val transmittersRepo: TransmittersRepo
|
private val transmittersRepo: TransmittersRepo
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
private val _appTimer = MutableLiveData(System.currentTimeMillis())
|
|
||||||
private val _passes = MutableLiveData<Result<MutableList<SatPass>>>()
|
private val _passes = MutableLiveData<Result<MutableList<SatPass>>>()
|
||||||
private val _appEvent = MutableLiveData<Event<Int>>()
|
private val _appEvent = MutableLiveData<Event<Int>>()
|
||||||
private var selectedEntries = emptyList<SatEntry>()
|
private var selectedEntries = emptyList<SatEntry>()
|
||||||
@@ -53,11 +52,16 @@ class SharedViewModel @Inject constructor(
|
|||||||
updateDefaultSourcesAndEntries()
|
updateDefaultSourcesAndEntries()
|
||||||
prefsManager.setFirstLaunchDone()
|
prefsManager.setFirstLaunchDone()
|
||||||
}
|
}
|
||||||
startApplicationTimer()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAppEvent(): LiveData<Event<Int>> = _appEvent
|
fun getAppEvent(): LiveData<Event<Int>> = _appEvent
|
||||||
fun getAppTimer(): LiveData<Long> = _appTimer
|
fun getAppTimer() = liveData {
|
||||||
|
while (true) {
|
||||||
|
emit(System.currentTimeMillis())
|
||||||
|
delay(1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getSources() = sourcesRepo.getSources().asLiveData()
|
fun getSources() = sourcesRepo.getSources().asLiveData()
|
||||||
fun getEntries() = entriesRepo.getEntries().asLiveData()
|
fun getEntries() = entriesRepo.getEntries().asLiveData()
|
||||||
fun getPasses(): LiveData<Result<MutableList<SatPass>>> = _passes
|
fun getPasses(): LiveData<Result<MutableList<SatPass>>> = _passes
|
||||||
@@ -122,15 +126,6 @@ class SharedViewModel @Inject constructor(
|
|||||||
_appEvent.value = event
|
_appEvent.value = event
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startApplicationTimer(tickMillis: Long = 1000L) {
|
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
|
||||||
while (true) {
|
|
||||||
delay(tickMillis)
|
|
||||||
_appTimer.postValue(System.currentTimeMillis())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getPasses(entry: SatEntry, dateNow: Date): MutableList<SatPass> {
|
private fun getPasses(entry: SatEntry, dateNow: Date): MutableList<SatPass> {
|
||||||
val gsp = prefsManager.getStationPosition()
|
val gsp = prefsManager.getStationPosition()
|
||||||
val predictor = PassPredictor(entry.tle, gsp)
|
val predictor = PassPredictor(entry.tle, gsp)
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
gradle_version = '4.1.2'
|
gradle_version = '4.1.2'
|
||||||
gradle_plugin_version = '1.4.30'
|
gradle_plugin_version = '1.4.31'
|
||||||
material_version = '1.3.0'
|
material_version = '1.3.0'
|
||||||
constraint_layout_version = '2.0.4'
|
constraint_layout_version = '2.0.4'
|
||||||
lifecycle_version = '2.3.0'
|
lifecycle_version = '2.3.0'
|
||||||
@@ -9,7 +9,7 @@ buildscript {
|
|||||||
preference_version = '1.1.1'
|
preference_version = '1.1.1'
|
||||||
view_pager2_version = '1.0.0'
|
view_pager2_version = '1.0.0'
|
||||||
room_version = '2.2.6'
|
room_version = '2.2.6'
|
||||||
hilt_version = '2.32-alpha'
|
hilt_version = '2.33-beta'
|
||||||
hilt_viewmodel_version = '1.0.0-alpha03'
|
hilt_viewmodel_version = '1.0.0-alpha03'
|
||||||
retrofit_version = '2.9.0'
|
retrofit_version = '2.9.0'
|
||||||
osmdroid_version = '6.1.10'
|
osmdroid_version = '6.1.10'
|
||||||
|
|||||||
Reference in new issue
Block a user