com.facebook.rebound.SpringConfig Java Examples

The following examples show how to use com.facebook.rebound.SpringConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FragmentLogin.java    From Pixiv-Shaft with MIT License 6 votes vote down vote up
@Override
void initData() {
    if (Local.getBoolean(Params.SHOW_DIALOG, true)) {
        Common.createDialog(mContext);
    }
    rotate = springSystem.createSpring();
    rotate.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(15, 8));

    //使两个cardview高度,大小保持一致
    baseBind.cardLogin.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final int height = baseBind.cardLogin.getHeight();

            ViewGroup.LayoutParams paramsSign = baseBind.cardSign.getLayoutParams();
            paramsSign.height = height;
            baseBind.cardSign.setLayoutParams(paramsSign);

            baseBind.cardLogin.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
}
 
Example #2
Source File: ToggleButton.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
public void setup(AttributeSet attrs) {
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setStrokeCap(Cap.ROUND);
	
	springSystem = SpringSystem.create();
	spring = springSystem.createSpring();
	spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));
	
	this.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			toggle();
		}
	});
	
	TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.ToggleButton_offBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.ToggleButton_onColor, onColor);
	spotColor = typedArray.getColor(R.styleable.ToggleButton_spotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.ToggleButton_offColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_borderWidth, borderWidth);
	typedArray.recycle();
}
 
Example #3
Source File: SpringConfiguratorView.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
 
Example #4
Source File: Magnet.java    From Magnet with MIT License 6 votes vote down vote up
protected void initializeMotionPhysics() {
  SpringConfig config = getSpringConfig();
  SpringSystem springSystem = getSpringSystem();
  xSpring = createXSpring(springSystem, config);
  ySpring = createYSpring(springSystem, config);
  motionImitatorX =
      new MagnetImitator(MotionProperty.X, Imitator.TRACK_ABSOLUTE, Imitator.FOLLOW_SPRING, 0, 0);
  motionImitatorY =
      new MagnetImitator(MotionProperty.Y, Imitator.TRACK_ABSOLUTE, Imitator.FOLLOW_SPRING, 0, 0);
  xWindowManagerPerformer = new WindowManagerPerformer(MotionProperty.X);
  yWindowManagerPerformer = new WindowManagerPerformer(MotionProperty.Y);
  actor = new Actor.Builder(springSystem, iconView).addMotion(xSpring, motionImitatorX,
      xWindowManagerPerformer)
      .addMotion(ySpring, motionImitatorY, yWindowManagerPerformer)
      .onTouchListener(this)
      .build();
  iconView.getViewTreeObserver().addOnGlobalLayoutListener(this);
}
 
Example #5
Source File: BonusAnimationActivity.java    From AndroidPlayground with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bonus_animation);
    ButterKnife.bind(this);
    mScaleSpring = mSpringSystem.createSpring();
    mScaleSpring.addListener(mBonusMsgSpringListener);
    mScaleSpring.setCurrentValue(0.07);
    mScaleSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(QC_TENSION,
            QC_FRICTION));

    new Thread(new Runnable() {
        @Override
        public void run() {
            mBonusAnimationView.initResources(BonusAnimationActivity.this);
        }
    }).start();
}
 
Example #6
Source File: SpringConfiguratorView.java    From KugouLayout with MIT License 6 votes vote down vote up
/**
 * reload the springs from the registry and update the UI
 */
public void refreshSpringConfigurations() {
  Map<SpringConfig, String> springConfigMap = springConfigRegistry.getAllSpringConfig();

  spinnerAdapter.clear();
  mSpringConfigs.clear();

  for (Map.Entry<SpringConfig, String> entry : springConfigMap.entrySet()) {
    if (entry.getKey() == SpringConfig.defaultConfig) {
      continue;
    }
    mSpringConfigs.add(entry.getKey());
    spinnerAdapter.add(entry.getValue());
  }
  // Add the default config in last.
  mSpringConfigs.add(SpringConfig.defaultConfig);
  spinnerAdapter.add(springConfigMap.get(SpringConfig.defaultConfig));
  spinnerAdapter.notifyDataSetChanged();
  if (mSpringConfigs.size() > 0) {
    mSpringSelectorSpinner.setSelection(0);
  }
}
 
Example #7
Source File: YOLOComboView.java    From RxComboDetector with MIT License 6 votes vote down vote up
public YOLOComboView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    BaseSpringSystem springSystem = SpringSystem.create();
    mComboSpring = springSystem.createSpring();
    mComboSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(600, 9));

    mYOLOLogo = new ImageView(context);
    FrameLayout.LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    mYOLOLogo.setLayoutParams(params);
    mYOLOLogo.setImageResource(R.drawable.ic_yolo);
    addView(mYOLOLogo);

    mComboText = new TextView(context);
    params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT);
    params.rightMargin = 30;
    mComboText.setLayoutParams(params);
    mComboText.setTextColor(context.getResources().getColor(android.R.color.holo_red_light));
    mComboText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    addView(mComboText);

    mSpringListener = new ComboSpringListener(mComboText);
    setAlpha(0);
}
 
Example #8
Source File: SwitchButton.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void setup(AttributeSet attrs) {
    this.paint = new Paint(1);
    this.paint.setStyle(Style.STROKE);
    this.paint.setStrokeCap(Cap.ROUND);
    this.springSystem = SpringSystem.create();
    this.spring = this.springSystem.createSpring();
    this.spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50.0d, 7.0d));
    setOnClickListener(new OnClickListener() {
        public void onClick(View arg0) {
            SwitchButton.this.onViewSwitch();
        }
    });
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SwitchButton);
    this.onSpotColor = typedArray.getColor(R.styleable.SwitchButton_onColor, this.onSpotColor);
    this.offSpotColor = typedArray.getColor(R.styleable.SwitchButton_spotColor, this.offSpotColor);
    this.toggleOn = typedArray.getBoolean(R.styleable.SwitchButton_onToggle, this.toggleOn);
    this.spotColor = this.offSpotColor;
    this.borderWidth = typedArray.getDimensionPixelSize(R.styleable.SwitchButton_borderWidth, (int) AbViewUtil.dip2px(getContext(), (float) this.borderWidth));
    this.defaultAnimate = typedArray.getBoolean(R.styleable.SwitchButton_animate, this.defaultAnimate);
    typedArray.recycle();
}
 
Example #9
Source File: ExplosionFragment.java    From Backboard with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: ExplosionFragment.java    From Backboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	mHandler = new Handler();
	mSpringSystem = SpringSystem.create();

	mCoasting = SpringConfig.fromOrigamiTensionAndFriction(0, 0);
	mCoasting.tension = 0;

	// this is very much a hack, since the end value is set to 9001 to simulate constant
	// acceleration.
	mGravity = SpringConfig.fromOrigamiTensionAndFriction(0, 0);
	mGravity.tension = 1;
}
 
Example #11
Source File: SpringConfiguratorView.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * update the position of the seekbars based on the spring value;
 * @param springConfig current editing spring
 */
private void updateSeekBarsForSpringConfig(SpringConfig springConfig) {
  float tension = (float) OrigamiValueConverter.origamiValueFromTension(springConfig.tension);
  float tensionRange = MAX_TENSION - MIN_TENSION;
  int scaledTension = Math.round(((tension - MIN_TENSION) * MAX_SEEKBAR_VAL) / tensionRange);

  float friction = (float) OrigamiValueConverter.origamiValueFromFriction(springConfig.friction);
  float frictionRange = MAX_FRICTION - MIN_FRICTION;
  int scaledFriction = Math.round(((friction - MIN_FRICTION) * MAX_SEEKBAR_VAL) / frictionRange);

  mTensionSeekBar.setProgress(scaledTension);
  mFrictionSeekBar.setProgress(scaledFriction);
}
 
Example #12
Source File: SpringConfiguratorView.java    From KugouLayout with MIT License 5 votes vote down vote up
/**
 * update the position of the seekbars based on the spring value;
 * @param springConfig current editing spring
 */
private void updateSeekBarsForSpringConfig(SpringConfig springConfig) {
  float tension = (float) OrigamiValueConverter.origamiValueFromTension(springConfig.tension);
  float tensionRange = MAX_TENSION - MIN_TENSION;
  int scaledTension = Math.round(((tension - MIN_TENSION) * MAX_SEEKBAR_VAL) / tensionRange);

  float friction = (float) OrigamiValueConverter.origamiValueFromFriction(springConfig.friction);
  float frictionRange = MAX_FRICTION - MIN_FRICTION;
  int scaledFriction = Math.round(((friction - MIN_FRICTION) * MAX_SEEKBAR_VAL) / frictionRange);

  mTensionSeekBar.setProgress(scaledTension);
  mFrictionSeekBar.setProgress(scaledFriction);
}
 
Example #13
Source File: DraggerView.java    From Dragger with Apache License 2.0 5 votes vote down vote up
/**
 * The global default {@link Spring} instance.
 *
 * This instance is automatically initialized with defaults that are suitable to most
 * implementations.
 *
 */
private Spring getSpring() {
  if (singleton == null) {
    synchronized (Spring.class) {
      if (singleton == null) {
        singleton = SpringSystem
            .create()
            .createSpring()
            .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(tension, friction));
      }
    }
  }
  return singleton;
}
 
Example #14
Source File: PrismActivity.java    From PrismView with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new Instance of moveSpring if it's needed.
 * @return Instance of moveSpring.
 */
private Spring moveSpring() {

  SpringConfig springConfig = null;
  if (springType == SpringType.ORIGAMI) {
    if (isValuesNotSet()) {
      firstValue = DEFAULT_TENSION;
      secondValue = DEFAULT_FRICTION;
    }
    springConfig = SpringConfig.fromOrigamiTensionAndFriction(firstValue, secondValue);
  } else if (springType == SpringType.SPEEDBOUNCINESS) {
    if (isValuesNotSet()) {
      firstValue = DEFAULT_BOUNCENESS;
      secondValue = DEFAULT_SPEED;
    }
    springConfig = SpringConfig.fromBouncinessAndSpeed(firstValue, secondValue);
  }

  if (moveSpring == null) {
    if (springConfig != null) {
      moveSpring = SpringSystem.create().createSpring().setSpringConfig(springConfig);
    }
  } else {
    moveSpring.setSpringConfig(springConfig);
  }
  return moveSpring;
}
 
Example #15
Source File: SpringHelper.java    From FloatingView with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: ToggleButton.java    From ToggleButton with MIT License 5 votes vote down vote up
public void setup(AttributeSet attrs) {
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setStrokeCap(Cap.ROUND);
	
	springSystem = SpringSystem.create();
	spring = springSystem.createSpring();
	spring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(50, 7));
	
	this.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View arg0) {
			toggle(defaultAnimate);
		}
	});
	
	TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ToggleButton);
	offBorderColor = typedArray.getColor(R.styleable.ToggleButton_tbOffBorderColor, offBorderColor);
	onColor = typedArray.getColor(R.styleable.ToggleButton_tbOnColor, onColor);
	spotColor = typedArray.getColor(R.styleable.ToggleButton_tbSpotColor, spotColor);
	offColor = typedArray.getColor(R.styleable.ToggleButton_tbOffColor, offColor);
	borderWidth = typedArray.getDimensionPixelSize(R.styleable.ToggleButton_tbBorderWidth, borderWidth);
	defaultAnimate = typedArray.getBoolean(R.styleable.ToggleButton_tbAnimate, defaultAnimate);
	isDefaultOn = typedArray.getBoolean(R.styleable.ToggleButton_tbAsDefaultOn, isDefaultOn);
	typedArray.recycle();
	
	borderColor = offBorderColor;

	if (isDefaultOn) {
		toggleOn();
	}
}
 
Example #17
Source File: Magnet.java    From Magnet with MIT License 5 votes vote down vote up
public Magnet(Context context) {
  this.context = context;
  orientationChangeReceiver = new OrientationChangeReceiver();
  windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  removeView = new RemoveView(context);
  goToWallVelocity = pxFromDp(700);
  flingVelocityMinimum = pxFromDp(400);
  restVelocity = pxFromDp(100);
  springConfig = SpringConfig.fromBouncinessAndSpeed(1, 20);
}
 
Example #18
Source File: MainActivity.java    From JPSpringMenu with MIT License 5 votes vote down vote up
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    if (seekBar == mTensionbar) {
        mTvTension.setText("Tension:" + progress);
    } else {
        mTvFriction.setText("Fricsion:" + progress);
    }
    mSpringMenu.setMenuSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(mTensionbar.getProgress(), mFrictionBar.getProgress()));
}
 
Example #19
Source File: Magnet.java    From Magnet with MIT License 4 votes vote down vote up
/**
 * Set the configuration for the springs used by this magnet.
 */
public Builder<T> withSpringConfig(@NonNull SpringConfig springConfig) {
  magnet.springConfig = springConfig;
  return this;
}
 
Example #20
Source File: MainActivity.java    From JPSpringMenu with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTitleBar = (TitleBar) findViewById(R.id.title_bar);
    mRgFade = (RadioGroup) findViewById(R.id.rg_enablefade);
    mFrictionBar = (SeekBar) findViewById(R.id.sb_friction);
    mTensionbar = (SeekBar) findViewById(R.id.sb_tension);
    mTvFriction = (TextView) findViewById(R.id.tv_friction);
    mTvTension = (TextView) findViewById(R.id.tv_tension);
    mIvIgnore = (ImageView) findViewById(R.id.iv_ignore);
    mRgFade.setOnCheckedChangeListener(this);
    mTensionbar.setOnSeekBarChangeListener(this);
    mFrictionBar.setOnSeekBarChangeListener(this);
    mFrictionBar.setMax(100);
    mTensionbar.setMax(100);
    //init SpringMenu
    mSpringMenu = new SpringMenu(this, R.layout.view_menu);
    mSpringMenu.setMenuListener(this);
    mSpringMenu.setFadeEnable(true);
    mSpringMenu.setChildSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(20, 5));
    mSpringMenu.setDragOffset(0.4f);
    mSpringMenu.addIgnoredView(mFrictionBar
    );
    mSpringMenu.addIgnoredView(mTensionbar);
    // init titlebar
    mTitleBar.setLeftText("Left");
    mTitleBar.setTitle(R.string.app_name);
    mTitleBar.setBackgroundColor(Color.parseColor("#64b4ff"));
    mTitleBar.setDividerColor(Color.GRAY);
    mTitleBar.setTitleColor(Color.WHITE);
    mTitleBar.setLeftTextColor(Color.WHITE);
    mTitleBar.setActionTextColor(Color.WHITE);
    mTitleBar.setLeftClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mSpringMenu.setDirection(SpringMenu.DIRECTION_LEFT);
            mSpringMenu.openMenu();
        }
    });
    mTitleBar.addAction(new TitleBar.Action() {
        @Override
        public String getText() {
            return "Right";
        }

        @Override
        public int getDrawable() {
            return 0;
        }

        @Override
        public void performAction(View view) {
            mSpringMenu.setDirection(SpringMenu.DIRECTION_RIGHT);
            mSpringMenu.openMenu();
        }
    });

    ListBean[] listBeen = {new ListBean(R.mipmap.menu5, "Option One"), new ListBean(R.mipmap.menu1, "Option Two"), new ListBean(R.mipmap.menu2, "Option Three"), new ListBean(R.mipmap.menu3, "Option Four"), new ListBean(R.mipmap.menu4, "Option Five")};
    MyAdapter adapter = new MyAdapter(this, listBeen);
    ListView listView = (ListView) mSpringMenu.findViewById(R.id.test_listView);
    listView.setAdapter(adapter);

    mFrictionBar.setProgress(3);
    mTensionbar.setProgress(20);

    mSpringMenu.addIgnoredView(mIvIgnore);

}
 
Example #21
Source File: MagnetTest.java    From Magnet with MIT License 4 votes vote down vote up
@Before public void setUp() throws Exception {
  final Display displayMock = mock(Display.class);
  final Resources resourcesMock = mock(Resources.class);
  final Context contextMock = mock(Context.class);
  final ViewTreeObserver viewTreeObserverMock = mock(ViewTreeObserver.class);
  final SpringConfig config = SpringConfig.fromBouncinessAndSpeed(1, 20);
  displayMetricsMock = mock(DisplayMetrics.class);
  displayMetricsMock.widthPixels = initialX;
  displayMetricsMock.heightPixels = initialY;
  removeViewMock = mock(RemoveView.class);
  buttonMock = mock(View.class);
  windowManagerMock = mock(WindowManager.class);
  iconCallbackMock = mock(IconCallback.class);
  iconViewMock = mock(ImageView.class);
  paramsMock = mock(LayoutParams.class);
  mockXSpring = mock(Spring.class);
  mockYSpring = mock(Spring.class);

  doReturn(viewTreeObserverMock).when(iconViewMock).getViewTreeObserver();
  doReturn(windowManagerMock).when(contextMock).getSystemService(Context.WINDOW_SERVICE);
  doReturn(displayMetricsMock).when(resourcesMock).getDisplayMetrics();
  doReturn(displayMock).when(windowManagerMock).getDefaultDisplay();
  doReturn(resourcesMock).when(contextMock).getResources();
  setInternalState(removeViewMock, "button", buttonMock);
  whenNew(RemoveView.class).withArguments(contextMock).thenReturn(removeViewMock);
  whenNew(DisplayMetrics.class).withNoArguments().thenReturn(displayMetricsMock);
  whenNew(WindowManager.LayoutParams.class).withAnyArguments().thenReturn(paramsMock);
  doReturn(config).when(mockXSpring).getSpringConfig();
  doReturn(config).when(mockYSpring).getSpringConfig();

  Magnet instance = Magnet.newBuilder(contextMock).setIconView(iconViewMock)
      .setIconCallback(iconCallbackMock)
      .setRemoveIconResId(R.drawable.ic_close)
      .setRemoveIconShadow(R.drawable.bottom_shadow)
      .setShouldStickToWall(true)
      .setRemoveIconShouldBeResponsive(true)
      .setInitialPosition(initialX, initialY)
      .setIconWidth(iconWidth)
      .setIconHeight(iconHeight)
      .build();
  magnet = spy(instance);

  doReturn(mockXSpring).when(magnet).createXSpring(any(SpringSystem.class), any(SpringConfig.class));
  doReturn(mockYSpring).when(magnet).createYSpring(any(SpringSystem.class), any(SpringConfig.class));

  setInternalState(magnet, "layoutParams", paramsMock);
}
 
Example #22
Source File: Magnet.java    From Magnet with MIT License 4 votes vote down vote up
protected Spring createYSpring(SpringSystem springSystem, SpringConfig config) {
  Spring spring = springSystem.createSpring();
  spring.setSpringConfig(config);
  spring.setRestSpeedThreshold(restVelocity);
  return spring;
}
 
Example #23
Source File: Magnet.java    From Magnet with MIT License 4 votes vote down vote up
protected Spring createXSpring(SpringSystem springSystem, SpringConfig config) {
  Spring spring = springSystem.createSpring();
  spring.setSpringConfig(config);
  spring.setRestSpeedThreshold(restVelocity);
  return spring;
}
 
Example #24
Source File: Magnet.java    From Magnet with MIT License 4 votes vote down vote up
@NonNull protected SpringConfig getSpringConfig() {
  return springConfig;
}
 
Example #25
Source File: YumFloating.java    From FloatingView with Apache License 2.0 4 votes vote down vote up
@Override
public Spring createSpringByTensionAndFriction(double tension, double friction) {
    return mSpringSystem.createSpring()
            .setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(tension, friction));
}
 
Example #26
Source File: CountdownAnimationTextView.java    From AndroidPlayground with MIT License 4 votes vote down vote up
public CountdownAnimationTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    BaseSpringSystem springSystem = SpringSystem.create();
    mCountdownSpring = springSystem.createSpring();
    mCountdownSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(600, 9));
}
 
Example #27
Source File: YumFloating.java    From FloatingView with Apache License 2.0 4 votes vote down vote up
@Override
public Spring createSpringByBouncinessAndSpeed(double bounciness, double speed) {
    return mSpringSystem.createSpring()
            .setSpringConfig(SpringConfig.fromBouncinessAndSpeed(bounciness, speed));
}
 
Example #28
Source File: ReboundAnimation.java    From X-Alarm with GNU Affero General Public License v3.0 4 votes vote down vote up
public Spring createSpringFromBouncinessAndSpeed(double bounciness, double speed, SpringListener springListener){
    return mSpringSystem.createSpring().setSpringConfig(
            SpringConfig.fromBouncinessAndSpeed(bounciness,speed))
            .addListener(springListener);
}