Skip to content

[Internal] Use AnimatorSet#playTogether without workarounds on API 23+#4601

Open
pubiqq wants to merge 1 commit intomaterial-components:masterfrom
pubiqq:internal/compat-animator-set
Open

[Internal] Use AnimatorSet#playTogether without workarounds on API 23+#4601
pubiqq wants to merge 1 commit intomaterial-components:masterfrom
pubiqq:internal/compat-animator-set

Conversation

@pubiqq
Copy link
Contributor

@pubiqq pubiqq commented Feb 12, 2025

No description provided.

@pubiqq pubiqq mentioned this pull request Nov 11, 2024
@pubiqq pubiqq force-pushed the internal/compat-animator-set branch from 576b39e to 4f3cbfe Compare May 12, 2025 20:35
@pubiqq pubiqq force-pushed the internal/compat-animator-set branch from 4f3cbfe to e19e242 Compare September 8, 2025 21:17
@pubiqq pubiqq force-pushed the internal/compat-animator-set branch from e19e242 to c2fcc12 Compare March 18, 2026 15:11
Animator animator = items.get(i);
totalDuration = Math.max(totalDuration, animator.getStartDelay() + animator.getDuration());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Api23Impl.playTogether(animatorSet, items);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just inline the system call to be more accurate in semantics? (Like, it's not a "compat" impl.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a semantic standpoint, there is no significant difference between "for API ≥ 23, we invoke the platform implementation" and "for API ≥ 23, we invoke the implementation for API ≥ 23 (Api23Impl), which is the platform implementation". Even in the sample from the official guidelines, the platform method is called through an intermediate class.

But if you really want to, sure, you can edit my implementation and inline the platform call directly. Moreover, you can even remove all Api*Impl entirely and just use the platform call, like this:

@RestrictTo(Scope.LIBRARY_GROUP)
public class AnimatorSetCompat {

  public static void playTogether(@NonNull AnimatorSet animatorSet, @NonNull List<Animator> items) {
    animatorSet.playTogether(items);
  }
}

since the library no longer supports platforms prior to Marshmallow.

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.

2 participants