[ios] update speed in PPP when my position choosed

This commit is contained in:
ExMix 2014-06-30 15:33:17 +03:00 committed by Alex Zolotarev
parent bb0fc813c8
commit 80c78be400
3 changed files with 16 additions and 5 deletions

View file

@ -22,6 +22,9 @@ typedef NS_ENUM(NSUInteger, CellRow)
};
@interface PlacePageView () <UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate, LocationObserver, PlacePageShareCellDelegate, PlacePageInfoCellDelegate, ColorPickerDelegate, UIAlertViewDelegate>
{
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];

View file

@ -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;

View file

@ -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);