BakerJQ / Android-InfiniteCards

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

Can I implement swipe action on the items. #14

Closed AtharvaAbsolute closed 5 years ago

AtharvaAbsolute commented 5 years ago

My items have click listeners embedded in them, so I want the cards to change on swipe instead of a click action. Is the functionality available in the current version?

BakerJQ commented 5 years ago

It is not support for swipe actions, but you can implement it by extending InfiniteCardView and override onTouch method

AtharvaAbsolute commented 5 years ago

I have integrated the library pretty good, it has solved 90% of my problem, the only issue I'm facing is that the swipe actions that I'm using by overriding the onTouchListener is working outside the bounds of the component and not on the card, I have put the listener on the library component.

AtharvaAbsolute commented 5 years ago

Is there any way I can implement swipe actions on the child view, my adapter item.

BakerJQ commented 5 years ago

Maybe you can try intercepting touch event on your adapter item

AtharvaAbsolute commented 5 years ago

Yeah, I did that, it worked. Thanks!.

AtharvaAbsolute commented 5 years ago

Screenshot from 2019-03-18 02-01-01

My current layout is currently like as shown in 1, but I want it to be like 2, can this be done. Can I set any offset or something.

BakerJQ commented 5 years ago

This can be done by recalculating in AnimationTransformer, as shown in the customisation section (https://github.com/BakerJQ/Android-InfiniteCards#customisation) , you may try add setTranslationX

AtharvaAbsolute commented 5 years ago

I want to show an automatic demo swipe every time my app launches. I'm currently using the following code:

cardStackView.bringCardToFront(1);

Error:

Attempt to invoke virtual method 'java.lang.Object java.util.LinkedList.getFirst()' on a null object reference at com.bakerj.infinitecards.CardAnimationHelper.bringCardToFront(CardAnimationHelper.java:587) at com.bakerj.infinitecards.InfiniteCardView.bringCardToFront(InfiniteCardView.java:159)

BakerJQ commented 5 years ago

The list is not created yet, maybe you should do this after the view is fully attached

AtharvaAbsolute commented 5 years ago

I'm calling this in onViewCreated()

BakerJQ commented 5 years ago

The list is set after getting exact width and height in onMeasure

AtharvaAbsolute commented 5 years ago

Thanks, I did it.