当前位置: 首页>>代码示例>>Java>>正文


Java Spring.addListener方法代码示例

本文整理汇总了Java中com.facebook.rebound.Spring.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java Spring.addListener方法的具体用法?Java Spring.addListener怎么用?Java Spring.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.rebound.Spring的用法示例。


在下文中一共展示了Spring.addListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:tiancaiCC,项目名称:SpringFloatingActionMenu,代码行数:19,代码来源:SpringFloatingActionMenu.java

示例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);
    }
}
 
开发者ID:tiancaiCC,项目名称:SpringFloatingActionMenu,代码行数:19,代码来源:SpringFloatingActionMenu.java

示例3: applyPressAnimation

import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void applyPressAnimation() {
    SpringSystem springSystem = SpringSystem.create();
    final Spring spring = springSystem.createSpring();
    spring.addListener(new Performer(mBtn, View.SCALE_X));
    spring.addListener(new Performer(mBtn, View.SCALE_Y));
    mBtn.setOnTouchListener(new ToggleImitator(spring, 1, 1.2){
        @Override
        public void imitate(MotionEvent event) {
            super.imitate(event);
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    break;

                case MotionEvent.ACTION_UP:
                    callOnClick();
                    break;

                default:
            }
        }
    });
    spring.setCurrentValue(1);
}
 
开发者ID:tiancaiCC,项目名称:SpringFloatingActionMenu,代码行数:24,代码来源:MenuItemView.java

示例4: 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 );
	}
}
 
开发者ID:melvinjlobo,项目名称:SpiderMenu,代码行数:27,代码来源:SpiderMenu.java

示例5: showLabel

import com.facebook.rebound.Spring; //导入方法依赖的package包/类
public void showLabel() {
    SpringSystem springSystem = SpringSystem.create();
    final Spring spring = springSystem.createSpring();
    spring.addListener(new MapPerformer(mLabel, View.SCALE_X, 0, 1));
    spring.addListener(new MapPerformer(mLabel, View.SCALE_Y, 0, 1));
    spring.setCurrentValue(0);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            spring.setEndValue(1);
        }
    }, 200);
}
 
开发者ID:tiancaiCC,项目名称:SpringFloatingActionMenu,代码行数:14,代码来源:MenuItemView.java

示例6: 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);
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:41,代码来源:ExplosionFragment.java

示例7: applyFollowAnimation

import com.facebook.rebound.Spring; //导入方法依赖的package包/类
private void applyFollowAnimation() {
    /* Animation code */

    final SpringSystem springSystem = SpringSystem.create();

    // create the springs that control movement
    final Spring springX = springSystem.createSpring();
    final Spring springY = springSystem.createSpring();

    // bind circle movement to events
    new Actor.Builder(springSystem, mFAB)
            .addMotion(springX, Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.X)
            .addMotion(springY, Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.Y)
            .build();

    // add springs to connect between the views
    final Spring[] followsX = new Spring[mMenuItemCount];
    final Spring[] followsY = new Spring[mMenuItemCount];

    for (int i = 0; i < mFollowCircles.size(); i++) {

        // create spring to bind views
        followsX[i] = springSystem.createSpring();
        followsY[i] = springSystem.createSpring();
        followsX[i].addListener(new Performer(mFollowCircles.get(i), View.TRANSLATION_X));
        followsY[i].addListener(new Performer(mFollowCircles.get(i), View.TRANSLATION_Y));

        // imitates another character
        final SpringImitator followX = new SpringImitator(followsX[i]);
        final SpringImitator followY = new SpringImitator(followsY[i]);

        //  imitate the previous character
        if (i == 0) {
            springX.addListener(followX);
            springY.addListener(followY);
        } else {
            followsX[i - 1].addListener(followX);
            followsY[i - 1].addListener(followY);
        }
    }
}
 
开发者ID:tiancaiCC,项目名称:SpringFloatingActionMenu,代码行数:42,代码来源:SpringFloatingActionMenu.java

示例8: onCreateView

import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
	mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_follow, container, false);

	mCircle = mRootView.findViewById(R.id.circle);

	FrameLayout.LayoutParams leaderParams = (FrameLayout.LayoutParams) mCircle
			.getLayoutParams();

	mFollowers = new View[4];

	float diameter = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DIAMETER,
			getResources().getDisplayMetrics());

	TypedArray circles = getResources().obtainTypedArray(R.array.circles);

	// create the circle views
	int colorIndex = 1;
	for (int i = 0; i < mFollowers.length; i++) {
		mFollowers[i] = new View(getActivity());

		FrameLayout.LayoutParams params =
				new FrameLayout.LayoutParams((int) diameter, (int) diameter);
		params.gravity = leaderParams.gravity;
		mFollowers[i].setLayoutParams(params);

		mFollowers[i].setBackgroundDrawable(getResources().getDrawable(
				circles.getResourceId(colorIndex, -1)));

		colorIndex++;
		if (colorIndex >= circles.length()) {
			colorIndex = 0;
		}

		mRootView.addView(mFollowers[i]);
	}

	circles.recycle();

	/* Animation code */

	final SpringSystem springSystem = SpringSystem.create();

	// create the springs that control movement
	final Spring springX = springSystem.createSpring();
	final Spring springY = springSystem.createSpring();

	// bind circle movement to events
	new Actor.Builder(springSystem, mCircle).addMotion(springX, MotionProperty.X)
			.addMotion(springY, MotionProperty.Y).build();

	// add springs to connect between the views
	final Spring[] followsX = new Spring[mFollowers.length];
	final Spring[] followsY = new Spring[mFollowers.length];

	for (int i = 0; i < mFollowers.length; i++) {

		// create spring to bind views
		followsX[i] = springSystem.createSpring();
		followsY[i] = springSystem.createSpring();
		followsX[i].addListener(new Performer(mFollowers[i], View.TRANSLATION_X));
		followsY[i].addListener(new Performer(mFollowers[i], View.TRANSLATION_Y));

		// imitates another character
		final SpringImitator followX = new SpringImitator(followsX[i]);
		final SpringImitator followY = new SpringImitator(followsY[i]);

		//  imitate the previous character
		if (i == 0) {
			springX.addListener(followX);
			springY.addListener(followY);
		} else {
			followsX[i - 1].addListener(followX);
			followsY[i - 1].addListener(followY);
		}
	}

	return mRootView;
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:81,代码来源:FollowFragment.java

示例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;
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:74,代码来源:FlowerFragment.java

示例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;
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:65,代码来源:BloomFragment.java

示例11: onCreateView

import com.facebook.rebound.Spring; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
	final View rootView = inflater.inflate(R.layout.fragment_scale, container, false);

	final View rect = rootView.findViewById(R.id.rect);

	final SpringSystem springSystem = SpringSystem.create();

	final Spring spring = springSystem.createSpring();

	spring.addListener(new Performer(rect, View.SCALE_X));
	spring.addListener(new Performer(rect, View.SCALE_Y));

	rootView.setOnTouchListener(new View.OnTouchListener() {
		@Override
		@SuppressLint("ClickableViewAccessibility")
		public boolean onTouch(View v, MotionEvent event) {
			switch (event.getAction()) {
			case MotionEvent.ACTION_DOWN:
				spring.setVelocity(0);

			case MotionEvent.ACTION_MOVE:

				// can't use Imitation here because there is no nice mapping from
				// an event property to a Spring
				float scaleX, scaleY;

				float delta = event.getX() - (rect.getX() + rect.getMeasuredWidth() / 2);
				scaleX = Math.abs(delta) / (rect.getMeasuredWidth() / 2);

				delta = event.getY() - (rect.getY() + rect.getMeasuredHeight() / 2);
				scaleY = Math.abs(delta) / (rect.getMeasuredHeight() / 2);

				float scale = Math.max(scaleX, scaleY);

				spring.setEndValue(scale);

				break;
			case MotionEvent.ACTION_UP:
				spring.setEndValue(1f);

				break;
			}

			return true;
		}
	});

	return rootView;
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:52,代码来源:ScaleFragment.java

示例12: setSpring

import com.facebook.rebound.Spring; //导入方法依赖的package包/类
/**
 * Sets the {@link com.facebook.rebound.Spring} that this imitator should use. This class
 * attaches itself as a {@link com.facebook.rebound.SpringListener} and stores the
 * {@link com.facebook.rebound.SpringConfig} to use when the user is dragging.
 *
 * @param spring
 * 		the spring to use
 */
@Override
public void setSpring(@NonNull final Spring spring) {
	super.setSpring(spring);
	spring.addListener(this);

	mOriginalConfig = spring.getSpringConfig();
}
 
开发者ID:tumblr,项目名称:Backboard,代码行数:16,代码来源:InertialImitator.java


注:本文中的com.facebook.rebound.Spring.addListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。