forked from organicmaps/organicmaps-tmp
[ios] Rewrote RatingSummaryView update.
This commit is contained in:
parent
8fbab9754b
commit
28edc6a30d
2 changed files with 6 additions and 10 deletions
|
@ -183,6 +183,8 @@ import UIKit
|
|||
}
|
||||
}
|
||||
|
||||
var scheduledUpdate: DispatchWorkItem?
|
||||
|
||||
var settings = RatingSummaryViewSettings() {
|
||||
didSet {
|
||||
update()
|
||||
|
@ -228,16 +230,10 @@ import UIKit
|
|||
frame.size = intrinsicContentSize
|
||||
}
|
||||
|
||||
@objc func doUpdate() {
|
||||
DispatchQueue.main.async {
|
||||
self.updateImpl()
|
||||
}
|
||||
}
|
||||
|
||||
func update() {
|
||||
let sel = #selector(doUpdate)
|
||||
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: sel, object: nil)
|
||||
perform(sel, with: nil, afterDelay: 1 / 120)
|
||||
scheduledUpdate?.cancel()
|
||||
scheduledUpdate = DispatchWorkItem { [weak self] in self?.updateImpl() }
|
||||
DispatchQueue.main.async(execute: scheduledUpdate!)
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
|
|
|
@ -322,7 +322,7 @@ import UIKit
|
|||
|
||||
func update() {
|
||||
scheduledUpdate?.cancel()
|
||||
scheduledUpdate = DispatchWorkItem { self.updateImpl() }
|
||||
scheduledUpdate = DispatchWorkItem { [weak self] in self?.updateImpl() }
|
||||
DispatchQueue.main.async(execute: scheduledUpdate!)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue