Search Screen. Check if location is valid in "near me" screen, if not tell about it to user.

Search Screen. Check if location is valid in "near me" screen, if not tell about it to user.
This commit is contained in:
Kirill Zhdanovich 2013-03-26 11:43:28 +03:00 committed by Alex Zolotarev
parent 105c34e4a2
commit 55b4389716
3 changed files with 14 additions and 6 deletions

View file

@ -363,7 +363,7 @@ static void OnSearchResultCallback(search::Results const & res)
static NSString *CellIdentifier = @"categoryCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
if (!cell)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
@ -377,12 +377,18 @@ static void OnSearchResultCallback(search::Results const & res)
if ([m_searchBar.text length] != 0 && ![[_searchResults objectAtIndex:scopeSection] getCount] && numberOfRowsInEmptySearch)
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"NoResultsCell"];
if (cell == nil)
if (!cell)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"NoResultsCell"] autorelease];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
cell.textLabel.text = NSLocalizedString(@"no_search_results_found", nil);
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"NoResultsCell"] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = NSLocalizedString(@"no_search_results_found", nil);
// check if we have no position in "near me" screen
if (![m_locationManager lastLocationIsValid] && scopeSection == 0)
cell.detailTextLabel.text = NSLocalizedString(@"unknown_current_position", nil);
else
cell.detailTextLabel.text = @"";
return cell;
}

View file

@ -35,4 +35,6 @@
- (bool)getNorthRad:(double &)rad;
+ (NSString *)formatDistance:(double)meters;
- (bool)lastLocationIsValid;
@end

View file

@ -245,7 +245,7 @@
return [NSString stringWithUTF8String:s.c_str()];
}
-(bool)lastLocationIsValid
- (bool)lastLocationIsValid
{
return (([self lastLocation] != nil) && ([m_lastLocationTime timeIntervalSinceNow] > -300.0));
}