Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Grechuhin <i.grechuhin@mapswithme.com>2015-06-19 17:34:46 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:52:42 +0300
commitcd19027e52420cffea81ac9443416e2f79977b88 (patch)
treeff29fb6430fcf51e918c60642e540b5198fd8be9 /iphone/Maps/Classes/MWMPlacePageViewManager.mm
parentff0e67ed870e8f998f6af228d37f6977f5525ffb (diff)
[ios] Fixed initial distance delay.
Diffstat (limited to 'iphone/Maps/Classes/MWMPlacePageViewManager.mm')
-rw-r--r--iphone/Maps/Classes/MWMPlacePageViewManager.mm58
1 files changed, 31 insertions, 27 deletions
diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.mm b/iphone/Maps/Classes/MWMPlacePageViewManager.mm
index c0aaeab7bb..273ece8208 100644
--- a/iphone/Maps/Classes/MWMPlacePageViewManager.mm
+++ b/iphone/Maps/Classes/MWMPlacePageViewManager.mm
@@ -75,9 +75,10 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
self.entity = [[MWMPlacePageEntity alloc] initWithUserMark:m_userMark->GetUserMark()];
self.state = MWMPlacePageManagerStateOpen;
if (IPAD)
- [self presentPlacePageForiPad];
+ [self setPlacePageForiPad];
else
- [self presentPlacePageForiPhoneWithOrientation:self.ownerViewController.interfaceOrientation];
+ [self setPlacePageForiPhoneWithOrientation:self.ownerViewController.interfaceOrientation];
+ [self configPlacePage];
}
- (void)layoutPlacePageToOrientation:(UIInterfaceOrientation)orientation
@@ -86,18 +87,24 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
return;
[self.placePage dismiss];
- [self presentPlacePageForiPhoneWithOrientation:orientation];
+ [self setPlacePageForiPhoneWithOrientation:orientation];
+ [self configPlacePage];
}
-- (void)presentPlacePageForiPad
+- (void)configPlacePage
{
- [self.placePage dismiss];
- self.placePage = [[MWMiPadPlacePage alloc] initWithManager:self];
[self.placePage configure];
[self.placePage show];
+ [self updateDistance];
}
-- (void)presentPlacePageForiPhoneWithOrientation:(UIInterfaceOrientation)orientation
+- (void)setPlacePageForiPad
+{
+ [self.placePage dismiss];
+ self.placePage = [[MWMiPadPlacePage alloc] initWithManager:self];
+}
+
+- (void)setPlacePageForiPhoneWithOrientation:(UIInterfaceOrientation)orientation
{
if (self.state == MWMPlacePageManagerStateClosed)
return;
@@ -108,20 +115,14 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
case UIInterfaceOrientationLandscapeRight:
if (![self.placePage isKindOfClass:[MWMiPhoneLandscapePlacePage class]])
self.placePage = [[MWMiPhoneLandscapePlacePage alloc] initWithManager:self];
-
- [self.placePage configure];
- [self.placePage show];
break;
-
+
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
if (![self.placePage isKindOfClass:[MWMiPhonePortraitPlacePage class]])
self.placePage = [[MWMiPhonePortraitPlacePage alloc] initWithManager:self];
-
- [self.placePage configure];
- [self.placePage show];
break;
-
+
case UIInterfaceOrientationUnknown:
break;
}
@@ -202,37 +203,39 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
- (void)onLocationUpdate:(location::GpsInfo const &)info
{
- if (!m_userMark)
- return;
+ [self updateDistance];
+}
+
+- (void)updateDistance
+{
NSString * distance = [self distance];
self.directionView.distanceLabel.text = distance;
[self.placePage setDistance:distance];
}
+
- (NSString *)distance
{
- CLLocation const * location = [MapsAppDelegate theApp].m_locationManager.lastLocation;
- if (!location)
+ CLLocation * location = [MapsAppDelegate theApp].m_locationManager.lastLocation;
+ if (!location || !m_userMark)
return @"";
double azimut = -1;
double north = -1;
[[MapsAppDelegate theApp].m_locationManager getNorthRad:north];
string distance;
- GetFramework().GetDistanceAndAzimut(m_userMark->GetUserMark()->GetOrg(), location.coordinate.latitude, location.coordinate.longitude, north, distance, azimut);
+ CLLocationCoordinate2D const coord = location.coordinate;
+ GetFramework().GetDistanceAndAzimut(m_userMark->GetUserMark()->GetOrg(), coord.latitude, coord.longitude, north, distance, azimut);
return [NSString stringWithUTF8String:distance.c_str()];
}
- (void)onCompassUpdate:(location::CompassInfo const &)info
{
- if (!m_userMark)
+ CLLocation * location = [MapsAppDelegate theApp].m_locationManager.lastLocation;
+ if (!location || !m_userMark)
return;
- double lat, lon;
-
- if (![[MapsAppDelegate theApp].m_locationManager getLat:lat Lon:lon])
- return;
-
- CGFloat angle = ang::AngleTo(MercatorBounds::FromLatLon(lat, lon), m_userMark->GetUserMark()->GetOrg()) + info.m_bearing;
+ CLLocationCoordinate2D const coord = location.coordinate;
+ CGFloat angle = ang::AngleTo(MercatorBounds::FromLatLon(coord.latitude, coord.longitude), m_userMark->GetUserMark()->GetOrg()) + info.m_bearing;
CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_2 - angle);
[self.placePage setDirectionArrowTransform:transform];
[self.directionView setDirectionArrowTransform:transform];
@@ -243,6 +246,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
self.directionView = [MWMDirectionView directionViewForViewController:self.ownerViewController];
self.directionView.titleLabel.text = title;
self.directionView.typeLabel.text = type;
+ [self updateDistance];
}
@end