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

Fix LottieDrawable#start for non-View callbacks #2056

Merged
merged 2 commits into from Apr 13, 2022

Conversation

ajarl
Copy link
Contributor

@ajarl ajarl commented Apr 13, 2022

Previously, the start function would be a noop if your callback was something other than a View instance.

With this change, if you use a non-View Callback (such as a Drawable), start will still call playAnimation; if the Callback was a View, it must still not be in edit mode to call playAnimation.

Previously, the start function would be a noop if your callback was
something other than a View instance.
@LottieSnapshotBot
Copy link

LottieSnapshotBot commented Apr 13, 2022

Snapshot Tests
28: Report Diff

@@ -551,7 +551,7 @@ public void draw(Canvas canvas, Matrix matrix) {
public void start() {
// Don't auto play when in edit mode.
Callback callback = getCallback();
if (callback instanceof View && !((View) callback).isInEditMode()) {
if (!(callback instanceof View) || !((View) callback).isInEditMode()) {
Copy link
Collaborator

@gpeal gpeal Apr 13, 2022

Choose a reason for hiding this comment

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

Thinking about this a bit more, it might be easier to read as if (is View && isInEditMode() return
The double negative with an or requires too much thought to grok 😄

Copy link
Contributor Author

@ajarl ajarl Apr 13, 2022

Choose a reason for hiding this comment

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

Agreed!

@LottieSnapshotBot
Copy link

LottieSnapshotBot commented Apr 13, 2022

Snapshot Tests
28: Report Diff

gpeal
gpeal approved these changes Apr 13, 2022
@gpeal gpeal merged commit 318b8ea into airbnb:master Apr 13, 2022
4 checks passed
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.

None yet

3 participants