Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
2f32efdc
Commit
2f32efdc
authored
Apr 13, 2016
by
Björn Richerzhagen
Browse files
LocationUpdates: only trigger onLocationChanged, if the location
actually changed.
parent
29ba1deb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/DefaultTopologyComponent.java
View file @
2f32efdc
...
...
@@ -319,6 +319,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
private
long
interval
=
1
*
Simulator
.
MINUTE_UNIT
;
private
int
priority
=
LocationRequest
.
PRIORITY_BALANCED_POWER_ACCURACY
;
private
Location
lastLocation
=
null
;
private
List
<
LocationListener
>
listeners
=
new
LinkedList
<
LocationListener
>();
...
...
@@ -359,7 +361,11 @@ public class DefaultTopologyComponent implements TopologyComponent {
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(!
listeners
.
isEmpty
())
{
// Only reschedule, if at least one listener is ... listening
listeners
.
forEach
((
LocationListener
listener
)
->
listener
.
onLocationChanged
(
getLastLocation
()));
Location
newLoc
=
getLastLocation
();
if
(
lastLocation
==
null
||
lastLocation
.
distanceTo
(
newLoc
)
>
0
)
{
listeners
.
forEach
((
LocationListener
listener
)
->
listener
.
onLocationChanged
(
newLoc
));
lastLocation
=
newLoc
;
}
Event
.
scheduleWithDelay
(
interval
,
this
,
null
,
0
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment