kopia lustrzana https://github.com/rt-bishop/Look4Sat
Added ability to toggle from pass view to map view #68
rodzic
96ae6338a7
commit
8ef0d103e4
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
app:layout_constraintEnd_toEndOf="@+id/radar_frame" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/add_notification_button"
|
||||
android:id="@+id/radar_notify_button"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="4dp"
|
||||
|
|
@ -86,10 +86,24 @@
|
|||
android:contentDescription="@string/placeholder"
|
||||
android:elevation="4dp"
|
||||
android:src="@drawable/ic_notification"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/radar_bar"
|
||||
app:layout_constraintStart_toStartOf="@+id/radar_bar"
|
||||
app:layout_constraintTop_toTopOf="@+id/radar_bar"
|
||||
app:tint="@color/greyLight"
|
||||
tools:ignore="DuplicateSpeakableTextCheck" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/radar_to_map_button"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:backgroundTint="@color/greyDark"
|
||||
android:contentDescription="@string/placeholder"
|
||||
android:elevation="4dp"
|
||||
android:src="@drawable/ic_nav_map"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/radar_bar"
|
||||
app:layout_constraintEnd_toEndOf="@+id/radar_bar"
|
||||
app:layout_constraintTop_toTopOf="@+id/radar_bar"
|
||||
tools:ignore="DuplicateSpeakableTextCheck" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@
|
|||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||
app:popUpTo="@id/nav_passes"
|
||||
app:popUpToInclusive="true" />
|
||||
<action
|
||||
android:id="@+id/action_radar_to_map"
|
||||
app:destination="@id/nav_map"
|
||||
app:enterAnim="@anim/nav_default_enter_anim"
|
||||
app:exitAnim="@anim/nav_default_exit_anim"
|
||||
app:popEnterAnim="@anim/nav_default_pop_enter_anim"
|
||||
app:popExitAnim="@anim/nav_default_pop_exit_anim" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/nav_map"
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue