From 00efcf85aa4325bb4012fa56b56f533c660079b7 Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Thu, 2 Feb 2017 14:03:47 +0300 Subject: [PATCH] Fixed calculation of size in downloader --- .../Cells/MWMMapDownloaderTableViewCell.mm | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/iphone/Maps/UI/Downloader/Cells/MWMMapDownloaderTableViewCell.mm b/iphone/Maps/UI/Downloader/Cells/MWMMapDownloaderTableViewCell.mm index d8772760e6..4178aab7d3 100644 --- a/iphone/Maps/UI/Downloader/Cells/MWMMapDownloaderTableViewCell.mm +++ b/iphone/Maps/UI/Downloader/Cells/MWMMapDownloaderTableViewCell.mm @@ -61,9 +61,30 @@ self.title.attributedText = [self matchedString:@(nodeAttrs.m_nodeLocalName.c_str()) selectedAttrs:selectedTitleAttrs unselectedAttrs:unselectedTitleAttrs]; - TMwmSize const size = self.mode == mwm::DownloaderMode::Downloaded - ? nodeAttrs.m_downloadingMwmSize + + TMwmSize size = nodeAttrs.m_mwmSize; + bool const isModeDownloaded = self.mode == mwm::DownloaderMode::Downloaded; + + switch (nodeAttrs.m_status) + { + case storage::NodeStatus::Error: + case storage::NodeStatus::Undefined: + case storage::NodeStatus::NotDownloaded: + case storage::NodeStatus::OnDiskOutOfDate: + size = isModeDownloaded ? nodeAttrs.m_localMwmSize : nodeAttrs.m_mwmSize; + break; + case storage::NodeStatus::Downloading: + size = isModeDownloaded ? nodeAttrs.m_downloadingMwmSize + : nodeAttrs.m_mwmSize - nodeAttrs.m_downloadingMwmSize; + break; + case storage::NodeStatus::InQueue: + case storage::NodeStatus::Partly: + size = isModeDownloaded ? nodeAttrs.m_localMwmSize : nodeAttrs.m_mwmSize - nodeAttrs.m_localMwmSize; + break; + case storage::NodeStatus::OnDisk: size = isModeDownloaded ? nodeAttrs.m_mwmSize : 0; break; + } + self.downloadSize.text = formattedSize(size); self.downloadSize.hidden = (size == 0); }