mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +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) {
|
private fun setupObservers(binding: FragmentMapBinding) {
|
||||||
|
viewModel.selectDefaultSatellite(arguments?.getInt("catNum"))
|
||||||
viewModel.stationPosLiveData.observe(viewLifecycleOwner, { renderStationPos(it, binding) })
|
viewModel.stationPosLiveData.observe(viewLifecycleOwner, { renderStationPos(it, binding) })
|
||||||
viewModel.satPositions.observe(viewLifecycleOwner, { renderSatPositions(it, binding) })
|
viewModel.satPositions.observe(viewLifecycleOwner, { renderSatPositions(it, binding) })
|
||||||
viewModel.satTrack.observe(viewLifecycleOwner, { renderSatTrack(it, binding) })
|
viewModel.satTrack.observe(viewLifecycleOwner, { renderSatTrack(it, binding) })
|
||||||
|
|||||||
@@ -61,17 +61,6 @@ class MapViewModel @Inject constructor(
|
|||||||
private val _satPositions = MutableLiveData<Map<Satellite, GeoPos>>()
|
private val _satPositions = MutableLiveData<Map<Satellite, GeoPos>>()
|
||||||
val satPositions: LiveData<Map<Satellite, GeoPos>> = _satPositions
|
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 {
|
fun shouldUseTextLabels(): Boolean {
|
||||||
return preferences.shouldUseTextLabels()
|
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) {
|
fun selectSatellite(satellite: Satellite, updateFreq: Long = 2000) {
|
||||||
selectedSat = satellite
|
selectedSat = satellite
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.rtbishop.look4sat.presentation.radarScreen
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
@@ -104,9 +105,13 @@ class RadarFragment : Fragment(R.layout.fragment_radar) {
|
|||||||
orientation.third
|
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 ->
|
// this.context?.let { context ->
|
||||||
//
|
//
|
||||||
// val choicesList = arrayOf(
|
// val choicesList = arrayOf(
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
app:layout_constraintEnd_toEndOf="@+id/radar_frame" />
|
app:layout_constraintEnd_toEndOf="@+id/radar_frame" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/add_notification_button"
|
android:id="@+id/radar_notify_button"
|
||||||
android:layout_width="64dp"
|
android:layout_width="64dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
@@ -86,10 +86,24 @@
|
|||||||
android:contentDescription="@string/placeholder"
|
android:contentDescription="@string/placeholder"
|
||||||
android:elevation="4dp"
|
android:elevation="4dp"
|
||||||
android:src="@drawable/ic_notification"
|
android:src="@drawable/ic_notification"
|
||||||
|
android:visibility="invisible"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/radar_bar"
|
app:layout_constraintBottom_toBottomOf="@+id/radar_bar"
|
||||||
app:layout_constraintStart_toStartOf="@+id/radar_bar"
|
app:layout_constraintStart_toStartOf="@+id/radar_bar"
|
||||||
app:layout_constraintTop_toTopOf="@+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" />
|
tools:ignore="DuplicateSpeakableTextCheck" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|||||||
@@ -48,6 +48,13 @@
|
|||||||
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
app:popExitAnim="@anim/nav_default_pop_exit_anim"
|
||||||
app:popUpTo="@id/nav_passes"
|
app:popUpTo="@id/nav_passes"
|
||||||
app:popUpToInclusive="true" />
|
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>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_map"
|
android:id="@+id/nav_map"
|
||||||
|
|||||||
Reference in new issue
Block a user