Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormpimenov <mpimenov@users.noreply.github.com>2016-10-25 15:43:47 +0300
committerGitHub <noreply@github.com>2016-10-25 15:43:47 +0300
commit0a34ded0eb4edb3e548e98f36ac41364f80d0029 (patch)
tree514421194a3b3aae7c194b15de4eb875f4650d14
parent87ca29db2db2865fefe3cf591e2009a5e6ecd452 (diff)
parenta2dd40389674bcfa0fb493f274a1b826b4b9330f (diff)
Merge pull request #4552 from VladiMihaylenko/master
[ios] Fixed crash with opening hours.
-rw-r--r--iphone/Maps/Classes/MWMOpeningHoursCell.h2
-rw-r--r--iphone/Maps/Classes/MWMOpeningHoursCell.mm17
2 files changed, 14 insertions, 5 deletions
diff --git a/iphone/Maps/Classes/MWMOpeningHoursCell.h b/iphone/Maps/Classes/MWMOpeningHoursCell.h
index 211cf927a9..b310ed1035 100644
--- a/iphone/Maps/Classes/MWMOpeningHoursCell.h
+++ b/iphone/Maps/Classes/MWMOpeningHoursCell.h
@@ -4,7 +4,7 @@
@interface MWMOpeningHoursCell : MWMTableViewCell
-- (void)configureWithOpeningHours:(NSString *)openningHours
+- (void)configureWithOpeningHours:(NSString *)openingHours
updateLayoutDelegate:(id<MWMPlacePageCellUpdateProtocol>)delegate
isClosedNow:(BOOL)isClosedNow;
@end
diff --git a/iphone/Maps/Classes/MWMOpeningHoursCell.mm b/iphone/Maps/Classes/MWMOpeningHoursCell.mm
index 6667caa636..dafc55ef8e 100644
--- a/iphone/Maps/Classes/MWMOpeningHoursCell.mm
+++ b/iphone/Maps/Classes/MWMOpeningHoursCell.mm
@@ -99,6 +99,7 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
@property(weak, nonatomic) IBOutlet UITableView * tableView;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewHeight;
+@property(copy, nonatomic) NSString * rawString;
@property(weak, nonatomic) id<MWMPlacePageCellUpdateProtocol> delegate;
@@ -123,7 +124,7 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
[self registerObserver];
}
-- (void)configureWithOpeningHours:(NSString *)openningHours
+- (void)configureWithOpeningHours:(NSString *)openingHours
updateLayoutDelegate:(id<MWMPlacePageCellUpdateProtocol>)delegate
isClosedNow:(BOOL)isClosedNow;
{
@@ -132,9 +133,11 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
self.isExtended = NO;
self.delegate = delegate;
self.isClosedNow = isClosedNow;
+ // If we can't parse opening hours string then leave it as is.
+ self.rawString = openingHours;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
- self->m_days = [MWMOpeningHours processRawString:openningHours];
+ self->m_days = [MWMOpeningHours processRawString:openingHours];
dispatch_async(dispatch_get_main_queue(), ^{
self.tableView.delegate = self;
self.tableView.dataSource = self;
@@ -147,7 +150,7 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
- return self.isExtended ? m_days.size() : 1;
+ return self.isExtended && !m_days.empty() ? m_days.size() : 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
@@ -159,7 +162,6 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
{
_MWMOHHeaderCell * cell =
[tableView dequeueReusableCellWithIdentifier:[_MWMOHHeaderCell className]];
- cell.text.attributedText = richStringFromDay(day, self.isClosedNow);
if (m_days.size() > 1)
{
@@ -185,6 +187,13 @@ NSAttributedString * richStringFromDay(osmoh::Day const & day, BOOL isClosedNow)
cell.tapAction = nil;
cell.arrowIcon.hidden = YES;
}
+
+ // This means that we couldn't parse opening hours string.
+ if (m_days.empty())
+ cell.text.text = self.rawString;
+ else
+ cell.text.attributedText = richStringFromDay(day, self.isClosedNow);
+
return cell;
}
else