Skip to content

Commit

Permalink
Colored dots make more sense. And update properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthaus Litteken committed Aug 13, 2010
1 parent 7306e0e commit 9eb5b85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PlaceMarkCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@property (nonatomic, retain) UILabel *placeMarkNameLabel;
@property (nonatomic, retain) UIImageView *placeMarkDistanceImageView;

- (UIImage *)imageForDistance:(double) distance;
- (UIImage *)imageForDistance:(double) distance:(NSInteger *) thresh;

- (PlaceMark *)placemark;
- (void)setPlaceMark:(PlaceMark *)newPlaceMark;
Expand Down
11 changes: 6 additions & 5 deletions PlaceMarkCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (void)setPlaceMark:(PlaceMark *)newPlaceMark {
placemark = newPlaceMark;

self.placeMarkNameLabel.text = newPlaceMark.pmName;
self.placeMarkDistanceImageView.image = [self imageForDistance:newPlaceMark.distance];
self.placeMarkDistanceImageView.image = [self imageForDistance:newPlaceMark.distance:newPlaceMark.threshold];
self.placeMarkDistanceLabel.text =
(newPlaceMark.distance == -1.0 ? @"Loading..." : [NSString stringWithFormat:@"%.1f", newPlaceMark.distance]);

Expand Down Expand Up @@ -184,12 +184,13 @@ - (UILabel *)newLabelWithPrimaryColor:(UIColor *)primaryColor
return newLabel;
}

- (UIImage *)imageForDistance:(double) distance {
if (distance < 50) {
- (UIImage *)imageForDistance:(double) distance:(NSInteger *) thresh {
double threshold = [[[NSNumber alloc] initWithInt: thresh] doubleValue];
if ((distance / threshold) < 2) {
return distance3Image;
} else if (distance < 100) {
} else if ((distance / threshold) < 5) {
return distance2Image;
} else if (distance <= 250) {
} else if ((distance / threshold) > 5) {
return distance1Image;
} else {
return nil;
Expand Down

0 comments on commit 9eb5b85

Please sign in to comment.