mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Now using the user defined updateFreq preference for views invalidation
This commit is contained in:
1 parent
171b65a314
commit
beda26ac99
3 files changed
+10
-6
No files matched your search
@@ -32,11 +32,13 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
private val defValueLoc = application.getString(R.string.def_gsp_loc)
|
||||
private val defValueHours = application.getString(R.string.def_hours_ahead)
|
||||
private val defValueMinEl = application.getString(R.string.def_min_el)
|
||||
private val defValueUpdateFreq = application.getString(R.string.def_update_freq)
|
||||
private val keyLat = application.getString(R.string.key_lat)
|
||||
private val keyLon = application.getString(R.string.key_lon)
|
||||
private val keyAlt = application.getString(R.string.key_alt)
|
||||
private val keyHours = application.getString(R.string.key_hours_ahead)
|
||||
private val keyMinEl = application.getString(R.string.key_min_el)
|
||||
private val keyUpdateFreq = application.getString(R.string.key_update_freq)
|
||||
private val tleMainListFileName = application.getString(R.string.tle_main_list_file_name)
|
||||
private val tleSelectionFileName = application.getString(R.string.tle_selection_file_name)
|
||||
private val app = application
|
||||
@@ -67,6 +69,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
var satPassList = emptyList<SatPass>()
|
||||
var tleMainList = loadTwoLineElementFile()
|
||||
var selectionList = loadSelectionList()
|
||||
val updateFreq
|
||||
get() = preferences.getString(keyUpdateFreq, defValueUpdateFreq)!!.toLong()
|
||||
|
||||
fun updateGsp() {
|
||||
val lat = preferences.getString(keyLat, defValueLoc)!!.toDouble()
|
||||
|
||||
@@ -26,7 +26,6 @@ import kotlin.math.sin
|
||||
|
||||
class RadarFragment : Fragment() {
|
||||
|
||||
private val delay = 2000L
|
||||
private val service = Executors.newSingleThreadScheduledExecutor()
|
||||
|
||||
private lateinit var viewModel: MainViewModel
|
||||
@@ -57,6 +56,7 @@ class RadarFragment : Fragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val delay = viewModel.updateFreq
|
||||
satPass = arguments?.get("satPass") as SatPass
|
||||
mainActivity = activity as MainActivity
|
||||
mainActivity.supportActionBar?.title = satPass.tle.name
|
||||
@@ -69,7 +69,7 @@ class RadarFragment : Fragment() {
|
||||
radarAltitude = view.findViewById(R.id.radar_altitude)
|
||||
transNoFound = view.findViewById(R.id.radar_no_trans)
|
||||
|
||||
radarView = RadarView(mainActivity)
|
||||
radarView = RadarView(mainActivity, delay)
|
||||
radarSkyFrame.addView(radarView)
|
||||
service.scheduleAtFixedRate({ radarView.invalidate() }, 0, delay, TimeUnit.MILLISECONDS)
|
||||
|
||||
@@ -94,7 +94,7 @@ class RadarFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
inner class RadarView(context: Context) : View(context) {
|
||||
inner class RadarView(context: Context, updateFreq: Long) : View(context) {
|
||||
|
||||
private val radarSize = resources.displayMetrics.widthPixels
|
||||
private val scale = resources.displayMetrics.density
|
||||
@@ -104,6 +104,7 @@ class RadarFragment : Fragment() {
|
||||
private val piDiv2 = Math.PI / 2.0
|
||||
private val txtSize = scale * 15
|
||||
private val center = 0f
|
||||
private val delay = updateFreq
|
||||
|
||||
private val bmp: Bitmap = Bitmap.createBitmap(radarSize, radarSize, Bitmap.Config.ARGB_8888)
|
||||
private val mtrx: Matrix = Matrix().apply {
|
||||
|
||||
@@ -26,7 +26,6 @@ import kotlin.math.roundToInt
|
||||
|
||||
class WorldMapFragment : Fragment() {
|
||||
|
||||
private val delay = 3000L
|
||||
private val service = Executors.newSingleThreadScheduledExecutor()
|
||||
|
||||
private lateinit var viewModel: MainViewModel
|
||||
@@ -55,6 +54,7 @@ class WorldMapFragment : Fragment() {
|
||||
// fab = view.findViewById(R.id.worldmap_fab)
|
||||
// fab.setOnClickListener { showSelectSatDialog() }
|
||||
|
||||
val delay = viewModel.updateFreq
|
||||
val tleString = arrayOf(
|
||||
"METEOR-M2 2",
|
||||
"1 44387U 19038A 19336.45319619 -.00000025 00000-0 80323-5 0 9996",
|
||||
@@ -71,8 +71,7 @@ class WorldMapFragment : Fragment() {
|
||||
|
||||
trackView = TrackView(activity as MainActivity)
|
||||
mapFrame.addView(trackView)
|
||||
|
||||
service.scheduleAtFixedRate({ trackView.invalidate() }, delay, delay, TimeUnit.MILLISECONDS)
|
||||
service.scheduleAtFixedRate({ trackView.invalidate() }, 0, delay, TimeUnit.MILLISECONDS)
|
||||
}
|
||||
|
||||
// private fun showSelectSatDialog() {
|
||||
|
||||
Reference in new issue
Block a user