mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Libs update, bug with SatPass parcelable fixed, regression fixed
This commit is contained in:
1 parent
1730e3b37c
commit
f2689edce4
10 files changed
+52
-40
No files matched your search
+3
-3
@@ -25,13 +25,13 @@ apply plugin: "androidx.navigation.safeargs.kotlin"
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
buildToolsVersion "29.0.3"
|
||||
defaultConfig {
|
||||
applicationId "com.rtbishop.look4sat"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 3
|
||||
versionName '1.2'
|
||||
versionCode 5
|
||||
versionName '1.2.2'
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.rtbishop.look4sat.repo.Repository
|
||||
import com.rtbishop.look4sat.repo.SatPass
|
||||
import com.rtbishop.look4sat.repo.Transmitter
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.FileNotFoundException
|
||||
@@ -75,6 +76,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
"https://celestrak.com/NORAD/elements/weather.txt"
|
||||
)
|
||||
|
||||
private var calculationJob: Job? = null
|
||||
|
||||
@Inject
|
||||
lateinit var locationClient: FusedLocationProviderClient
|
||||
@Inject
|
||||
@@ -177,6 +180,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
}
|
||||
|
||||
fun getPasses() {
|
||||
calculationJob?.cancel()
|
||||
val passList = mutableListOf<SatPass>()
|
||||
val dateNow = Date()
|
||||
val dateFuture = Calendar.getInstance().let {
|
||||
@@ -184,28 +188,33 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
it.add(Calendar.HOUR, hoursAhead)
|
||||
it.time
|
||||
}
|
||||
viewModelScope.launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
tleSelection.forEach { indexOfSelection ->
|
||||
val tle = tleMainList[indexOfSelection]
|
||||
try {
|
||||
val predictor = PassPredictor(tle, gsp.value!!)
|
||||
val passes = predictor.getPasses(dateNow, hoursAhead, true)
|
||||
passes.forEach {
|
||||
passList.add(SatPass(tle, predictor, it))
|
||||
calculationJob = viewModelScope.launch {
|
||||
if (tleMainList.isNotEmpty() && tleSelection.isNotEmpty()) {
|
||||
withContext(Dispatchers.Default) {
|
||||
tleSelection.forEach { indexOfSelection ->
|
||||
val tle = tleMainList[indexOfSelection]
|
||||
try {
|
||||
val predictor = PassPredictor(tle, gsp.value!!)
|
||||
val passes = predictor.getPasses(dateNow, hoursAhead, true)
|
||||
passes.forEach {
|
||||
passList.add(SatPass(tle, predictor, it))
|
||||
}
|
||||
} catch (exception: IllegalArgumentException) {
|
||||
_debugMessage.postValue(app.getString(R.string.err_parse_tle))
|
||||
} catch (exception: SatNotFoundException) {
|
||||
_debugMessage.postValue(app.getString(R.string.err_sat_wont_pass))
|
||||
}
|
||||
} catch (exception: IllegalArgumentException) {
|
||||
_debugMessage.postValue(app.getString(R.string.err_parse_tle))
|
||||
} catch (exception: SatNotFoundException) {
|
||||
_debugMessage.postValue(app.getString(R.string.err_sat_wont_pass))
|
||||
}
|
||||
passList.removeAll { it.pass.startTime.after(dateFuture) }
|
||||
passList.removeAll { it.pass.endTime.before(dateNow) }
|
||||
passList.removeAll { it.pass.maxEl < minEl }
|
||||
passList.sortBy { it.pass.startTime }
|
||||
}
|
||||
passList.removeAll { it.pass.startTime.after(dateFuture) }
|
||||
passList.removeAll { it.pass.endTime.before(dateNow) }
|
||||
passList.removeAll { it.pass.maxEl < minEl }
|
||||
passList.sortBy { it.pass.startTime }
|
||||
_satPassList.postValue(passList)
|
||||
} else {
|
||||
_satPassList.postValue(mutableListOf())
|
||||
_debugMessage.postValue(app.getString(R.string.err_no_sat_selected))
|
||||
}
|
||||
_satPassList.postValue(passList)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,14 @@
|
||||
|
||||
package com.rtbishop.look4sat.repo
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.github.amsacode.predict4java.SatPassTime
|
||||
import com.github.amsacode.predict4java.TLE
|
||||
import com.rtbishop.look4sat.predict4kotlin.PassPredictor
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.android.parcel.RawValue
|
||||
|
||||
@Parcelize
|
||||
data class SatPass(
|
||||
val tle: TLE,
|
||||
val predictor: @RawValue PassPredictor,
|
||||
val pass: @RawValue SatPassTime,
|
||||
val predictor: PassPredictor,
|
||||
val pass: SatPassTime,
|
||||
var progress: Int = 0,
|
||||
var active: Boolean = false
|
||||
) : Parcelable
|
||||
)
|
||||
@@ -65,7 +65,7 @@ class PassListFragment : Fragment() {
|
||||
super.onCreate(savedInstanceState)
|
||||
mainActivity = activity as MainActivity
|
||||
viewModel = ViewModelProvider(mainActivity).get(MainViewModel::class.java)
|
||||
satPassAdapter = SatPassAdapter()
|
||||
satPassAdapter = SatPassAdapter(viewModel)
|
||||
satPassList = mutableListOf()
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ class PassListFragment : Fragment() {
|
||||
satPassRecycler.apply {
|
||||
layoutManager = LinearLayoutManager(mainActivity)
|
||||
adapter = satPassAdapter
|
||||
isVerticalScrollBarEnabled = false
|
||||
(itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
|
||||
}
|
||||
satPassAdapter.setList(satPassList)
|
||||
|
||||
@@ -83,7 +83,7 @@ class PolarViewFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val delay = viewModel.delay
|
||||
satPass = args.satPass
|
||||
satPass = viewModel.passSatList.value!![args.satPassIndex]
|
||||
mainActivity.supportActionBar?.title = satPass.tle.name
|
||||
|
||||
polarViewFrame = view.findViewById(R.id.polar_view_frame)
|
||||
|
||||
@@ -28,13 +28,15 @@ import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.rtbishop.look4sat.MainViewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.repo.SatPass
|
||||
import com.rtbishop.look4sat.ui.PassListFragmentDirections
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class SatPassAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
class SatPassAdapter(val viewModel: MainViewModel) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private var satPassList = mutableListOf<SatPass>()
|
||||
|
||||
@@ -134,8 +136,9 @@ class SatPassAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
progressBar.progress = satPass.progress
|
||||
|
||||
itemView.setOnClickListener {
|
||||
val action = PassListFragmentDirections.actionPassToPolar(satPass)
|
||||
itemView.findNavController().navigate(action)
|
||||
val satPassIndex = viewModel.passSatList.value!!.indexOf(satPass)
|
||||
val action = PassListFragmentDirections.actionPassToPolar(satPassIndex)
|
||||
it.findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,8 +162,9 @@ class SatPassAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
String.format(context.getString(R.string.pat_elevation), satPass.pass.maxEl)
|
||||
|
||||
itemView.setOnClickListener {
|
||||
val action = PassListFragmentDirections.actionPassToPolar(satPass)
|
||||
itemView.findNavController().navigate(action)
|
||||
val satPassIndex = viewModel.passSatList.value!!.indexOf(satPass)
|
||||
val action = PassListFragmentDirections.actionPassToPolar(satPassIndex)
|
||||
it.findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
android:label="@string/menu_polar_view"
|
||||
tools:layout="@layout/fragment_polar_view">
|
||||
<argument
|
||||
android:name="satPass"
|
||||
app:argType="com.rtbishop.look4sat.repo.SatPass" />
|
||||
android:name="satPassIndex"
|
||||
app:argType="integer" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<string name="err_enter_value">Пожалуйста, введите значение</string>
|
||||
<string name="err_no_tle_file">Не найден файл TLE</string>
|
||||
<string name="err_no_selection_file">Не найден файл выбранных спутников</string>
|
||||
<string name="err_no_sat_selected">Не выбраны спутники</string>
|
||||
|
||||
<string name="pass_aos_az">НПС — %2d°</string>
|
||||
<string name="pass_maxEl">Элевация: %.1f°</string>
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
<string name="err_enter_value">Please, enter the value</string>
|
||||
<string name="err_no_tle_file">TLE file was not found</string>
|
||||
<string name="err_no_selection_file">Selection file was not found</string>
|
||||
<string name="err_no_sat_selected">No satellites selected</string>
|
||||
|
||||
<string name="pass_satName" translatable="false">%s</string>
|
||||
<string name="pass_satId" translatable="false">ID: %d</string>
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:3.5.3"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
|
||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.0"
|
||||
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ ext {
|
||||
supportLib = '1.0.0'
|
||||
constraintLayout = '1.1.3'
|
||||
|
||||
ktx = '1.1.0'
|
||||
ktx = '1.2.0'
|
||||
preference = '1.1.0'
|
||||
|
||||
navigation = '2.2.0'
|
||||
navigation = '2.2.1'
|
||||
lifecycle = '2.2.0'
|
||||
|
||||
room = '2.2.3'
|
||||
|
||||
Reference in new issue
Block a user