forked from organicmaps/organicmaps
[iOS] fix release crashes
This commit is contained in:
parent
c5b9e51a79
commit
da0056d530
14 changed files with 75 additions and 55 deletions
|
@ -49,6 +49,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@interface PlacePageData : NSObject
|
||||
|
||||
@property(nonatomic, readonly, class) BOOL isGuide;
|
||||
@property(class, nonatomic, readonly) BOOL hasData;
|
||||
|
||||
@property(nonatomic, readonly, nullable) PlacePageButtonsData *buttonsData;
|
||||
@property(nonatomic, readonly) PlacePagePreviewData *previewData;
|
||||
@property(nonatomic, readonly, nullable) PlacePageInfoData *infoData;
|
||||
|
|
|
@ -68,7 +68,12 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
}
|
||||
}
|
||||
|
||||
@interface PlacePageData () <MWMStorageObserver>
|
||||
@interface PlacePageData () <MWMStorageObserver> {
|
||||
FeatureID m_featureID;
|
||||
m2::PointD m_mercator;
|
||||
std::vector<std::string> m_rawTypes;
|
||||
std::string m_hotelId;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
@ -158,6 +163,12 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
_mapNodeAttributes = [[MWMStorage sharedStorage] attributesForCountry:@(rawData().GetCountryId().c_str())];
|
||||
[[MWMStorage sharedStorage] addObserver:self];
|
||||
}
|
||||
|
||||
m_featureID = rawData().GetID();
|
||||
m_mercator = rawData().GetMercator();
|
||||
m_rawTypes = rawData().GetRawTypes();
|
||||
m_hotelId = rawData().GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -168,6 +179,10 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
}
|
||||
}
|
||||
|
||||
+ (BOOL)hasData {
|
||||
return GetFramework().HasPlacePageInfo();
|
||||
}
|
||||
|
||||
- (void)loadOnlineDataWithCompletion:(MWMVoidBlock)completion {
|
||||
dispatch_group_t group = dispatch_group_create();
|
||||
if (self.previewData.isBookingPlace) {
|
||||
|
@ -189,7 +204,7 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
|
||||
- (void)loadUgcWithCompletion:(MWMVoidBlock)completion {
|
||||
__weak __typeof(self) wSelf = self;
|
||||
GetFramework().GetUGC(rawData().GetID(), [wSelf, completion] (ugc::UGC const & ugc, ugc::UGCUpdate const & update) {
|
||||
GetFramework().GetUGC(m_featureID, [wSelf, completion] (ugc::UGC const & ugc, ugc::UGCUpdate const & update) {
|
||||
__strong __typeof(wSelf) self = wSelf;
|
||||
if (self == nil) {
|
||||
completion();
|
||||
|
@ -226,11 +241,11 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
|
||||
auto locale = AppInfo.sharedInfo.twoLetterLanguageId.UTF8String;
|
||||
if (self.isLargeToponim) {
|
||||
api->GetCityGallery(rawData().GetMercator(), locale, UTM::LargeToponymsPlacepageGallery, resultHandler, errorHandler);
|
||||
api->GetCityGallery(m_mercator, locale, UTM::LargeToponymsPlacepageGallery, resultHandler, errorHandler);
|
||||
} else {
|
||||
api->GetPoiGallery(rawData().GetMercator(),
|
||||
api->GetPoiGallery(m_mercator,
|
||||
locale,
|
||||
rawData().GetRawTypes(),
|
||||
m_rawTypes,
|
||||
[MWMFrameworkHelper isWiFiConnected],
|
||||
UTM::SightseeingsPlacepageGallery,
|
||||
resultHandler,
|
||||
|
@ -253,9 +268,9 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
return;
|
||||
}
|
||||
|
||||
std::string const hotelId = rawData().GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
std::string const hotelId = m_hotelId;
|
||||
__weak __typeof(self) wSelf = self;
|
||||
api->GetHotelInfo(hotelId,
|
||||
api->GetHotelInfo(m_hotelId,
|
||||
[[AppInfo sharedInfo] twoLetterLanguageId].UTF8String,
|
||||
[wSelf, hotelId, completion] (booking::HotelInfo const & hotelInfo) {
|
||||
__strong __typeof(wSelf) self = wSelf;
|
||||
|
@ -281,7 +296,7 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
std::string const currency = "RUB";
|
||||
|
||||
auto params = booking::BlockParams::MakeDefault();
|
||||
params.m_hotelId = rawData().GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID);
|
||||
params.m_hotelId = m_hotelId;
|
||||
params.m_currency = currency;
|
||||
|
||||
__weak __typeof(self) wSelf = self;
|
||||
|
@ -330,7 +345,7 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
|
|||
|
||||
- (void)processCountryEvent:(NSString *)countryId {
|
||||
if ([countryId isEqualToString:self.mapNodeAttributes.countryId]) {
|
||||
_mapNodeAttributes = [[MWMStorage sharedStorage] attributesForCountry:@(rawData().GetCountryId().c_str())];
|
||||
_mapNodeAttributes = [[MWMStorage sharedStorage] attributesForCountry:countryId];
|
||||
if (self.onMapNodeStatusUpdate != nil) {
|
||||
self.onMapNodeStatusUpdate();
|
||||
}
|
||||
|
|
|
@ -114,6 +114,10 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing";
|
|||
#pragma mark - Map Navigation
|
||||
|
||||
- (void)showPlacePage {
|
||||
if (!PlacePageData.hasData) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.controlsManager.trafficButtonHidden = YES;
|
||||
if (PlacePageData.isGuide) {
|
||||
self.placePageVC = [MWMGuidesGalleryBuilder build];
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@protocol MWMMapDownloaderButtonTableViewCellProtocol <NSObject>
|
||||
|
||||
- (void)onAddMaps;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMMapDownloaderButtonTableViewCell : MWMTableViewCell
|
||||
|
||||
@property (weak, nonatomic) id<MWMMapDownloaderButtonTableViewCellProtocol> delegate;
|
||||
|
||||
@end
|
||||
|
|
|
@ -22,9 +22,4 @@
|
|||
[self setLayoutMargins:UIEdgeInsetsZero];
|
||||
}
|
||||
|
||||
- (IBAction)buttonPressed
|
||||
{
|
||||
[self.delegate onAddMaps];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -16,29 +16,31 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="22f-XO-fEh">
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Add Maps Button" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dOW-mN-UY7">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" priority="750" constant="44" id="ppe-HK-X6q"/>
|
||||
<constraint firstAttribute="height" constant="44" id="6Wr-jd-ikR"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Add Maps Button"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<color key="textColor" systemColor="linkColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="regular17:linkBlueText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="download_maps"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="buttonPressed" destination="KGk-i7-Jjw" eventType="touchUpInside" id="wi2-kT-ib1"/>
|
||||
</connections>
|
||||
</button>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="22f-XO-fEh" secondAttribute="bottom" id="Dmd-Qj-hkL"/>
|
||||
<constraint firstItem="22f-XO-fEh" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="VTQ-nl-h3g"/>
|
||||
<constraint firstAttribute="trailing" secondItem="22f-XO-fEh" secondAttribute="trailing" id="j9Y-lb-BeQ"/>
|
||||
<constraint firstItem="22f-XO-fEh" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="rRj-TU-xPW"/>
|
||||
<constraint firstItem="dOW-mN-UY7" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="EyM-Ka-jj7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="dOW-mN-UY7" secondAttribute="trailing" id="K0a-sK-wOb"/>
|
||||
<constraint firstAttribute="bottom" secondItem="dOW-mN-UY7" secondAttribute="bottom" id="h4g-hj-rht"/>
|
||||
<constraint firstItem="dOW-mN-UY7" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="tcn-Sg-XSP"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<point key="canvasLocation" x="139" y="155"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
|
|
|
@ -216,6 +216,12 @@ class DownloadMapsViewController: MWMViewController {
|
|||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func onAddMaps() {
|
||||
let vc = storyboard!.instantiateViewController(ofType: DownloadMapsViewController.self)
|
||||
vc.mode = .available
|
||||
navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
|
@ -236,7 +242,6 @@ extension DownloadMapsViewController: UITableViewDataSource {
|
|||
if hasAddMapSection && indexPath.section == dataSource.numberOfSections() {
|
||||
let cellType = MWMMapDownloaderButtonTableViewCell.self
|
||||
let buttonCell = tableView.dequeueReusableCell(cell: cellType, indexPath: indexPath)
|
||||
buttonCell.delegate = self
|
||||
return buttonCell
|
||||
}
|
||||
|
||||
|
@ -320,6 +325,10 @@ extension DownloadMapsViewController: UITableViewDelegate {
|
|||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
if indexPath.section == dataSource.numberOfSections() {
|
||||
onAddMaps()
|
||||
return
|
||||
}
|
||||
let nodeAttrs = dataSource.item(at: indexPath)
|
||||
if nodeAttrs.hasChildren {
|
||||
showChildren(dataSource.item(at: indexPath))
|
||||
|
@ -462,13 +471,6 @@ extension DownloadMapsViewController: UIBarPositioningDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - MWMMapDownloaderButtonTableViewCellProtocol
|
||||
|
||||
extension DownloadMapsViewController: MWMMapDownloaderButtonTableViewCellProtocol {
|
||||
@objc func onAddMaps() {
|
||||
let vc = storyboard!.instantiateViewController(ofType: DownloadMapsViewController.self)
|
||||
vc.mode = .available
|
||||
navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -509,6 +511,4 @@ extension DownloadMapsViewController: DownloadAllViewDelegate {
|
|||
Statistics.logEvent(kStatDownloaderDownloadCancel, withParameters: [kStatFrom: kStatMap])
|
||||
skipCountryEvent = false
|
||||
self.processCountryEvent(dataSource.parentAttributes().countryId)
|
||||
reloadData()
|
||||
}
|
||||
}
|
||||
reloadData()
|
|
@ -1,6 +1,9 @@
|
|||
class SearchMapsDataSource {
|
||||
typealias SearchCallback = (Bool) -> Void
|
||||
|
||||
fileprivate var searchResults: [MapSearchResult] = []
|
||||
fileprivate var searchId = 0
|
||||
fileprivate var onUpdate: SearchCallback?
|
||||
}
|
||||
|
||||
extension SearchMapsDataSource: IDownloaderDataSource {
|
||||
|
@ -56,20 +59,22 @@ extension SearchMapsDataSource: IDownloaderDataSource {
|
|||
completion()
|
||||
}
|
||||
|
||||
func search(_ query: String, locale: String, update: @escaping (Bool) -> Void) {
|
||||
func search(_ query: String, locale: String, update: @escaping SearchCallback) {
|
||||
searchId += 1
|
||||
onUpdate = update
|
||||
FrameworkHelper.search(inDownloader: query, inputLocale: locale) { [weak self, searchId] (results, finished) in
|
||||
self?.searchResults = results
|
||||
if searchId != self?.searchId {
|
||||
return
|
||||
}
|
||||
self?.searchResults = results
|
||||
if results.count > 0 || finished {
|
||||
update(finished)
|
||||
self?.onUpdate?(finished)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func cancelSearch() {
|
||||
self.searchResults = []
|
||||
searchResults = []
|
||||
onUpdate = nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,6 +252,7 @@ enum RowInMetaInfo
|
|||
{
|
||||
[[MWMBookmarksManager sharedManager] deleteBookmark:m_cachedBookmarkId];
|
||||
GetFramework().UpdatePlacePageInfoForCurrentSelection();
|
||||
[self.placePageData updateBookmarkStatus];
|
||||
[self goBack];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
protocol ActionBarViewControllerDelegate: AnyObject {
|
||||
func actionBar(_ actionBar: ActionBarViewController, dPressButton type: ActionBarButtonType)
|
||||
func actionBar(_ actionBar: ActionBarViewController, didPressButton type: ActionBarButtonType)
|
||||
}
|
||||
|
||||
class ActionBarViewController: UIViewController {
|
||||
|
@ -171,7 +171,7 @@ class ActionBarViewController: UIViewController {
|
|||
style: .default,
|
||||
handler: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
self.delegate?.actionBar(self, dPressButton: button)
|
||||
self.delegate?.actionBar(self, didPressButton: button)
|
||||
}))
|
||||
}
|
||||
actionSheet.addAction(UIAlertAction(title: L("cancel"), style: .cancel))
|
||||
|
@ -189,6 +189,6 @@ extension ActionBarViewController: ActionBarButtonDelegate {
|
|||
showMore()
|
||||
return
|
||||
}
|
||||
delegate?.actionBar(self, dPressButton: type)
|
||||
delegate?.actionBar(self, didPressButton: type)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -888,7 +888,7 @@
|
|||
<scene sceneID="MOc-50-GOI">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="ActionBarViewController" id="idq-Vs-dIh" customClass="ActionBarViewController" customModule="maps_me" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Odt-s0-pOf">
|
||||
<view key="view" contentMode="scaleToFill" id="Odt-s0-pOf" customClass="SolidTouchView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
|
|
|
@ -190,7 +190,7 @@ extension PlacePageInteractor: PlacePageBookmarkViewControllerDelegate {
|
|||
// MARK: - ActionBarViewControllerDelegate
|
||||
|
||||
extension PlacePageInteractor: ActionBarViewControllerDelegate {
|
||||
func actionBar(_ actionBar: ActionBarViewController, dPressButton type: ActionBarButtonType) {
|
||||
func actionBar(_ actionBar: ActionBarViewController, didPressButton type: ActionBarButtonType) {
|
||||
switch type {
|
||||
case .booking:
|
||||
MWMPlacePageManagerHelper.book(placePageData)
|
||||
|
|
|
@ -186,7 +186,7 @@ static UIColor *backgroundColorForPartner(NSInteger partnerIndex) {
|
|||
}
|
||||
|
||||
- (void)progressButtonPressed:(MWMCircularProgress *)progress {
|
||||
[self.delegate tapOnButtonWithType:MWMActionBarButtonTypeDownload];
|
||||
[self.delegate tapOnButtonWithType:self.type];
|
||||
}
|
||||
|
||||
- (IBAction)tap {
|
||||
|
|
|
@ -219,7 +219,11 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout {
|
|||
|
||||
placePageData.loadOnlineData(completion: onLoadOnlineData)
|
||||
placePageData.onBookmarkStatusUpdate = { [weak self] in
|
||||
self?.updateBookmarkSection()
|
||||
guard let self = self else { return }
|
||||
if self.placePageData.bookmarkData == nil {
|
||||
self.actionBarViewController.resetButtons()
|
||||
}
|
||||
self.updateBookmarkSection()
|
||||
}
|
||||
placePageData.onUgcStatusUpdate = { [weak self] in
|
||||
self?.onLoadUgc()
|
||||
|
|
Loading…
Add table
Reference in a new issue