From 80c78be400b515ee6a9eccd950dc9454fc78bec0 Mon Sep 17 00:00:00 2001 From: ExMix Date: Mon, 30 Jun 2014 15:33:17 +0300 Subject: [PATCH] [ios] update speed in PPP when my position choosed --- iphone/Maps/Classes/PlacePageView.mm | 15 ++++++++++++--- iphone/Maps/Platform/LocationManager.h | 2 +- iphone/Maps/Platform/LocationManager.mm | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/iphone/Maps/Classes/PlacePageView.mm b/iphone/Maps/Classes/PlacePageView.mm index 490ce3219f..23f472df28 100644 --- a/iphone/Maps/Classes/PlacePageView.mm +++ b/iphone/Maps/Classes/PlacePageView.mm @@ -22,6 +22,9 @@ typedef NS_ENUM(NSUInteger, CellRow) }; @interface PlacePageView () +{ + BOOL m_hasSpeed; +} @property (nonatomic) UIView * backgroundView; @property (nonatomic) UIView * headerView; @@ -127,7 +130,13 @@ typedef NS_ENUM(NSUInteger, CellRow) if ([self isMarkOfType:UserMark::MY_POSITION]) { - self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude]; + BOOL hasSpeed = NO; + self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude:hasSpeed]; + if (hasSpeed != m_hasSpeed) + { + m_hasSpeed = hasSpeed; + [self reloadHeader]; + } if (self.state == PlacePageStateOpened) [cell updateCoordinates]; } @@ -238,7 +247,7 @@ typedef NS_ENUM(NSUInteger, CellRow) self.titleLabel.origin = CGPointMake(23, 29); if ([self isMarkOfType:UserMark::MY_POSITION]) - self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude]; + self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude:m_hasSpeed]; else self.typeLabel.text = self.types; self.typeLabel.width = [self typesWidth]; @@ -286,7 +295,7 @@ typedef NS_ENUM(NSUInteger, CellRow) [self alignAnimated:animated]; self.tableView.contentInset = UIEdgeInsetsMake([self headerHeight], 0, 0, 0); [self.tableView setContentOffset:CGPointMake(0, -self.tableView.contentInset.top) animated:animated]; - if (state == PlacePageStateOpened) + if (state != PlacePageStateHidden) { if ([[MapsAppDelegate theApp].m_locationManager enabledOnMap]) [[MapsAppDelegate theApp].m_locationManager start:self]; diff --git a/iphone/Maps/Platform/LocationManager.h b/iphone/Maps/Platform/LocationManager.h index 056fc3f198..77b452d411 100644 --- a/iphone/Maps/Platform/LocationManager.h +++ b/iphone/Maps/Platform/LocationManager.h @@ -36,7 +36,7 @@ + (NSString *)formattedDistance:(double)meters; // Returns nil if neither speed nor altitude are available -- (NSString *)formattedSpeedAndAltitude; +- (NSString *)formattedSpeedAndAltitude:(BOOL &)hasSpeed; - (bool)lastLocationIsValid; - (BOOL)enabledOnMap; diff --git a/iphone/Maps/Platform/LocationManager.mm b/iphone/Maps/Platform/LocationManager.mm index 0a6bd915eb..df924770c9 100644 --- a/iphone/Maps/Platform/LocationManager.mm +++ b/iphone/Maps/Platform/LocationManager.mm @@ -250,8 +250,9 @@ else return rocket; } -- (NSString *)formattedSpeedAndAltitude +- (NSString *)formattedSpeedAndAltitude:(BOOL &)hasSpeed { + hasSpeed = NO; CLLocation * l = [self lastLocation]; if (l) { @@ -261,6 +262,7 @@ // Speed is actual only for just received location if (l.speed > 0. && [l.timestamp timeIntervalSinceNow] >= -2.0) { + hasSpeed = YES; if (!result.empty()) result += " "; result += [LocationManager getSpeedSymbol:l.speed] + MeasurementUtils::FormatSpeed(l.speed);