Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
Updates sample app to display speed
Browse files Browse the repository at this point in the history
  • Loading branch information
ecgreb committed Sep 30, 2014
1 parent 8cc43ea commit 2781183
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lost-sample/res/layout/list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/speed"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/time"
android:layout_width="match_parent"
Expand Down
4 changes: 4 additions & 0 deletions lost-sample/src/main/java/com/example/lost/LostActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,28 @@ public static void populateLocationView(View view, Location location) {
final TextView provider = (TextView) view.findViewById(R.id.provider);
final TextView coordinates = (TextView) view.findViewById(R.id.coordinates);
final TextView accuracy = (TextView) view.findViewById(R.id.accuracy);
final TextView speed = (TextView) view.findViewById(R.id.speed);
final TextView time = (TextView) view.findViewById(R.id.time);

provider.setText(location.getProvider() + " provider");
coordinates.setText(String.format("%.4f, %.4f", location.getLatitude(),
location.getLongitude()));
accuracy.setText("within " + Math.round(location.getAccuracy()) + " meters");
speed.setText(location.getSpeed() + " m/s");
time.setText(new Date(location.getTime()).toString());
}

public static void clearLocationView(View view) {
final TextView provider = (TextView) view.findViewById(R.id.provider);
final TextView coordinates = (TextView) view.findViewById(R.id.coordinates);
final TextView accuracy = (TextView) view.findViewById(R.id.accuracy);
final TextView speed = (TextView) view.findViewById(R.id.speed);
final TextView time = (TextView) view.findViewById(R.id.time);

provider.setText("");
coordinates.setText("");
accuracy.setText("");
speed.setText("");
time.setText("");
}

Expand Down

0 comments on commit 2781183

Please sign in to comment.