forked from organicmaps/organicmaps-tmp
[ios] Removed redundant storage observer.
This commit is contained in:
parent
e7e181d46a
commit
3593f5126e
3 changed files with 37 additions and 14 deletions
|
@ -37,12 +37,11 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
|
|||
@property (nonatomic) MWMSearchTableViewController * tableViewController;
|
||||
@property (nonatomic) MWMSearchDownloadViewController * downloadController;
|
||||
|
||||
@property (nonatomic) BOOL haveDownloadedMaps;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMSearchManager
|
||||
{
|
||||
int m_mapsObserverSlotId;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithParentView:(nonnull UIView *)view
|
||||
delegate:(nonnull id<MWMSearchManagerProtocol, MWMSearchViewProtocol, MWMRoutingProtocol>)delegate
|
||||
|
@ -55,7 +54,6 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
|
|||
self.rootView.delegate = delegate;
|
||||
self.parentView = view;
|
||||
self.state = MWMSearchManagerStateHidden;
|
||||
[MWMFrameworkListener addObserver:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -267,6 +265,11 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
|
|||
|
||||
- (void)changeToDefaultState
|
||||
{
|
||||
using namespace storage;
|
||||
auto const & s = GetFramework().Storage();
|
||||
TCountriesVec downloadedCountries, availCountries;
|
||||
s.GetChildrenInGroups(s.GetRootId(), downloadedCountries, availCountries);
|
||||
self.haveDownloadedMaps = !downloadedCountries.empty();
|
||||
self.view.alpha = 1.;
|
||||
[self updateTopController];
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
|
@ -314,19 +317,25 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
|
|||
|
||||
- (UIViewController *)topController
|
||||
{
|
||||
using namespace storage;
|
||||
auto & s = GetFramework().Storage();
|
||||
TCountriesVec downloadedCountries, availCountries;
|
||||
s.GetChildrenInGroups(s.GetRootId(), downloadedCountries, availCountries);
|
||||
BOOL const haveMap = (downloadedCountries.size() != 0);
|
||||
return haveMap ? self.tabbedController : self.downloadController;
|
||||
if (self.haveDownloadedMaps || self.state == MWMSearchManagerStateHidden)
|
||||
{
|
||||
return self.tabbedController;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!self.downloadController)
|
||||
self.downloadController = [[MWMSearchDownloadViewController alloc] initWithDelegate:self];
|
||||
return self.downloadController;
|
||||
}
|
||||
}
|
||||
|
||||
- (MWMSearchDownloadViewController *)downloadController
|
||||
- (void)setDownloadController:(MWMSearchDownloadViewController *)downloadController
|
||||
{
|
||||
if (!_downloadController)
|
||||
_downloadController = [[MWMSearchDownloadViewController alloc] initWithDelegate:self];
|
||||
return _downloadController;
|
||||
_downloadController = downloadController;
|
||||
if (downloadController)
|
||||
[MWMFrameworkListener addObserver:self];
|
||||
else
|
||||
[MWMFrameworkListener removeObserver:self];
|
||||
}
|
||||
|
||||
- (MWMSearchTabbedViewController *)tabbedController
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
+ (MWMFrameworkListener *)listener;
|
||||
+ (void)addObserver:(id<MWMFrameworkObserver>)observer;
|
||||
+ (void)removeObserver:(id<MWMFrameworkObserver>)observer;
|
||||
|
||||
@property (nonatomic, readonly) location::EMyPositionMode myPositionMode;
|
||||
@property (nonatomic) UserMark const * userMark;
|
||||
|
|
|
@ -81,6 +81,19 @@ void loopWrappers(TObservers * observers, TLoopBlock block)
|
|||
});
|
||||
}
|
||||
|
||||
+ (void)removeObserver:(TObserver)observer
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
MWMFrameworkListener * listener = [MWMFrameworkListener listener];
|
||||
[listener.routeBuildingObservers removeObject:observer];
|
||||
[listener.myPositionObservers removeObject:observer];
|
||||
[listener.userMarkObservers removeObject:observer];
|
||||
[listener.storageObservers removeObject:observer];
|
||||
[listener.drapeObservers removeObject:observer];
|
||||
});
|
||||
}
|
||||
|
||||
- (instancetype)initListener
|
||||
{
|
||||
self = [super init];
|
||||
|
|
Loading…
Add table
Reference in a new issue