@Test public void testGoToWall() { magnet.show(); reset(mockXSpring, mockYSpring); magnet.goToWall(); verify(mockXSpring).setEndValue(anyDouble()); }
public void goToWall() { if (shouldStickToWall && !isGoingToWall) { isGoingToWall = true; iconView.getLocationOnScreen(iconPosition); boolean endX = iconPosition[0] > context.getResources().getDisplayMetrics().widthPixels / 2; float nearestXWall = endX ? xMaxValue : xMinValue; actor.removeAllListeners(); xSpring.setEndValue(nearestXWall); float velocity = iconPosition[0] > nearestXWall ? -goToWallVelocity : goToWallVelocity; if (endX) { xSpring.setVelocity(velocity); } else { xSpring.setVelocity(velocity); } } actor.addAllListeners(); }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { public void goToWall() { if (shouldStickToWall && !isGoingToWall) { isGoingToWall = true; iconView.getLocationOnScreen(iconPosition); boolean endX = iconPosition[0] > context.getResources().getDisplayMetrics().widthPixels / 2; float nearestXWall = endX ? xMaxValue : xMinValue; actor.removeAllListeners(); xSpring.setEndValue(nearestXWall); float velocity = iconPosition[0] > nearestXWall ? -goToWallVelocity : goToWallVelocity; if (endX) { xSpring.setVelocity(velocity); } else { xSpring.setVelocity(velocity); } } actor.addAllListeners(); } }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { public void goToWall() { if (shouldStickToWall && !isGoingToWall) { isGoingToWall = true; iconView.getLocationOnScreen(iconPosition); boolean endX = iconPosition[0] > context.getResources().getDisplayMetrics().widthPixels / 2; float nearestXWall = endX ? xMaxValue : xMinValue; actor.removeAllListeners(); xSpring.setEndValue(nearestXWall); float velocity = iconPosition[0] > nearestXWall ? -goToWallVelocity : goToWallVelocity; if (endX) { xSpring.setVelocity(velocity); } else { xSpring.setVelocity(velocity); } } actor.addAllListeners(); } Magnet(Context context); }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { public void goToWall() { if (shouldStickToWall && !isGoingToWall) { isGoingToWall = true; iconView.getLocationOnScreen(iconPosition); boolean endX = iconPosition[0] > context.getResources().getDisplayMetrics().widthPixels / 2; float nearestXWall = endX ? xMaxValue : xMinValue; actor.removeAllListeners(); xSpring.setEndValue(nearestXWall); float velocity = iconPosition[0] > nearestXWall ? -goToWallVelocity : goToWallVelocity; if (endX) { xSpring.setVelocity(velocity); } else { xSpring.setVelocity(velocity); } } actor.addAllListeners(); } Magnet(Context context); static Builder<Magnet> newBuilder(Context context); void show(); @Deprecated void setPosition(int x, int y, boolean animate); void setPosition(int x, int y); void setIconSize(int width, int height); void goToWall(); void destroy(); @Override void onGlobalLayout(); @Override boolean onTouch(View view, MotionEvent event); @Override void onClick(View view); @Override void onSpringUpdate(Spring spring); @Override void onSpringAtRest(Spring spring); @Override void onSpringActivate(Spring spring); @Override void onSpringEndStateChange(Spring spring); }
Magnet implements View.OnTouchListener, View.OnClickListener, ViewTreeObserver.OnGlobalLayoutListener,
    SpringListener { public void goToWall() { if (shouldStickToWall && !isGoingToWall) { isGoingToWall = true; iconView.getLocationOnScreen(iconPosition); boolean endX = iconPosition[0] > context.getResources().getDisplayMetrics().widthPixels / 2; float nearestXWall = endX ? xMaxValue : xMinValue; actor.removeAllListeners(); xSpring.setEndValue(nearestXWall); float velocity = iconPosition[0] > nearestXWall ? -goToWallVelocity : goToWallVelocity; if (endX) { xSpring.setVelocity(velocity); } else { xSpring.setVelocity(velocity); } } actor.addAllListeners(); } Magnet(Context context); static Builder<Magnet> newBuilder(Context context); void show(); @Deprecated void setPosition(int x, int y, boolean animate); void setPosition(int x, int y); void setIconSize(int width, int height); void goToWall(); void destroy(); @Override void onGlobalLayout(); @Override boolean onTouch(View view, MotionEvent event); @Override void onClick(View view); @Override void onSpringUpdate(Spring spring); @Override void onSpringAtRest(Spring spring); @Override void onSpringActivate(Spring spring); @Override void onSpringEndStateChange(Spring spring);  }