Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display UI immediately if displayTimeThreshold = 0 #118

Merged
merged 1 commit into from
Feb 16, 2017
Merged

Display UI immediately if displayTimeThreshold = 0 #118

merged 1 commit into from
Feb 16, 2017

Conversation

nicoaldegheri
Copy link

In my application I try to update the message set in the ActivityData but I never see that change because setMessage() is called before the timer show the original ActivityData.
This is because even with diplayTimeThreshold = 0, the call of the selector show() is placed at the end of the current execution stack, after my message update.

This pullRequest is proposal to avoid this by immediately calling show() if displayThimeThresold = 0.

This for avoid show() put at the of the operation queue du to the use of the timer and selector.
if data.displayTimeThreshold == 0 {
show(with: data)
} else {
showTimer = scheduledTimer(data.displayTimeThreshold, selector: #selector(showTimerFired(_:)), data: data)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 100 characters or less: currently 118 characters (line_length)

@ninjaprox
Copy link
Owner

@nicoaldegheri: To clarify, your code will look like this (if I understand correctly):

indicatorView.startAnimating(data) // With message "Before change"
indicatorView.setMessage("After change")

Then the result is supposed to be "After change" instead of "Before change", isn't it?

@nicoaldegheri
Copy link
Author

@ninjaprox it's exactly that!

@ninjaprox
Copy link
Owner

ninjaprox commented Feb 10, 2017

@nicoaldegheri: Is there a specific reason behind that? In normal use case, the message can be packed in data, then change it after awhile by setMessage(_:).

@nicoaldegheri
Copy link
Author

Oh sorry, I misunderstood, this is exactly my use case:

myPresentFunction {
indicatorView.startAnimating(data) // With message "Before change"
}
myUpdateMessageFunction {
indicatorView.setMessage("After change")
}

I have some case where myUpdateMessageFunction() is call very quickly after myPresentFunction(). So quickly that it stacked before your showTimerFired() selector in showTimer.

I hope this is more understandable :-)

@ninjaprox ninjaprox merged commit 7d2cb2b into ninjaprox:master Feb 16, 2017
@nicoaldegheri
Copy link
Author

👍 Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants