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.5k stars 104 forks source link

Provide feature to have prepared shimmer layout #38

Closed avalanchas closed 8 months ago

avalanchas commented 8 months ago

Description

This PR adds very simple functionality to give a VeilLayout (and thus by extension a VeilRecyclerFrameView) a pre-made (prepared by the caller ahead of time) ShimmerFrameLayout to show when veiled. This simply means that the custom "masking" process is skipped and the VeilLayout simply shows the defaultChild view - which, again, is already shimmering

This means that the caller can just as well insert a Shimmer Layout for a carousel item, thereby going the first steps towards fixing #15 🎉 Personally, I would not close #15 yet, because in a perfect world AndroidVeil would auto-mask a carousel layout as well

A demo activity for a shimmering carousel is included in this PR

Types of changes

What types of changes does your code introduce?

This PR is fully compatible with previous versions because we simply assume isPrepared = false in all places, named parameters and xml attrs. Thus, the behaviour of existing apps does not change, only when isPrepared is set to true will the code stop adding the masked shimmerContainer

Preparing a pull request for review

avalanchas commented 7 months ago

Hi @skydoves, thank you for the high praise, coming from you it means a lot! I have one more note though: as I mentioned above:

Personally, I would not close https://github.com/skydoves/AndroidVeil/issues/15 yet, because in a perfect world AndroidVeil would auto-mask a carousel layout as well

In my humble opinion I think we should reopen #15 until carousels can be auto-masked I hope I can get to this in the next few months