forked from organicmaps/organicmaps
[ios] Conversion kml after async load
This commit is contained in:
parent
b469e43088
commit
c59c2ab7e9
3 changed files with 12 additions and 20 deletions
|
@ -42,15 +42,7 @@ final class BMCViewController: MWMViewController {
|
|||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
let count = viewModel.filesCountForConversion
|
||||
if count > 0 {
|
||||
MWMAlertViewController.activeAlert().presentConvertBookmarksAlert(withCount: count)
|
||||
{ [weak viewModel] in
|
||||
MWMAlertViewController.activeAlert().presentSpinnerAlert(withTitle: L("converting"),
|
||||
cancel: nil)
|
||||
viewModel?.convertAllKML()
|
||||
}
|
||||
}
|
||||
viewModel.convertAllKMLIfNeeded()
|
||||
}
|
||||
|
||||
private func updateCategoryName(category: BMCCategory?) {
|
||||
|
@ -77,7 +69,6 @@ final class BMCViewController: MWMViewController {
|
|||
private func shareCategory(category: BMCCategory, anchor: UIView) {
|
||||
let shareOnSuccess = { [viewModel] (url: URL) in
|
||||
typealias AVC = MWMActivityViewController
|
||||
let fileName = (url.lastPathComponent as NSString).deletingPathExtension
|
||||
let message = L("share_bookmarks_email_body")
|
||||
let shareController = AVC.share(for: url, message: message) { [viewModel] _, _, _, _ in
|
||||
viewModel?.finishShareCategory()
|
||||
|
|
|
@ -23,12 +23,6 @@ final class BMCDefaultViewModel: NSObject {
|
|||
var minCategoryNameLength: UInt = Const.minCategoryNameLength
|
||||
var maxCategoryNameLength: UInt = Const.maxCategoryNameLength
|
||||
|
||||
var filesCountForConversion: UInt {
|
||||
get {
|
||||
return BM.filesCountForConversion()
|
||||
}
|
||||
}
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
BM.add(self)
|
||||
|
@ -203,14 +197,22 @@ extension BMCDefaultViewModel: BMCViewModel {
|
|||
pendingPermission(isPending: false)
|
||||
}
|
||||
|
||||
func convertAllKML() {
|
||||
BM.convertAll()
|
||||
func convertAllKMLIfNeeded() {
|
||||
let count = BM.filesCountForConversion()
|
||||
if count > 0 {
|
||||
MWMAlertViewController.activeAlert().presentConvertBookmarksAlert(withCount: count) {
|
||||
MWMAlertViewController.activeAlert().presentSpinnerAlert(withTitle: L("converting"),
|
||||
cancel: nil)
|
||||
BM.convertAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension BMCDefaultViewModel: MWMBookmarksObserver {
|
||||
func onBookmarksLoadFinished() {
|
||||
loadData()
|
||||
convertAllKMLIfNeeded()
|
||||
}
|
||||
|
||||
func onBookmarkDeleted(_: MWMMarkID) {
|
||||
|
|
|
@ -41,6 +41,5 @@ protocol BMCViewModel: AnyObject {
|
|||
func pendingPermission(isPending: Bool)
|
||||
func grant(permission: BMCPermission?)
|
||||
|
||||
var filesCountForConversion: UInt { get }
|
||||
func convertAllKML();
|
||||
func convertAllKMLIfNeeded();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue