skydoves / AndroidVeil

:performing_arts: An easy and flexible way to implement loading skeletons and shimmering effects on layouts for Android.
Apache License 2.0
1.52k stars 106 forks source link

ShimmerContainer and maskElements leaking views on multiple calls to VeilLayout#setLayout(View) #21

Closed AlexQuinlivan closed 2 years ago

AlexQuinlivan commented 2 years ago

VeilLayout#maskElements was an array that was seemingly unused, but multiple calls to setLayout would retain all previously held views and append the new views.

VeilLayout#shimmerContainer would eventually grow in size as multiple setLayout calls were made. This was remedied by removing all the views contained on setLayout.

I'm not sure many people have the same use case as I do, but for some of the views that I have their internals have mutable visibility and require multiple refreshes of the shimmer container contents. I was thinking that maybe I should also add an invalidateVeil that skips the removal of the contained layout, but recalculates the shimmer container. Not sure this is something that you'd be interested in, but probably calls for a seperate "New feature" PR.

Gradle spotless apply passes on this PR.

Guidelines

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

Types of changes

What types of changes does your code introduce?

Preparing a pull request for review

Ensure your change is properly formatted by running:

$ ./gradlew spotlessApply

Please correct any failures before requesting a review.