forked from organicmaps/organicmaps-tmp
[ios] Fixed download from search.
This commit is contained in:
parent
ef70e80047
commit
da41c662ba
6 changed files with 33 additions and 38 deletions
|
@ -24,7 +24,7 @@ typedef NS_ENUM(NSUInteger, MWMDownloadMapRequestState)
|
|||
|
||||
- (void)showRequest;
|
||||
|
||||
- (void)downloadProgress:(CGFloat)progress countryName:(nonnull NSString *)countryName;
|
||||
- (void)downloadProgress:(CGFloat)progress;
|
||||
- (void)setDownloadFailed;
|
||||
|
||||
@end
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#import "MWMCircularProgress.h"
|
||||
#import "MWMDownloadMapRequest.h"
|
||||
#import "MWMDownloadMapRequestView.h"
|
||||
#import "MWMMapDownloadDialog.h"
|
||||
#import "MWMStorage.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
|
@ -40,25 +41,12 @@
|
|||
{
|
||||
[[NSBundle mainBundle] loadNibNamed:self.class.className owner:self options:nil];
|
||||
[parentView addSubview:self.rootView];
|
||||
[self setupProgressView];
|
||||
self.delegate = delegate;
|
||||
[self showRequest];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setupProgressView
|
||||
{
|
||||
self.progressView = [[MWMCircularProgress alloc] initWithParentView:self.progressViewWrapper];
|
||||
self.progressView.delegate = self;
|
||||
[self.progressView setImage:[UIImage imageNamed:@"ic_download"] forState:MWMCircularProgressStateNormal];
|
||||
[self.progressView setImage:[UIImage imageNamed:@"ic_download"] forState:MWMCircularProgressStateSelected];
|
||||
[self.progressView setImage:[UIImage imageNamed:@"ic_close_spinner"] forState:MWMCircularProgressStateProgress];
|
||||
[self.progressView setImage:[UIImage imageNamed:@"ic_close_spinner"] forState:MWMCircularProgressStateSpinner];
|
||||
[self.progressView setImage:[UIImage imageNamed:@"ic_download_error"] forState:MWMCircularProgressStateFailed];
|
||||
[self.progressView setImage:[UIImage imageNamed:@"ic_check"] forState:MWMCircularProgressStateCompleted];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self.rootView removeFromSuperview];
|
||||
|
@ -71,7 +59,6 @@
|
|||
if (s.IsDownloadInProgress())
|
||||
{
|
||||
m_countryId = s.GetCurrentDownloadingCountryId();
|
||||
self.progressView.state = MWMCircularProgressStateProgress;
|
||||
[self updateState:MWMDownloadMapRequestStateDownload];
|
||||
}
|
||||
else
|
||||
|
@ -103,11 +90,10 @@
|
|||
|
||||
#pragma mark - Process control
|
||||
|
||||
- (void)downloadProgress:(CGFloat)progress countryName:(nonnull NSString *)countryName
|
||||
- (void)downloadProgress:(CGFloat)progress
|
||||
{
|
||||
self.progressView.progress = progress;
|
||||
[self showRequest];
|
||||
self.mapTitleLabel.text = countryName;
|
||||
self.progressView.progress = progress;
|
||||
}
|
||||
|
||||
- (void)setDownloadFailed
|
||||
|
@ -134,6 +120,7 @@
|
|||
else
|
||||
{
|
||||
[Statistics logEvent:kStatDownloaderDownloadCancel withParameters:@{kStatFrom : kStatSearch}];
|
||||
[MWMMapDownloadDialog pauseAutoDownload:YES];
|
||||
[MWMStorage cancelDownloadNode:m_countryId];
|
||||
}
|
||||
[self showRequest];
|
||||
|
@ -169,4 +156,20 @@
|
|||
[self.delegate stateUpdated:state];
|
||||
}
|
||||
|
||||
- (MWMCircularProgress *)progressView
|
||||
{
|
||||
if (!_progressView)
|
||||
{
|
||||
_progressView = [[MWMCircularProgress alloc] initWithParentView:self.progressViewWrapper];
|
||||
_progressView.delegate = self;
|
||||
[_progressView setImage:[UIImage imageNamed:@"ic_download"] forState:MWMCircularProgressStateNormal];
|
||||
[_progressView setImage:[UIImage imageNamed:@"ic_download"] forState:MWMCircularProgressStateSelected];
|
||||
[_progressView setImage:[UIImage imageNamed:@"ic_close_spinner"] forState:MWMCircularProgressStateProgress];
|
||||
[_progressView setImage:[UIImage imageNamed:@"ic_close_spinner"] forState:MWMCircularProgressStateSpinner];
|
||||
[_progressView setImage:[UIImage imageNamed:@"ic_download_error"] forState:MWMCircularProgressStateFailed];
|
||||
[_progressView setImage:[UIImage imageNamed:@"ic_check"] forState:MWMCircularProgressStateCompleted];
|
||||
}
|
||||
return _progressView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -29,17 +29,6 @@
|
|||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Axo-F2-0Xb" userLabel="ProgressViewWrapper">
|
||||
<rect key="frame" x="144" y="45" width="32" height="32"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="32" id="CcH-aB-wPy"/>
|
||||
<constraint firstAttribute="height" constant="32" id="j9b-F2-Mcs"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ANW-J1-K9x">
|
||||
<rect key="frame" x="40" y="31" width="240" height="44"/>
|
||||
<color key="backgroundColor" red="0.11764705882352941" green="0.58823529411764708" blue="0.94117647058823528" alpha="1" colorSpace="calibratedRGB"/>
|
||||
|
@ -103,6 +92,14 @@
|
|||
<action selector="selectMapTouchUpInside:" destination="-1" eventType="touchUpInside" id="RXu-BP-tNk"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Axo-F2-0Xb" userLabel="ProgressViewWrapper">
|
||||
<rect key="frame" x="142" y="45" width="36" height="36"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="36" id="CcH-aB-wPy"/>
|
||||
<constraint firstAttribute="height" constant="36" id="j9b-F2-Mcs"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
- (nonnull instancetype)init __attribute__((unavailable("init is not available")));
|
||||
- (nonnull instancetype)initWithDelegate:(nonnull id<MWMSearchDownloadProtocol>)delegate;
|
||||
|
||||
- (void)downloadProgress:(CGFloat)progress countryName:(nonnull NSString *)countryName;
|
||||
- (void)downloadProgress:(CGFloat)progress;
|
||||
- (void)setDownloadFailed;
|
||||
|
||||
@end
|
||||
|
|
|
@ -83,10 +83,10 @@
|
|||
|
||||
#pragma mark - Process control
|
||||
|
||||
- (void)downloadProgress:(CGFloat)progress countryName:(nonnull NSString *)countryName
|
||||
- (void)downloadProgress:(CGFloat)progress
|
||||
{
|
||||
[self stateUpdated:MWMDownloadMapRequestStateDownload];
|
||||
[self.downloadRequest downloadProgress:progress countryName:countryName];
|
||||
[self.downloadRequest downloadProgress:progress];
|
||||
}
|
||||
|
||||
- (void)setDownloadFailed
|
||||
|
|
|
@ -218,12 +218,7 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
|
|||
|
||||
- (void)processCountry:(storage::TCountryId const &)countryId progress:(storage::TLocalAndRemoteSize const &)progress
|
||||
{
|
||||
using namespace storage;
|
||||
CGFloat const normProgress = (CGFloat)progress.first / progress.second;
|
||||
NodeAttrs attrs;
|
||||
GetFramework().Storage().GetNodeAttrs(countryId, attrs);
|
||||
NSString * countryName = @(attrs.m_nodeLocalName.c_str());
|
||||
[self.downloadController downloadProgress:normProgress countryName:countryName];
|
||||
[self.downloadController downloadProgress:static_cast<CGFloat>(progress.first) / progress.second];
|
||||
}
|
||||
|
||||
#pragma mark - MWMSearchDownloadProtocol
|
||||
|
|
Loading…
Add table
Reference in a new issue