Add LeakCanary.
This commit is contained in:
parent
ccaec4bf10
commit
bac441ad4b
3 changed files with 26 additions and 14 deletions
|
@ -74,4 +74,6 @@ dependencies {
|
||||||
|
|
||||||
// OpenStreetMap
|
// OpenStreetMap
|
||||||
implementation 'org.osmdroid:osmdroid-android:6.1.14'
|
implementation 'org.osmdroid:osmdroid-android:6.1.14'
|
||||||
|
|
||||||
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,17 +296,22 @@ class MapFragment : Fragment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView()
|
||||||
|
{
|
||||||
|
Log.i("VOUSSOIR", "MapFragment.onDestroy")
|
||||||
|
super.onDestroyView()
|
||||||
|
if (database_changed_listener in trackbook.database_changed_listeners)
|
||||||
|
{
|
||||||
|
trackbook.database_changed_listeners.remove(database_changed_listener)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy()
|
override fun onDestroy()
|
||||||
{
|
{
|
||||||
Log.i("VOUSSOIR", "MapFragment.onDestroy")
|
Log.i("VOUSSOIR", "MapFragment.onDestroy")
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
trackerService.mapfragment = null
|
trackerService.mapfragment = null
|
||||||
requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
|
||||||
if (database_changed_listener in trackbook.database_changed_listeners)
|
|
||||||
{
|
|
||||||
trackbook.database_changed_listeners.remove(database_changed_listener)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val requestLocationPermissionLauncher = registerForActivityResult(RequestPermission()) { isGranted: Boolean ->
|
private val requestLocationPermissionLauncher = registerForActivityResult(RequestPermission()) { isGranted: Boolean ->
|
||||||
|
@ -594,10 +599,14 @@ class MapFragment : Fragment()
|
||||||
private val connection = object : ServiceConnection {
|
private val connection = object : ServiceConnection {
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder)
|
override fun onServiceConnected(className: ComponentName, service: IBinder)
|
||||||
{
|
{
|
||||||
|
// get reference to tracker service]
|
||||||
|
val serviceref = (service as TrackerServiceBinder).service.get()
|
||||||
|
if (serviceref == null)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
}
|
||||||
bound = true
|
bound = true
|
||||||
// get reference to tracker service
|
trackerService = serviceref
|
||||||
val binder = service as TrackerService.LocalBinder
|
|
||||||
trackerService = binder.service
|
|
||||||
trackerService.mapfragment = thismapfragment
|
trackerService.mapfragment = thismapfragment
|
||||||
// get state of tracking and update button if necessary
|
// get state of tracking and update button if necessary
|
||||||
trackingState = trackerService.trackingState
|
trackingState = trackerService.trackingState
|
||||||
|
|
|
@ -57,6 +57,7 @@ import net.voussoir.trkpt.helpers.isRecentEnough
|
||||||
import net.voussoir.trkpt.helpers.iso8601_local
|
import net.voussoir.trkpt.helpers.iso8601_local
|
||||||
import net.voussoir.trkpt.helpers.random_device_id
|
import net.voussoir.trkpt.helpers.random_device_id
|
||||||
import org.osmdroid.util.GeoPoint
|
import org.osmdroid.util.GeoPoint
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TrackerService: Service()
|
class TrackerService: Service()
|
||||||
|
@ -70,12 +71,12 @@ class TrackerService: Service()
|
||||||
var currentBestLocation: Location = getDefaultLocation()
|
var currentBestLocation: Location = getDefaultLocation()
|
||||||
var lastCommit: Long = 0
|
var lastCommit: Long = 0
|
||||||
var location_min_time_ms: Long = 0
|
var location_min_time_ms: Long = 0
|
||||||
private val RECENT_TRKPT_COUNT = 7200
|
private val RECENT_TRKPT_COUNT = 3600
|
||||||
private val DISPLACEMENT_LOCATION_COUNT = 5
|
private val DISPLACEMENT_LOCATION_COUNT = 5
|
||||||
lateinit var recent_displacement_locations: Deque<Location>
|
lateinit var recent_displacement_locations: Deque<Location>
|
||||||
lateinit var recent_trackpoints_for_mapview: MutableList<GeoPoint>
|
lateinit var recent_trackpoints_for_mapview: MutableList<GeoPoint>
|
||||||
var bound: Boolean = false
|
var bound: Boolean = false
|
||||||
private val binder = LocalBinder()
|
private val binder = TrackerServiceBinder(this)
|
||||||
|
|
||||||
private lateinit var notificationManager: NotificationManager
|
private lateinit var notificationManager: NotificationManager
|
||||||
private lateinit var notification_builder: NotificationCompat.Builder
|
private lateinit var notification_builder: NotificationCompat.Builder
|
||||||
|
@ -562,8 +563,8 @@ class TrackerService: Service()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
inner class LocalBinder : Binder() {
|
class TrackerServiceBinder(trackerservice: TrackerService) : Binder()
|
||||||
val service: TrackerService = this@TrackerService
|
{
|
||||||
}
|
val service: WeakReference<TrackerService> = WeakReference(trackerservice)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue