mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-04 11:37:22 +00:00
Added ability to toggle from pass view to map view #68
This commit is contained in:
1 parent
96ae6338a7
commit
8ef0d103e4
5 files changed
+45
-14
No files matched your search
@@ -88,6 +88,7 @@ class MapFragment : Fragment(R.layout.fragment_map) {
|
||||
}
|
||||
|
||||
private fun setupObservers(binding: FragmentMapBinding) {
|
||||
viewModel.selectDefaultSatellite(arguments?.getInt("catNum"))
|
||||
viewModel.stationPosLiveData.observe(viewLifecycleOwner, { renderStationPos(it, binding) })
|
||||
viewModel.satPositions.observe(viewLifecycleOwner, { renderSatPositions(it, binding) })
|
||||
viewModel.satTrack.observe(viewLifecycleOwner, { renderSatTrack(it, binding) })
|
||||
|
||||
@@ -61,17 +61,6 @@ class MapViewModel @Inject constructor(
|
||||
private val _satPositions = MutableLiveData<Map<Satellite, GeoPos>>()
|
||||
val satPositions: LiveData<Map<Satellite, GeoPos>> = _satPositions
|
||||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
dataRepository.getSelectedSatellites().also { selectedSatellites ->
|
||||
if (selectedSatellites.isNotEmpty()) {
|
||||
allSatList = selectedSatellites
|
||||
selectSatellite(selectedSatellites.first())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun shouldUseTextLabels(): Boolean {
|
||||
return preferences.shouldUseTextLabels()
|
||||
}
|
||||
@@ -89,6 +78,21 @@ class MapViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun selectDefaultSatellite(catnum: Int?) {
|
||||
viewModelScope.launch {
|
||||
dataRepository.getSelectedSatellites().also { satellites ->
|
||||
if (satellites.isNotEmpty()) {
|
||||
allSatList = satellites
|
||||
if (catnum == null) {
|
||||
selectSatellite(satellites.first())
|
||||
} else {
|
||||
satellites.find { it.params.catnum == catnum }?.let { selectSatellite(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun selectSatellite(satellite: Satellite, updateFreq: Long = 2000) {
|
||||
selectedSat = satellite
|
||||
viewModelScope.launch {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.rtbishop.look4sat.presentation.radarScreen
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
@@ -104,9 +105,13 @@ class RadarFragment : Fragment(R.layout.fragment_radar) {
|
||||
orientation.third
|
||||
)
|
||||
})
|
||||
binding.radarToMapButton.setOnClickListener {
|
||||
val bundle = bundleOf("catNum" to pass.catNum)
|
||||
findNavController().navigateSafe(R.id.action_radar_to_map, bundle)
|
||||
}
|
||||
}
|
||||
|
||||
// binding.addNotificationButton.setOnClickListener {
|
||||
// binding.radarNotifyButton.setOnClickListener {
|
||||
// this.context?.let { context ->
|
||||
//
|
||||
// val choicesList = arrayOf(
|
||||
|
||||
Reference in new issue
Block a user