[ios] Fixed crash.

This commit is contained in:
VladiMihaylenko 2017-03-20 14:04:24 +03:00 committed by Илья Гречухин
parent af0bf47669
commit 0010540f22
3 changed files with 17 additions and 4 deletions

View file

@ -4,6 +4,8 @@
#include "partners_api/booking_api.hpp"
@class MWMPlacePageData;
namespace place_page
{
enum class Sections
@ -88,7 +90,7 @@ enum class OpeningHours
Unknown
};
using NewSectionsAreReady = void (^)(NSRange const & range);
using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * data);
using BannerIsReady = void (^)();
} // namespace place_page

View file

@ -27,6 +27,7 @@ using namespace place_page;
@property(copy, nonatomic) NSString * cachedMinPrice;
@property(nonatomic) FBNativeAd * nativeAd;
@property(copy, nonatomic) NSArray<MWMGalleryItemModel *> * photos;
@end
@ -186,6 +187,7 @@ using namespace place_page;
api->GetHotelInfo(hotelId, [[AppInfo sharedInfo] twoLetterLanguageId].UTF8String,
[hotelId, self](booking::HotelInfo const & hotelInfo)
{
if (hotelId != hotelInfo.m_hotelId)
return;
@ -250,7 +252,7 @@ using namespace place_page;
length++;
}
self.sectionsAreReadyCallback({position, length});
self.sectionsAreReadyCallback({position, length}, self);
});
});
});
@ -404,6 +406,9 @@ using namespace place_page;
- (NSURL *)URLToAllReviews { return [NSURL URLWithString:@(m_info.GetSponsoredReviewUrl().c_str())]; }
- (NSArray<MWMGalleryItemModel *> *)photos
{
if (_photos)
return _photos;
NSMutableArray<MWMGalleryItemModel *> * res = [@[] mutableCopy];
for (auto const & p : m_hotelInfo.m_photos)
{
@ -415,7 +420,9 @@ using namespace place_page;
auto photo = [[MWMGalleryItemModel alloc] initWithImageURL:big previewURL:preview];
[res addObject:photo];
}
return res;
self.photos = res;
return _photos;
}
#pragma mark - Bookmark

View file

@ -118,7 +118,11 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
{
self.isPlacePageButtonsEnabled = YES;
self.data = data;
data.sectionsAreReadyCallback = ^(NSRange const & range) {
data.sectionsAreReadyCallback = ^(NSRange const & range, MWMPlacePageData * d) {
if (![self.data isEqual:d])
return;
[self.placePageView.tableView insertSections:[NSIndexSet indexSetWithIndexesInRange:range]
withRowAnimation:UITableViewRowAnimationAutomatic];
};