Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2023-07-11 15:48:57 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dcf414db31c87d86926446bd5b72853bcb07d0e1
dcf414db
1 parent
50376aa3
telematics fix
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelematicsActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/TelematicsActivity.java
View file @
dcf414d
...
...
@@ -256,7 +256,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
//TODO: comment the first block and uncomment the second block if needs revert to handler implementation
if
(
mLatitude
!=
0
&&
mLongitude
!=
0
)
{
mSpeed
=
calculateSpeed
(
mLatitude
,
mLongitude
,
location
.
getLatitude
(),
location
.
getLongitude
(),
(
LOCATION_UPDATE_INTERVAL
/
1000
));
mTvAvgVelocity
.
setText
(
String
.
format
(
"%.1f"
,
Math
.
floor
(
mSpeed
))
+
"
m/s^2
"
);
mTvAvgVelocity
.
setText
(
String
.
format
(
"%.1f"
,
Math
.
floor
(
mSpeed
))
+
"
km/h
"
);
}
...
...
@@ -321,7 +321,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
private
void
initViews
()
{
mTvVelocity
.
setText
(
"0.0 m/s^2"
);
mTvAvgVelocity
.
setText
(
"0.0
m/s^2
"
);
mTvAvgVelocity
.
setText
(
"0.0
km/h
"
);
}
private
void
requestLocationUpdates
()
{
...
...
@@ -352,7 +352,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
@Override
public
void
run
()
{
double
speed
=
calculateSpeed
(
mLatitude
,
mLongitude
,
location
.
getLatitude
(),
location
.
getLongitude
(),
(
LOCATION_UPDATE_INTERVAL
/
1000
));
mTvAvgVelocity
.
setText
(
String
.
format
(
"%.1f"
,
Math
.
floor
(
speed
))
+
"
m/s^2
"
);
mTvAvgVelocity
.
setText
(
String
.
format
(
"%.1f"
,
Math
.
floor
(
speed
))
+
"
km/h
"
);
mLocationHandler
.
postDelayed
(
this
,
LOCATION_UPDATE_INTERVAL
);
}
};
...
...
@@ -368,8 +368,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
// Function to calculate speed in meters per second
private
double
calculateSpeed
(
double
lat1
,
double
lon1
,
double
lat2
,
double
lon2
,
double
timeDifferenceInSeconds
)
{
double
distance
=
calculateDistance
(
lat1
,
lon1
,
lat2
,
lon2
);
// return (distance / timeDifferenceInSeconds) * 3.6f; // Convert to km/h;
return
(
distance
/
timeDifferenceInSeconds
);
// Convert to km/h;
return
(
distance
/
timeDifferenceInSeconds
)
*
3.6f
;
// Convert to km/h;
}
private
void
requestSingleLocationUpdate
()
{
...
...
@@ -446,7 +445,7 @@ public class TelematicsActivity extends Activity implements View.OnClickListener
touchCount
=
0
;
mSensorManager
.
unregisterListener
(
this
);
mTvVelocity
.
setText
(
"0.0 m/s^2"
);
mTvAvgVelocity
.
setText
(
"0.0
m/s^2
"
);
mTvAvgVelocity
.
setText
(
"0.0
km/h
"
);
Snackbar
.
make
(
mLlTelematicsMain
,
"Sensor Unregistered"
,
Snackbar
.
LENGTH_SHORT
).
show
();
if
(
mHandler
!=
null
)
mHandler
.
removeCallbacks
(
mRunnable
);
...
...
Please
register
or
login
to post a comment