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

GuideViewController.mm « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 36ce9620b1896241478605b1e2a985ada67bba8b (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//
//  GuideViewController.mm
//  Maps
//
//  Created by Yury Melnichek on 15.03.11.
//  Copyright 2011 MapsWithMe. All rights reserved.
//

#import "GuideViewController.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "ArticleVC.h"
#include "global.hpp"

@implementation GuideViewController

@synthesize activityIndicator;
@synthesize loadingLabel;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
      // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (IBAction)OnMapClicked:(id)sender
{
  UISegmentedControl * pSegmentedControl = (UISegmentedControl *)sender;
  int const selectedIndex = pSegmentedControl.selectedSegmentIndex;

  if (selectedIndex != 1)
  {
    LOG(LINFO, (selectedIndex));
    [UIView transitionFromView:self.view
                        toView:[MapsAppDelegate theApp].mapViewController.view
                      duration:0
                       options:UIViewAnimationOptionTransitionNone
                    completion:nil];
    [pSegmentedControl setSelectedSegmentIndex:1];
  }
}

- (void)onEmptySearch
{
  // Do nothing. Don't hide the results view.
}

- (void)willShowArticleVC:(ArticleVC *) viewController
{
  [super willShowArticleVC:viewController];
  viewController.articleFormat = @
  "<html>"
  "  <head>"
  "    <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>"
  "    <meta name='viewport' content='width=device-width; initial-scale=1.0; "
  "                                   maximum-scale=1.0; user-scalable=0;'/>"
  "    <style type='text/css'>"
  "      img, object { border:none; max-width:280px; height:auto; }"
  "      div { clear:both; }"
  "      div.thumbcaption div.magnify { display:none; }"
  "      div.thumbinner { padding:6px; margin:6px 0 0 0; border:1px solid #777;"
  "                       -webkit-border-radius:6px;"
  "                       font-size:12px; display:table; }"
  "      div#content h2 button { display:none; }"
  "    </style>"
  "  </head>"
  "  <body style='-webkit-text-size-adjust:%d%%'>"
  "    %@"
  "  </body>"
  "</html>";
}

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view from its nib.
  if (!GetSloynikEngine())
  {
    CGRect frame = self.view.frame;
    self.activityIndicator = [[[UIActivityIndicatorView alloc]
                               initWithFrame:CGRectMake(frame.origin.x + frame.size.width / 2 - 15,
                                                        80, 30, 30)] autorelease];
    
    [self.activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
    [self.view addSubview:self.activityIndicator];
    
    self.loadingLabel = [[[UILabel alloc]
                          initWithFrame:CGRectMake(frame.origin.x + frame.size.width / 2 - 30,
                                                   110, 60, 30)] autorelease];
    self.loadingLabel.text = @"Indexing...";
    self.loadingLabel.textAlignment = UITextAlignmentCenter;
    self.loadingLabel.userInteractionEnabled = NO;
    self.loadingLabel.numberOfLines = 1;
    self.loadingLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
    self.loadingLabel.adjustsFontSizeToFitWidth = YES;
    [self.view addSubview:self.loadingLabel];

    self.searchBar.hidden = YES;
    self.resultsView.hidden = YES;

    [self.activityIndicator startAnimating];
  }
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

- (void)OnSloynikEngineInitialized
{
  if (self.activityIndicator)
  {
    [self.activityIndicator removeFromSuperview];
    [self.loadingLabel removeFromSuperview];
    self.activityIndicator = nil;
    self.searchBar.hidden = NO;
    self.resultsView.hidden = NO;
    [self.resultsView reloadData];
  }  
}

@end