Skip to content

Commit

Permalink
Merge pull request #796 from PhenoApps/issue/795
Browse files Browse the repository at this point in the history
fix gnss flickering
  • Loading branch information
trife authored Nov 1, 2023
2 parents 2d685bc + 4aac004 commit fe1e52f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions app/src/main/java/com/fieldbook/tracker/traits/GNSSTraitLayout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class GNSSTraitLayout : BaseTraitLayout, GPSTracker.GPSTrackerListener {
true
}

constructor(context: Context?) : super(context) {}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

data class AverageInfo(var unit: ObservationUnitModel, var location: Location?,
var points: List<Pair<Double, Double>>,
Expand Down Expand Up @@ -188,6 +188,13 @@ class GNSSTraitLayout : BaseTraitLayout, GPSTracker.GPSTrackerListener {
}
}

private fun unregisterGnssReceiver() {
try {
mLocalBroadcastManager.unregisterReceiver(receiver)
} catch (ignore: Exception) {
}
}

private fun initialize() {

mProgressDialog = AlertDialog.Builder(context)
Expand All @@ -202,6 +209,8 @@ class GNSSTraitLayout : BaseTraitLayout, GPSTracker.GPSTrackerListener {
val filter = IntentFilter()
filter.addAction(ACTION_BROADCAST_GNSS_TRAIT)

unregisterGnssReceiver()

/**
* When a BROADCAST_BT_OUTPUT is received and parsed, this interface is called.
* The parser parameter is a model for the parsed message, and is used to populate the
Expand Down Expand Up @@ -707,7 +716,8 @@ class GNSSTraitLayout : BaseTraitLayout, GPSTracker.GPSTrackerListener {

setupAveragingUi()

connectionCheckHandler()
if (!connectionCheckRunning)
connectionCheckHandler()

}

Expand All @@ -725,8 +735,11 @@ class GNSSTraitLayout : BaseTraitLayout, GPSTracker.GPSTrackerListener {
}
}

private var connectionCheckRunning = false
private fun connectionCheckHandler() {

connectionCheckRunning = true

val deviceName = prefs.getString(GeneralKeys.GNSS_LAST_PAIRED_DEVICE_NAME, null)

if (deviceName != context.getString(R.string.pref_behavior_geonav_internal_gps_choice)) {
Expand Down

0 comments on commit fe1e52f

Please sign in to comment.