forked from organicmaps/organicmaps
[ios] Fixed minor issues
Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
parent
0544b47050
commit
c96a652543
2 changed files with 22 additions and 9 deletions
|
@ -89,11 +89,11 @@
|
|||
self.downloadSize.hidden = (size == 0);
|
||||
}
|
||||
|
||||
- (void)configProgress:(MWMMapNodeAttributes *)nodeAttrs {
|
||||
- (void)configProgress:(MWMMapNodeAttributes *)na {
|
||||
MWMCircularProgress *progress = self.progress;
|
||||
BOOL isModeDownloaded = self.mode == MWMMapDownloaderModeDownloaded;
|
||||
MWMButtonColoring coloring = isModeDownloaded ? MWMButtonColoringBlack : MWMButtonColoringBlue;
|
||||
switch (nodeAttrs.nodeStatus) {
|
||||
switch (na.nodeStatus) {
|
||||
case MWMMapNodeStatusNotDownloaded:
|
||||
case MWMMapNodeStatusPartly: {
|
||||
MWMCircularProgressStateVec affectedStates = @[@(MWMCircularProgressStateNormal), @(MWMCircularProgressStateSelected)];
|
||||
|
@ -102,9 +102,20 @@
|
|||
progress.state = MWMCircularProgressStateNormal;
|
||||
break;
|
||||
}
|
||||
case MWMMapNodeStatusDownloading:
|
||||
progress.progress = kMaxProgress * nodeAttrs.downloadedSize / (isModeDownloaded ? nodeAttrs.totalUpdateSizeBytes : nodeAttrs.totalSize - nodeAttrs.downloadingSize);
|
||||
case MWMMapNodeStatusDownloading: {
|
||||
// Avoid NaN and +inf.
|
||||
// TODO: Refactor downloader and do not allow these situations to happen.
|
||||
float denominator;
|
||||
if (isModeDownloaded) {
|
||||
denominator = na.totalUpdateSizeBytes ? na.totalUpdateSizeBytes : na.totalSize;
|
||||
} else {
|
||||
uint64_t const diff = na.totalSize - na.downloadingSize;
|
||||
denominator = diff > 0 ? diff : na.totalSize;
|
||||
}
|
||||
assert(denominator);
|
||||
progress.progress = kMaxProgress * na.downloadedSize / denominator;
|
||||
break;
|
||||
}
|
||||
case MWMMapNodeStatusApplying:
|
||||
case MWMMapNodeStatusInQueue:
|
||||
progress.state = MWMCircularProgressStateSpinner;
|
||||
|
|
|
@ -406,11 +406,13 @@ extension DownloadMapsViewController: StorageObserver {
|
|||
configButtons()
|
||||
}
|
||||
|
||||
for cell in tableView.visibleCells {
|
||||
guard let downloaderCell = cell as? MWMMapDownloaderTableViewCell else { continue }
|
||||
if downloaderCell.nodeAttrs.countryId != countryId { continue }
|
||||
guard let indexPath = tableView.indexPath(for: downloaderCell) else { return }
|
||||
downloaderCell.config(dataSource.item(at: indexPath), searchQuery: searchBar.text)
|
||||
for _ in tableView.visibleCells {
|
||||
// Referencing tableView.visibleCells automatically initializes them, so the code below is not needed.
|
||||
// See func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
|
||||
// guard let downloaderCell = cell as? MWMMapDownloaderTableViewCell else { continue }
|
||||
// if downloaderCell.nodeAttrs.countryId != countryId { continue }
|
||||
// guard let indexPath = tableView.indexPath(for: downloaderCell) else { return }
|
||||
// downloaderCell.config(dataSource.item(at: indexPath), searchQuery: searchBar.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue