當前位置: 首頁>>代碼示例>>Java>>正文


Java SpringSystem.createSpring方法代碼示例

本文整理匯總了Java中com.facebook.rebound.SpringSystem.createSpring方法的典型用法代碼示例。如果您正苦於以下問題:Java SpringSystem.createSpring方法的具體用法?Java SpringSystem.createSpring怎麽用?Java SpringSystem.createSpring使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.rebound.SpringSystem的用法示例。


在下文中一共展示了SpringSystem.createSpring方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SpringConfiguratorView

import com.facebook.rebound.SpringSystem; //導入方法依賴的package包/類
@TargetApi(11)
public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mSpringConfigs = new ArrayList();
    this.mTextColor = Color.argb(255, Opcodes.SHR_INT_LIT8, Opcodes.SHR_INT_LIT8, Opcodes
            .SHR_INT_LIT8);
    SpringSystem springSystem = SpringSystem.create();
    this.springConfigRegistry = SpringConfigRegistry.getInstance();
    this.spinnerAdapter = new SpinnerAdapter(context);
    Resources resources = getResources();
    this.mRevealPx = (float) Util.dpToPx(40.0f, resources);
    this.mStashPx = (float) Util.dpToPx(280.0f, resources);
    this.mRevealerSpring = springSystem.createSpring();
    this.mRevealerSpring.setCurrentValue(PathListView.NO_ZOOM).setEndValue(PathListView
            .NO_ZOOM).addListener(new RevealerSpringListener());
    addView(generateHierarchy(context));
    SeekbarListener seekbarListener = new SeekbarListener();
    this.mTensionSeekBar.setMax(MAX_SEEKBAR_VAL);
    this.mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener);
    this.mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL);
    this.mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener);
    this.mSpringSelectorSpinner.setAdapter(this.spinnerAdapter);
    this.mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener());
    refreshSpringConfigurations();
    setTranslationY(this.mStashPx);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:SpringConfiguratorView.java

示例2: applyBloomOpenAnimation

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例3: applyBloomCloseAnimation

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例4: applyPressAnimation

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例5: start

import com.facebook.rebound.SpringSystem; //導入方法依賴的package包/類
public void start(){
    SpringSystem springSystem = SpringSystem.create();
    Spring spring  = springSystem.createSpring();
    if (mConfig == 0){
        spring.setSpringConfig(SpringConfig.fromBouncinessAndSpeed(mConfigValueOne, mConfigValueTwo));
    }else if (mConfig == 1){
        spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(mConfigValueOne, mConfigValueTwo));
    }
    start(spring);
}
 
開發者ID:UFreedom,項目名稱:FloatingView,代碼行數:11,代碼來源:SpringHelper.java

示例6: showLabel

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例7: SpringConfiguratorView

import com.facebook.rebound.SpringSystem; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);

  SpringSystem springSystem = SpringSystem.create();
  springConfigRegistry = SpringConfigRegistry.getInstance();
  spinnerAdapter = new SpinnerAdapter(context);

  Resources resources = getResources();
  mRevealPx = dpToPx(40, resources);
  mStashPx = dpToPx(280, resources);

  mRevealerSpring = springSystem.createSpring();
  SpringListener revealerSpringListener = new RevealerSpringListener();
  mRevealerSpring
      .setCurrentValue(1)
      .setEndValue(1)
      .addListener(revealerSpringListener);

  addView(generateHierarchy(context));

  SeekbarListener seekbarListener = new SeekbarListener();
  mTensionSeekBar.setMax(MAX_SEEKBAR_VAL);
  mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener);

  mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL);
  mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener);

  mSpringSelectorSpinner.setAdapter(spinnerAdapter);
  mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener());
  refreshSpringConfigurations();

  this.setTranslationY(mStashPx);
}
 
開發者ID:xujunbin,項目名稱:FloatWindow,代碼行數:35,代碼來源:SpringConfiguratorView.java

示例8: initializeSpring

import com.facebook.rebound.SpringSystem; //導入方法依賴的package包/類
private static Spring initializeSpring(final View view, final int startTranslationX, final int startTranslationY, boolean overshoot)
{
    view.setTranslationX(startTranslationX);
    view.setTranslationY(startTranslationY);
    view.setVisibility(View.VISIBLE);

    // Create a system to run the physics loop for a set of springs.
    SpringSystem springSystem = SpringSystem.create();

    // Add a spring to the system.
    Spring spring = springSystem.createSpring();
    spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(80, 7));
    spring.setOvershootClampingEnabled(!overshoot);
    return spring;
}
 
開發者ID:bnottingham,項目名稱:springmenu,代碼行數:16,代碼來源:ReboundAnimation.java

示例9: init

import com.facebook.rebound.SpringSystem; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
    if(attrs != null) {
        TypedArray attrArray = context
                .obtainStyledAttributes(attrs, R.styleable.DragLayout);

        for (int i = 0; i < attrArray.getIndexCount(); ++i) {
            int attr = attrArray.getIndex(i);
            if (attr == R.styleable.DragLayout_scale) {
                scale = attrArray.getFloat(attr, DEFAULT_SCALE);

            } else if (attr == R.styleable.DragLayout_springFriction) {
                friction = attrArray.getFloat(attr, DEFAULT_FRICTION);

            } else if (attr == R.styleable.DragLayout_springTension) {
                tension = attrArray.getFloat(attr, DEFAULT_TENSION);

            } else if (attr == R.styleable.DragLayout_intercepting) {
                intercepting = attrArray.getBoolean(attr, DEFAULT_INTERCEPT_TOUCH_EVENT);

            }
        }
        attrArray.recycle();
    }

    setClickable(true);
    setOnTouchListener(this);
    setOnLongClickListener(this);

    SpringSystem springSystem = SpringSystem.create();
    pushSpring = springSystem.createSpring();
    pushSpring.addListener(this);
    pushSpring.setSpringConfig(new SpringConfig(tension, friction));
}
 
開發者ID:maciekjanusz,項目名稱:compass-project,代碼行數:34,代碼來源:DragLayout.java

示例10: SpringConfiguratorView

import com.facebook.rebound.SpringSystem; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public SpringConfiguratorView(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);

  SpringSystem springSystem = SpringSystem.create();
  springConfigRegistry = SpringConfigRegistry.getInstance();
  spinnerAdapter = new SpinnerAdapter(context);

  Resources resources = getResources();
  mRevealPx = dpToPx(40, resources);
  mStashPx = dpToPx(280, resources);

  mRevealerSpring = springSystem.createSpring();
  SpringListener revealerSpringListener = new RevealerSpringListener();
  mRevealerSpring
      .setCurrentValue(1)
      .setEndValue(1)
      .addListener(revealerSpringListener);

  addView(generateHierarchy(context));

  SeekbarListener seekbarListener = new SeekbarListener();
  mTensionSeekBar.setMax(MAX_SEEKBAR_VAL);
  mTensionSeekBar.setOnSeekBarChangeListener(seekbarListener);

  mFrictionSeekBar.setMax(MAX_SEEKBAR_VAL);
  mFrictionSeekBar.setOnSeekBarChangeListener(seekbarListener);

  mSpringSelectorSpinner.setAdapter(spinnerAdapter);
  mSpringSelectorSpinner.setOnItemSelectedListener(new SpringSelectedListener());
  refreshSpringConfigurations();

  //this.setTranslationY(mStashPx);
}
 
開發者ID:ozodrukh,項目名稱:Green,代碼行數:35,代碼來源:SpringConfiguratorView.java

示例11: applyFollowAnimation

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例12: onCreateView

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例13: onCreateView

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例14: onCreateView

import com.facebook.rebound.SpringSystem; //導入方法依賴的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

示例15: onCreateView

import com.facebook.rebound.SpringSystem; //導入方法依賴的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


注:本文中的com.facebook.rebound.SpringSystem.createSpring方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。