use of com.facebook.rebound.Spring in project android-card-slide-panel by xmuSistone.
the class CardItemView method initSpring.
private void initSpring() {
SpringConfig springConfig = SpringConfig.fromBouncinessAndSpeed(15, 20);
SpringSystem mSpringSystem = SpringSystem.create();
springX = mSpringSystem.createSpring().setSpringConfig(springConfig);
springY = mSpringSystem.createSpring().setSpringConfig(springConfig);
springX.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
int xPos = (int) spring.getCurrentValue();
setScreenX(xPos);
parentView.onViewPosChanged(CardItemView.this);
}
});
springY.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
int yPos = (int) spring.getCurrentValue();
setScreenY(yPos);
parentView.onViewPosChanged(CardItemView.this);
}
});
}
use of com.facebook.rebound.Spring in project LollipopShowcase by mikepenz.
the class ReboundItemAnimator method runPendingAnimations.
@Override
public void runPendingAnimations() {
if (!mViewHolders.isEmpty()) {
for (final RecyclerView.ViewHolder viewHolder : mViewHolders) {
SpringSystem springSystem = SpringSystem.create();
SpringConfig springConfig = new SpringConfig(70, 10);
final View target = viewHolder.itemView;
// Add a spring to the system.
Spring spring = springSystem.createSpring();
spring.setSpringConfig(springConfig);
spring.setCurrentValue(0.0f);
// Add a listener to observe the motion of the spring.
spring.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// You can observe the updates in the spring
// state by asking its current value in onSpringUpdate.
float value = (float) spring.getCurrentValue();
target.setScaleX(value);
target.setScaleY(value);
}
});
// Set the spring in motion; moving from 0 to 1
spring.setEndValue(1.0f);
}
}
}
use of com.facebook.rebound.Spring in project Depth-LIB-Android- by danielzeller.
the class RenderableThree method bounceBack.
public void bounceBack() {
cancelBounce();
isBounceAnimatin = true;
spring = springSystem.createSpring();
spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(150, 4));
final float offsetAtStart = offsetInPercent;
spring.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
float value = (float) spring.getCurrentValue();
offsetInPercent = offsetAtStart - (offsetAtStart * value);
}
@Override
public void onSpringAtRest(Spring spring) {
super.onSpringAtRest(spring);
isBounceAnimatin = false;
}
});
spring.setEndValue(1);
}
use of com.facebook.rebound.Spring in project android_packages_apps_DUI by DirtyUnicorns.
the class BaseNavigationBar method flushSpringSystem.
public void flushSpringSystem() {
if (mSpringSystem != null) {
for (Spring spring : mSpringSystem.getAllSprings()) {
spring.setAtRest();
spring.removeAllListeners();
spring.destroy();
}
mSpringSystem.removeAllListeners();
mSpringSystem = null;
}
}
use of com.facebook.rebound.Spring in project android-adDialog by yipianfengye.
the class AnimSpring method startCircleAnim.
/**
* 开始动画-定义动画开始角度
* @param animType
* @param animContainer
*/
public void startCircleAnim(final int animType, final RelativeLayout animContainer) {
double radius = Math.sqrt(DisplayUtil.screenhightPx * DisplayUtil.screenhightPx + DisplayUtil.screenWidthPx * DisplayUtil.screenWidthPx);
double heightY = -Math.sin(Math.toRadians(animType)) * radius;
double widthX = Math.cos(Math.toRadians(animType)) * radius;
Spring tranSpring = springSystem.createSpring();
Spring tranSpring1 = springSystem.createSpring();
tranSpring.addListener(new SimpleSpringListener() {
@Override
public void onSpringActivate(Spring spring) {
animContainer.setVisibility(View.VISIBLE);
}
@Override
public void onSpringUpdate(Spring spring) {
animContainer.setTranslationX((float) spring.getCurrentValue());
}
});
tranSpring1.addListener(new SimpleSpringListener() {
@Override
public void onSpringActivate(Spring spring) {
animContainer.setVisibility(View.VISIBLE);
}
@Override
public void onSpringUpdate(Spring spring) {
animContainer.setTranslationY((float) spring.getCurrentValue());
}
});
tranSpring.setSpringConfig(springConfig);
tranSpring1.setSpringConfig(springConfig);
tranSpring.setCurrentValue(widthX);
tranSpring.setEndValue(0);
tranSpring1.setCurrentValue(heightY);
tranSpring1.setEndValue(0);
}
Aggregations