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

MapsAppDelegate.mm « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c32d364adf0e4442d4585a07fc89595633d6eac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "GuideViewController.h"
#import "SettingsManager.h"
#import "../../Sloynik/Shared/global.hpp"

@implementation MapsAppDelegate

@synthesize window;
@synthesize mapViewController;

+ (MapsAppDelegate *) theApp
{
  return [[UIApplication sharedApplication] delegate];
}

// here we're
- (void) applicationWillTerminate: (UIApplication *) application
{
	[mapViewController OnTerminate];
}

- (void) applicationDidEnterBackground: (UIApplication *) application
{
	[mapViewController OnEnterBackground];
}

- (void) applicationWillEnterForeground: (UIApplication *) application
{
  [mapViewController OnEnterForeground];
}

- (void) onSloynikEngineInitialized: (void *) pEngine
{
  SetSloynikEngine(static_cast<sl::SloynikEngine *>(pEngine));
  if (m_guideViewController)
    [m_guideViewController OnSloynikEngineInitialized];
}

- (void) applicationDidFinishLaunching: (UIApplication *) application
{
  // Initialize Sloynik engine.
  // It takes long for the first time, so we do it while startup image is visible.
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
    sl::SloynikEngine * pEngine = CreateSloynikEngine();
    dispatch_async(dispatch_get_main_queue(), ^{
      [[MapsAppDelegate theApp] onSloynikEngineInitialized:pEngine];
    });
  });


  // Add the tab bar controller's current view as a subview of the window
  [window addSubview:mapViewController.view];
  [window makeKeyAndVisible];
}

- (GuideViewController *)guideViewController
{
  if (!m_guideViewController)
  {
    m_guideViewController = [GuideViewController alloc];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
      m_guideViewController = [m_guideViewController initWithNibName:@"GuideView-iPad" bundle:nil];
    else
      m_guideViewController = [m_guideViewController initWithNibName:@"GuideView" bundle:nil];
  }
  return m_guideViewController;
}

- (SettingsManager *)settingsManager
{
  if (!m_settingsManager)
    m_settingsManager = [[SettingsManager alloc] init];
  return m_settingsManager;
}

- (void) dealloc
{
  [m_guideViewController release];
  [m_settingsManager release];
  mapViewController = nil;
  window = nil;
  [super dealloc];
}

- (void) disableStandby
{
  ++m_standbyCounter;
  [UIApplication sharedApplication].idleTimerDisabled = YES;
}

- (void) enableStandby
{
  --m_standbyCounter;
  if (m_standbyCounter == 0)
    [UIApplication sharedApplication].idleTimerDisabled = NO;
}

@end