Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #79 from thunsaker/bug/distance-wonkiness
Browse files Browse the repository at this point in the history
Fix distance display issues
  • Loading branch information
thunsaker committed Feb 18, 2016
2 parents b3fc592 + 190ad02 commit b18c1e1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"chalk"
],
"uuid": "1cceab0a-8dc1-4641-b7b6-5ea9c827dd66",
"versionLabel": "2.200",
"versionLabel": "2.210",
"watchapp": {
"watchface": false
}
Expand Down
7 changes: 2 additions & 5 deletions src/js/pebble-js-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,20 @@ function fetchClosestVenues(token, position) {
var distance = element.location.distance;
// TODO: Once configuration is in place
if(localStorage.spoon_unit === null || localStorage.spoon_unit === "0") {
// venueDistance = element.location.distance >= 1000 ? (element.location.distance/1000).toFixed(2) + " km - " : element.location.distance + " m - ";
venueDistanceUnit = distance >= 1000 ? 1 : 0;
venueDistance = distance >= 1000 ? (distance/1000).toFixed(2) : distance; // Distance in m
} else {
distance *= mToFeet; // Distance in Feet
// venueDistance = distance >= ftInMile ? (distance/ftInMile).toFixed(2) + " mi - " : distance.toFixed(0) + " ft - ";
venueDistanceUnit = distance >= ftInMile ? 3 : 2;
venueDistance = distance >= ftInMile ? (distance/ftInMile).toFixed(2) : distance.toFixed(0);
}
// venueAddress = venueDistance + venueAddress;
}

if(isNewList) {
appMessageQueue.push({'message': {'id':venueId, 'name':venueName, 'address':venueAddress, 'distance':venueDistance, 'unit':venueDistanceUnit, 'index':offsetIndex}});
appMessageQueue.push({'message': {'id':venueId, 'name':venueName, 'address':venueAddress, 'distance':venueDistance.toString(), 'unit':venueDistanceUnit, 'index':offsetIndex}});
isNewList = false;
} else {
appMessageQueue.push({'message': {'id':venueId, 'name':venueName, 'address':venueAddress, 'distance':venueDistance, 'unit':venueDistanceUnit, 'index':offsetIndex}});
appMessageQueue.push({'message': {'id':venueId, 'name':venueName, 'address':venueAddress, 'distance':venueDistance.toString(), 'unit':venueDistanceUnit, 'index':offsetIndex}});
}

// Send them in clusters of 5
Expand Down
10 changes: 5 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,14 @@ static int16_t menu_get_cell_height_callback(MenuLayer *menu_layer, MenuIndex *c
static void menu_draw_header_callback(GContext* ctx, const Layer *cell_layer, uint16_t section_index, void *data) { }

static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
char addressString[30];
snprintf(addressString, sizeof(addressString),
"%s %s - %s", venues[cell_index->row].distance, get_unit(venues[cell_index->row].distance_unit), venues[cell_index->row].address);
#ifdef PBL_PLATFORM_APLITE
if(cell_index->row == NUM_MENU_ITEMS - 1) {
menu_cell_basic_draw(ctx, cell_layer, _("Foursquare"), _("Powered"), image_cog);
} else {
menu_cell_basic_draw(ctx, cell_layer, venues[cell_index->row].name, venues[cell_index->row].address, NULL);
} else if(strlen(venues[cell_index->row].name) > 0) {
menu_cell_basic_draw(ctx, cell_layer, venues[cell_index->row].name, addressString, NULL);
}
#else
GRect bounds = layer_get_bounds(cell_layer);
Expand Down Expand Up @@ -665,9 +668,6 @@ static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuI
graphics_context_set_compositing_mode(ctx, GCompOpSet);
graphics_draw_bitmap_in_rect(ctx, image_cog, cog_bounds);
} else if (strlen(venues[cell_index->row].name) > 0) {
static char addressString[30];
snprintf(addressString, sizeof(addressString),
"%s %s - %s", venues[cell_index->row].distance, get_unit(venues[cell_index->row].distance_unit), venues[cell_index->row].address);
#ifdef PBL_ROUND
GSize text_size = graphics_text_layout_get_content_size(
venues[cell_index->row].name,
Expand Down

0 comments on commit b18c1e1

Please sign in to comment.