BakerJQ / Android-InfiniteCards

An infinite card switching UI for Android, support custom animation 自定义实现神奇动效的卡片切换视图
Apache License 2.0
1.73k stars 204 forks source link

Delay in swap animation due to late UI rendering. #17

Closed AtharvaAbsolute closed 5 years ago

AtharvaAbsolute commented 5 years ago

Hi, I'm facing some issues with the swap animation. My adapter earlier was very long and inefficient so I had to put 1.5s delay so that the cards UI can render properly and then the swap animation took place. Now I have optimized the adapter to an extent where it can't be optimized more I guess and I see a much better performance boost. I have written all the necessary cases for the adapter in my model class and the adapter has just got to render the UI and nothing else, no complex conditions are present. But I'm still facing that issue even after such a fast operation, the swap animation doesn't work if I remove the delay or decrease it lesser than 1500ms. I'm using a Handler for this. Can you give me some insight into how can I lower the delay?. Thanks

BakerJQ commented 5 years ago

If you can give a demo code to me, maybe I can understand the situation better. For now, I don't quite understand the situation you described

AtharvaAbsolute commented 5 years ago

card.txt Please check this file out, I can't share the adapter with you due to security concerns. I'll walk you through the code, can you set up a call if possible? Thanks.

BakerJQ commented 5 years ago

Did you do any operation on setTransformerAnimAdd

AtharvaAbsolute commented 5 years ago

https://pastebin.com/i1LMSLYV I'm using this function for animation.

BakerJQ commented 5 years ago

Maybe you can try setTransformerAnimAdd(null) and setTransformerAnimRemove(null) then remove the delay

AtharvaAbsolute commented 5 years ago

And where do I do this?

BakerJQ commented 5 years ago

Just after initiate eg. findViewById

AtharvaAbsolute commented 5 years ago

cardStackView.setClickable(false); cardStackView.setAnimType(InfiniteCardView.ANIM_TYPE_SWITCH); cardStackView.setAnimInterpolator(new OvershootInterpolator(-8)); cardStackView.setTransformerToFront(new DefaultCommonTransformer());

Can I do it after the third line?

BakerJQ commented 5 years ago

yes

AtharvaAbsolute commented 5 years ago

screenshot They show this error.

BakerJQ commented 5 years ago

oh gosh...my mistake....I'll update it

AtharvaAbsolute commented 5 years ago

Okay, please revert when done, I'll also update the lib. version. Thanks.

BakerJQ commented 5 years ago

try version 1.0.5

AtharvaAbsolute commented 5 years ago

Sure.

AtharvaAbsolute commented 5 years ago

Looks good, no errors now. I'm gonna test it. I'll revert.

AtharvaAbsolute commented 5 years ago

Thanks👍

BakerJQ commented 5 years ago

My pleasure to help

AtharvaAbsolute commented 5 years ago

Removed the delay and added the two statements just after findViewById The app crashed, looks like it runs the animation before the cards are rendered.

'java.lang.Object java.util.LinkedList.getFirst()' on a null object reference cardStackView.bringCardToFront(1); got the error on this.

BakerJQ commented 5 years ago

I think I can only solve this by debug the project......

AtharvaAbsolute commented 5 years ago

I know what the problem is, the methods are executing before the cards are being rendered. I'll look into it. Can you take a remote connection and help me out. The library is awesome and has adapted to the requirements very well. The issue is probably on my side.

BakerJQ commented 5 years ago

remote connection may not available........for some extra reason in China......

AtharvaAbsolute commented 5 years ago

Okay, I'll try and debug, maybe it needs more optimization. I really appreciate the help and time. Thanks.