diff --git a/iphone/Maps/Classes/MapsAppDelegate.h b/iphone/Maps/Classes/MapsAppDelegate.h index 5f0df9b34b..38fc460250 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.h +++ b/iphone/Maps/Classes/MapsAppDelegate.h @@ -8,6 +8,7 @@ { SettingsManager * m_settingsManager; NSInteger m_standbyCounter; + NSInteger m_activeDownloadsCounter; } @property (nonatomic, retain) IBOutlet UIWindow * m_window; @@ -18,7 +19,11 @@ + (MapsAppDelegate *) theApp; - (SettingsManager *)settingsManager; + - (void)disableStandby; - (void)enableStandby; +- (void)disableDownloadIndicator; +- (void)enableDownloadIndicator; + @end diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 6bb4112197..819d618feb 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -64,8 +64,27 @@ - (void) enableStandby { --m_standbyCounter; - if (m_standbyCounter == 0) + if (m_standbyCounter <= 0) + { [UIApplication sharedApplication].idleTimerDisabled = NO; + m_standbyCounter = 0; + } +} + +- (void) disableDownloadIndicator +{ + --m_activeDownloadsCounter; + if (m_activeDownloadsCounter <= 0) + { + [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; + m_activeDownloadsCounter = 0; + } +} + +- (void) enableDownloadIndicator +{ + ++m_activeDownloadsCounter; + [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; } - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application diff --git a/platform/http_thread_apple.mm b/platform/http_thread_apple.mm index fabe9d655f..79a430bd12 100644 --- a/platform/http_thread_apple.mm +++ b/platform/http_thread_apple.mm @@ -5,6 +5,10 @@ #include "../base/logging.hpp" +#ifdef OMIM_OS_IPHONE + #include "../iphone/Maps/Classes/MapsAppDelegate.h" +#endif + #define TIMEOUT_IN_SECONDS 15.0 @implementation HttpThread @@ -14,6 +18,10 @@ LOG(LDEBUG, ("ID:", [self hash], "Connection is destroyed")); [m_connection cancel]; [m_connection release]; +#ifdef OMIM_OS_IPHONE + [[MapsAppDelegate theApp] enableStandby]; + [[MapsAppDelegate theApp] disableDownloadIndicator]; +#endif [super dealloc]; } @@ -69,6 +77,11 @@ [request addValue:[NSString stringWithUTF8String: uid.c_str()] forHTTPHeaderField:@"User-Agent"]; } +#ifdef OMIM_OS_IPHONE + [[MapsAppDelegate theApp] disableStandby]; + [[MapsAppDelegate theApp] enableDownloadIndicator]; +#endif + // create the connection with the request and start loading the data m_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];