本文整理汇总了Java中com.facebook.rebound.Spring.setEndValue方法的典型用法代码示例。如果您正苦于以下问题:Java Spring.setEndValue方法的具体用法?Java Spring.setEndValue怎么用?Java Spring.setEndValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.rebound.Spring
的用法示例。
在下文中一共展示了Spring.setEndValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyBloomOpenAnimation
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void applyBloomOpenAnimation() {
final SpringSystem springSystem = SpringSystem.create();
for (int i = 0; i < mMenuItemCount; i++) {
// create the springs that control movement
final Spring springX = springSystem.createSpring();
final Spring springY = springSystem.createSpring();
MenuItemView menuItemView = mMenuItemViews.get(i);
springX.addListener(new MapPerformer(menuItemView, View.X, mFAB.getLeft(), menuItemView.getLeft()));
springY.addListener(new MapPerformer(menuItemView, View.Y, mFAB.getTop(), menuItemView.getTop()));
DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(this,mContainerView,true);
springX.addListener(destroySelfSpringListener);
springY.addListener(destroySelfSpringListener);
springX.setEndValue(1);
springY.setEndValue(1);
}
}
示例2: applyBloomCloseAnimation
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void applyBloomCloseAnimation() {
final SpringSystem springSystem = SpringSystem.create();
for (int i = 0; i < mMenuItemCount; i++) {
// create the springs that control movement
final Spring springX = springSystem.createSpring();
final Spring springY = springSystem.createSpring();
MenuItemView menuItemView = mMenuItemViews.get(i);
springX.addListener(new MapPerformer(menuItemView, View.X, menuItemView.getLeft(), mFAB.getLeft()));
springY.addListener(new MapPerformer(menuItemView, View.Y, menuItemView.getTop(), mFAB.getTop()));
DestroySelfSpringListener destroySelfSpringListener = new DestroySelfSpringListener(this,mContainerView,false);
springX.addListener(destroySelfSpringListener);
springY.addListener(destroySelfSpringListener);
springX.setEndValue(1);
springY.setEndValue(1);
}
}
示例3: bounceView
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
/**
* Bounce the view. Will use the respective values for center and radial view
* @param child
* The child that has to be bounced
* @param springAnimator
* The spring animator with the listener to be invoked.
* Set null if you dont need to intercept the spring animation end
*
* @author Melvin Lobo
*/
private void bounceView(View child, SpringAnimator springAnimator) {
LayoutParams params = (LayoutParams) child.getLayoutParams();
if(params.getMenuType() == LayoutParams.CENTER) {
Spring centerScaleSpring = mSpringSystem.createSpring();
centerScaleSpring.setSpringConfig( new SpringConfig( CENTER_SCALE_TENSION, CENTER_SCALE_FRICTION ) );
centerScaleSpring.setEndValue( 1 );
centerScaleSpring.addListener( springAnimator );
}
else {
Spring radialScaleSpring = mSpringSystem.createSpring();
radialScaleSpring.setSpringConfig( new SpringConfig( RADIAL_SCALE_TENSION, RADIAL_SCALE_FRICTION ) );
radialScaleSpring.setEndValue( 1 );
radialScaleSpring.addListener( springAnimator );
}
}
示例4: applyFloatingAnimation
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public void applyFloatingAnimation(@NonNull final FloatingTextView view) {
Spring scaleAnim = createSpringByBouncinessAndSpeed(10, 15)
.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(@NonNull Spring spring) {
float transition = transition((float) spring.getCurrentValue(), 0.0f, 1.0f);
view.setScaleX(transition);
view.setScaleY(transition);
}
});
ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);
alphaAnimator.setDuration(duration);
alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(@NonNull ValueAnimator valueAnimator) {
view.setAlpha((Float) valueAnimator.getAnimatedValue());
}
});
scaleAnim.setEndValue(1f);
alphaAnimator.start();
}
示例5: togglePosition
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void togglePosition() {
double d = PathListView.NO_ZOOM;
double currentValue = this.mRevealerSpring.getEndValue();
Spring spring = this.mRevealerSpring;
if (currentValue == PathListView.NO_ZOOM) {
d = 0.0d;
}
spring.setEndValue(d);
}
示例6: animBottom
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void animBottom(Spring spring, boolean toOpen) {
if (isOpened) {
spring.setCurrentValue(mView.getHeight());
}
spring.setEndValue(toOpen ? 0 : mView.getHeight());
}
示例7: animTop
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void animTop(Spring spring, boolean toOpen) {
if (isOpened) {
spring.setCurrentValue(-mView.getHeight());
}
spring.setEndValue(toOpen ? 0 : -mView.getHeight());
}
示例8: createCircle
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private static void createCircle(Context context, ViewGroup rootView,
SpringSystem springSystem,
SpringConfig coasting,
SpringConfig gravity,
int diameter,
Drawable backgroundDrawable) {
final Spring xSpring = springSystem.createSpring().setSpringConfig(coasting);
final Spring ySpring = springSystem.createSpring().setSpringConfig(gravity);
// create view
View view = new View(context);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(diameter, diameter);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
view.setLayoutParams(params);
view.setBackgroundDrawable(backgroundDrawable);
rootView.addView(view);
// generate random direction and magnitude
double magnitude = Math.random() * 1000 + 3000;
double angle = Math.random() * Math.PI / 2 + Math.PI / 4;
xSpring.setVelocity(magnitude * Math.cos(angle));
ySpring.setVelocity(-magnitude * Math.sin(angle));
int maxX = rootView.getMeasuredWidth() / 2 + diameter;
xSpring.addListener(new Destroyer(rootView, view, -maxX, maxX));
int maxY = rootView.getMeasuredHeight() / 2 + diameter;
ySpring.addListener(new Destroyer(rootView, view, -maxY, maxY));
xSpring.addListener(new Performer(view, View.TRANSLATION_X));
ySpring.addListener(new Performer(view, View.TRANSLATION_Y));
// set a different end value to cause the animation to play
xSpring.setEndValue(2);
ySpring.setEndValue(9001);
}
示例9: onCreateView
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mRootView = (RelativeLayout) inflater.inflate(R.layout.fragment_flower, container, false);
mCircles = new View[6];
mCircle = mRootView.findViewById(R.id.circle);
final float diameter = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DIAMETER,
getResources().getDisplayMetrics());
final TypedArray circles = getResources().obtainTypedArray(R.array.circles);
// layout params
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) diameter,
(int) diameter);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
// create the circle views
int colorIndex = 0;
for (int i = 0; i < mCircles.length; i++) {
mCircles[i] = new View(getActivity());
mCircles[i].setLayoutParams(params);
mCircles[i].setBackgroundDrawable(getResources().getDrawable(
circles.getResourceId(colorIndex, -1)));
colorIndex++;
if (colorIndex >= circles.length()) {
colorIndex = 0;
}
mRootView.addView(mCircles[i], 0);
}
circles.recycle();
/* Animations! */
final SpringSystem springSystem = SpringSystem.create();
// create spring
final Spring spring = springSystem.createSpring();
// add listeners along arc
final double arc = 2 * Math.PI / mCircles.length;
for (int i = 0; i < mCircles.length; i++) {
View view = mCircles[i];
// map spring to a line segment from the center to the edge of the ring
spring.addListener(new MapPerformer(view, View.TRANSLATION_X, 0, 1,
0, (float) (RING_DIAMETER * Math.cos(i * arc))));
spring.addListener(new MapPerformer(view, View.TRANSLATION_Y, 0, 1,
0, (float) (RING_DIAMETER * Math.sin(i * arc))));
spring.setEndValue(CLOSED);
}
final ToggleImitator imitator = new ToggleImitator(spring, CLOSED, OPEN);
// move circle using finger, snap when near another circle, and bloom when touched
new Actor.Builder(SpringSystem.create(), mCircle)
.addMotion(new SnapImitator(MotionProperty.X), View.TRANSLATION_X)
.addMotion(new SnapImitator(MotionProperty.Y), View.TRANSLATION_Y)
.onTouchListener(imitator)
.build();
return mRootView;
}
示例10: onCreateView
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mRootView = (RelativeLayout) inflater.inflate(R.layout.fragment_bloom, container, false);
mCircles = new View[6];
float diameter = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DIAMETER,
getResources().getDisplayMetrics());
final TypedArray circles = getResources().obtainTypedArray(R.array.circles);
// layout params
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) diameter,
(int) diameter);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
// create the circle views
int colorIndex = 0;
for (int i = 0; i < mCircles.length; i++) {
mCircles[i] = new View(getActivity());
mCircles[i].setLayoutParams(params);
mCircles[i].setBackgroundDrawable(getResources().getDrawable(circles
.getResourceId(colorIndex, -1)));
colorIndex++;
if (colorIndex >= circles.length()) {
colorIndex = 0;
}
mRootView.addView(mCircles[i]);
}
circles.recycle();
/* Animations! */
final SpringSystem springSystem = SpringSystem.create();
// create spring
final Spring spring = springSystem.createSpring();
// add listeners along arc
double arc = 2 * Math.PI / mCircles.length;
for (int i = 0; i < mCircles.length; i++) {
View view = mCircles[i];
// map spring to a line segment from the center to the edge of the ring
spring.addListener(new MapPerformer(view, View.TRANSLATION_X, 0, 1,
0, (float) (RING_DIAMETER * Math.cos(i * arc))));
spring.addListener(new MapPerformer(view, View.TRANSLATION_Y, 0, 1,
0, (float) (RING_DIAMETER * Math.sin(i * arc))));
spring.setEndValue(CLOSED);
}
mRootView.setOnTouchListener(new ToggleImitator(spring, CLOSED, OPEN));
return mRootView;
}
示例11: onSpringUpdate
import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public void onSpringUpdate(ChatHead activeChatHead, boolean isDragging, int maxWidth, int maxHeight, Spring spring, Spring activeHorizontalSpring, Spring activeVerticalSpring, int totalVelocity) {
/** Bounds Check **/
if (spring == activeHorizontalSpring && !isDragging) {
double xPosition = activeHorizontalSpring.getCurrentValue();
if (xPosition + manager.getConfig().getHeadWidth() > maxWidth && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
if (xPosition < 0 && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
} else if (spring == activeVerticalSpring && !isDragging) {
double yPosition = activeVerticalSpring.getCurrentValue();
if (yPosition + manager.getConfig().getHeadHeight() > maxHeight && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
if (yPosition < 0 && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.NOT_DRAGGING && !activeHorizontalSpring.isOvershooting()) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
}
/** position it back **/
if (!isDragging && totalVelocity < MIN_VELOCITY_TO_POSITION_BACK && activeHorizontalSpring.getSpringConfig() == SpringConfigsHolder.DRAGGING) {
positionToOriginal(activeChatHead, activeHorizontalSpring, activeVerticalSpring);
}
if (activeChatHead == currentChatHead)
showOrHideView(activeChatHead);
if (!isDragging) {
/** Capturing check **/
int[] coords = manager.getChatHeadCoordsForCloseButton(activeChatHead);
double distanceCloseButtonFromHead = manager.getDistanceCloseButtonFromHead((float) activeHorizontalSpring.getCurrentValue() + manager.getConfig().getHeadWidth() / 2, (float) activeVerticalSpring.getCurrentValue() + manager.getConfig().getHeadHeight() / 2);
if (distanceCloseButtonFromHead < activeChatHead.CLOSE_ATTRACTION_THRESHOLD && activeHorizontalSpring.getSpringConfig() == SpringConfigsHolder.DRAGGING && activeVerticalSpring.getSpringConfig() == SpringConfigsHolder.DRAGGING && !activeChatHead.isSticky()) {
activeHorizontalSpring.setSpringConfig(SpringConfigsHolder.NOT_DRAGGING);
activeVerticalSpring.setSpringConfig(SpringConfigsHolder.NOT_DRAGGING);
activeChatHead.setState(ChatHead.State.CAPTURED);
}
if (activeChatHead.getState() == ChatHead.State.CAPTURED && activeHorizontalSpring.getSpringConfig() != SpringConfigsHolder.CAPTURING) {
activeHorizontalSpring.setAtRest();
activeVerticalSpring.setAtRest();
activeHorizontalSpring.setSpringConfig(SpringConfigsHolder.CAPTURING);
activeVerticalSpring.setSpringConfig(SpringConfigsHolder.CAPTURING);
activeHorizontalSpring.setEndValue(coords[0]);
activeVerticalSpring.setEndValue(coords[1]);
}
if (activeChatHead.getState() == ChatHead.State.CAPTURED && activeVerticalSpring.isAtRest()) {
manager.getCloseButton().disappear(false, true);
manager.captureChatHeads(activeChatHead);
}
if (!activeVerticalSpring.isAtRest() && !isTransitioning) {
manager.getCloseButton().appear();
} else {
manager.getCloseButton().disappear(true, true);
}
}
}