forked from organicmaps/organicmaps
[ios] Fixed ui hang on search.
This commit is contained in:
parent
0572c2100e
commit
5f41b82352
1 changed files with 10 additions and 11 deletions
|
@ -126,8 +126,6 @@ typedef NS_ENUM(NSUInteger, CellType)
|
|||
|
||||
@implementation SearchView
|
||||
|
||||
__weak SearchView * selfPointer;
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
|
@ -146,8 +144,6 @@ __weak SearchView * selfPointer;
|
|||
[self setState:SearchViewStateHidden animated:NO withCallback:NO];
|
||||
[self addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
|
||||
|
||||
selfPointer = self;
|
||||
|
||||
if ([self.tableView respondsToSelector:@selector(registerClass:forCellReuseIdentifier:)])
|
||||
{
|
||||
// only for iOS 6 and higher
|
||||
|
@ -317,7 +313,16 @@ static BOOL keyboardLoaded = NO;
|
|||
- (void)updateSearchParametersWithForce:(BOOL)force outParams:(search::SearchParams &)sp andQuery:(NSString *)newQuery
|
||||
{
|
||||
sp.m_query = [[newQuery precomposedStringWithCompatibilityMapping] UTF8String];
|
||||
sp.m_callback = bind(&onSearchResultCallback, _1);
|
||||
sp.m_callback = ^(search::Results const & results)
|
||||
{
|
||||
if (self.state == SearchViewStateHidden)
|
||||
return;
|
||||
SearchResultsWrapper * wrapper = [[SearchResultsWrapper alloc] initWithResults:results];
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self frameworkDidAddSearchResult:wrapper];
|
||||
});
|
||||
};
|
||||
sp.SetInputLocale([GetKeyboardInputLanguage() UTF8String]);
|
||||
sp.SetForceSearch(force == YES);
|
||||
}
|
||||
|
@ -334,12 +339,6 @@ static BOOL keyboardLoaded = NO;
|
|||
GetFramework().Search(sp);
|
||||
}
|
||||
|
||||
static void onSearchResultCallback(search::Results const & results)
|
||||
{
|
||||
SearchResultsWrapper * wrapper = [[SearchResultsWrapper alloc] initWithResults:results];
|
||||
[selfPointer performSelectorOnMainThread:@selector(frameworkDidAddSearchResult:) withObject:wrapper waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (void)frameworkDidAddSearchResult:(SearchResultsWrapper *)wrapper
|
||||
{
|
||||
// special buben for situation when textfield is empty and we should show categories (cause 'self.wrapper' == nil)
|
||||
|
|
Loading…
Add table
Reference in a new issue