本文整理匯總了Java中com.facebook.rebound.SimpleSpringListener類的典型用法代碼示例。如果您正苦於以下問題:Java SimpleSpringListener類的具體用法?Java SimpleSpringListener怎麽用?Java SimpleSpringListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SimpleSpringListener類屬於com.facebook.rebound包,在下文中一共展示了SimpleSpringListener類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setSpringSystem
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
private void setSpringSystem() {
mSpringSystem = SpringSystem.create();
mSpringsAlpha = mSpringSystem.createSpring()
.setSpringConfig(alphaconfig)
.setCurrentValue(1);
mSpringsAlpha.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring mSpring) {
float value = (float) mSpring.getCurrentValue();
mLockView.setAlpha(value);
}
});
}
示例2: applyFloatingAnimation
import com.facebook.rebound.SimpleSpringListener; //導入依賴的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();
}
示例3: disappear
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public void disappear(boolean immediate, boolean animate) {
ySpring.setEndValue(mParentHeight - centerY + chatHeadManager.getConfig().getCloseButtonHeight());
ySpring.setSpringConfig(SpringConfigsHolder.NOT_DRAGGING);
xSpring.setEndValue(0);
ySpring.addListener(new SimpleSpringListener() {
@Override
public void onSpringAtRest(Spring spring) {
super.onSpringAtRest(spring);
ySpring.removeListener(this);
}
});
scaleSpring.setEndValue(0.1f);
if (!animate) {
ySpring.setCurrentValue(mParentHeight, true);
xSpring.setCurrentValue(0, true);
}
disappeared = true;
if (listener != null) listener.onCloseButtonDisappear();
}
示例4: setMoreViewAnim
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public void setMoreViewAnim(){
/*
其中帶參數的第一個參數表示起主導作用spring的拉力係數,
第二個參數表示起主導作用Spring的摩擦力係數,
第三個和第四個表示附屬的拉力和摩擦力係數
*/
SpringChain springChain = SpringChain.create(40,6,50,7);
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
final View view = viewGroup.getChildAt(i);
springChain.addSpring(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
view.setTranslationY((float) spring.getCurrentValue());
}
});
}
List<Spring> springs = springChain.getAllSprings();
for (int i = 0; i < springs.size(); i++) {
springs.get(i).setCurrentValue(400);
}
springChain.setControlSpringIndex(4).getControlSpring().setEndValue(0);
}
示例5: initializeListeners
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
private void initializeListeners() {
SimpleSpringListener simpleSpringListener = null;
if (prismPosition == PrismPosition.RIGHT) {
simpleSpringListener = translationRight;
} else if (prismPosition == PrismPosition.LEFT) {
simpleSpringListener = translationLeft;
} else if (prismPosition == PrismPosition.TOP) {
simpleSpringListener = translationTop;
} else if (prismPosition == PrismPosition.BOTTOM) {
simpleSpringListener = translationBottom;
}
if (simpleSpringListener != null) {
moveSpring().removeAllListeners().addListener(simpleSpringListener);
}
}
示例6: getFollowerListenerX
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public SimpleSpringListener getFollowerListenerX() {
return followerListenerX;
}
示例7: getFollowerListenerY
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public SimpleSpringListener getFollowerListenerY() {
return followerListenerY;
}
示例8: OrigamiExample
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public OrigamiExample(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Inflate the layout.
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.origami_example, this, false);
addView(root);
// Listen for clicks on the root view.
root.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
handleClick(v);
}
});
// Get references to our views.
mPhotoGrid = root.findViewById(R.id.grid);
mSelectedPhoto = root.findViewById(R.id.selection);
mFeedbackBar = root.findViewById(R.id.feedback);
mSpringConfiguratorView = (SpringConfiguratorView) root.findViewById(R.id.spring_configurator);
// Setup the Spring by creating a SpringSystem adding a SimpleListener that renders the
// animation whenever the spring is updated.
mSpring = SpringSystem
.create()
.createSpring()
.setSpringConfig(ORIGAMI_SPRING_CONFIG)
.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// Just tell the UI to update based on the springs current state.
render();
}
});
// Here we just wait until the first layout pass finishes and call our render method to update
// the animation to the initial resting state of the spring.
mPhotoGrid.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
render();
mPhotoGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
/** Optional - Live Spring Tuning **/
// Put our config into a registry. This is optional, but it gives you the ability to live tune
// the spring using the SpringConfiguratorView which will show up at the bottom of the screen.
SpringConfigRegistry.getInstance().addSpringConfig(ORIGAMI_SPRING_CONFIG, "origami animation spring");
// Tell the SpringConfiguratorView that we've updated the registry to allow you to live tune the animation spring.
mSpringConfiguratorView.refreshSpringConfigurations();
// Uncomment this line to actually show the SpringConfiguratorView allowing you to live tune
// the Spring constants as you manipulate the UI.
mSpringConfiguratorView.setVisibility(View.VISIBLE);
}
示例9: PhotoGalleryExample
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public PhotoGalleryExample(Context context) {
super(context);
int viewCount = ROWS * COLS;
for (int i = 0; i < viewCount; i++) {
final int j = i;
// Create the View.
final ImageView imageView = new ImageView(context);
mImageViews.add(imageView);
addView(imageView);
imageView.setAlpha(0f);
imageView.setBackgroundColor(Util.randomColor());
imageView.setLayerType(LAYER_TYPE_HARDWARE, null);
// Add an image for each view.
int res = getResources().getIdentifier("d" + (i % 11 + 1), "drawable", context.getPackageName());
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(res);
// Add a click listener to handle scaling up the view.
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int endValue = mSpring.getEndValue() == 0 ? 1 : 0;
imageView.bringToFront();
mActiveIndex = j;
mSpring.setEndValue(endValue);
}
});
// Add a spring to the SpringChain to do an entry animation.
mSpringChain.addSpring(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
render();
}
});
}
// Wait for layout.
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
layout();
getViewTreeObserver().removeOnGlobalLayoutListener(this);
postOnAnimationDelayed(new Runnable() {
@Override
public void run() {
mSpringChain.setControlSpringIndex(0).getControlSpring().setEndValue(1);
}
}, 500);
}
});
}
示例10: SpringChainExample
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public SpringChainExample(Context context) {
super(context);
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup container = (ViewGroup) inflater.inflate(R.layout.cascade_effect, this, false);
addView(container);
ViewGroup rootView = (ViewGroup) container.findViewById(R.id.root);
int bgColor = Color.argb(255, 17, 148, 231);
setBackgroundColor(bgColor);
rootView.setBackgroundResource(R.drawable.rebound_tiles);
int startColor = Color.argb(255, 255, 64, 230);
int endColor = Color.argb(255, 255, 230, 64);
ArgbEvaluator evaluator = new ArgbEvaluator();
int viewCount = 10;
for (int i = 0; i < viewCount; i++) {
final View view = new View(context);
view.setLayoutParams(
new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
1f));
mSpringChain.addSpring(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
float value = (float) spring.getCurrentValue();
view.setTranslationX(value);
}
});
int color = (Integer) evaluator.evaluate((float) i / (float) viewCount, startColor, endColor);
view.setBackgroundColor(color);
view.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return handleRowTouch(v, event);
}
});
mViews.add(view);
rootView.addView(view);
}
getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
List<Spring> springs = mSpringChain.getAllSprings();
for (int i = 0; i < springs.size(); i++) {
springs.get(i).setCurrentValue(-mViews.get(i).getWidth());
}
postDelayed(new Runnable() {
@Override
public void run() {
mSpringChain
.setControlSpringIndex(0)
.getControlSpring()
.setEndValue(0);
}
}, 500);
}
});
}
示例11: OrigamiExample
import com.facebook.rebound.SimpleSpringListener; //導入依賴的package包/類
public OrigamiExample(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Inflate the layout.
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.origami_example, this, false);
addView(root);
// Listen for clicks on the root view.
root.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
handleClick(v);
}
});
// Get references to our views.
mPhotoGrid = root.findViewById(R.id.grid);
mSelectedPhoto = root.findViewById(R.id.selection);
mFeedbackBar = root.findViewById(R.id.feedback);
mSpringConfiguratorView = (SpringConfiguratorView) root.findViewById(R.id.spring_configurator);
// Setup the Spring by creating a SpringSystem adding a SimpleListener that renders the
// animation whenever the spring is updated.
mSpring = SpringSystem
.create()
.createSpring()
.setSpringConfig(ORIGAMI_SPRING_CONFIG)
.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
// Just tell the UI to update based on the springs current state.
render();
}
});
// Here we just wait until the first layout pass finishes and call our render method to update
// the animation to the initial resting state of the spring.
mPhotoGrid.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
render();
mPhotoGrid.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
/** Optional - Live Spring Tuning **/
// Put our config into a registry. This is optional, but it gives you the ability to live tune
// the spring using the SpringConfiguratorView which will show up at the bottom of the screen.
SpringConfigRegistry.getInstance().addSpringConfig(ORIGAMI_SPRING_CONFIG, "origami animation spring");
// Tell the SpringConfiguratorView that we've updated the registry to allow you to live tune the animation spring.
mSpringConfiguratorView.refreshSpringConfigurations();
// Uncomment this line to actually show the SpringConfiguratorView allowing you to live tune
// the Spring constants as you manipulate the UI.
mSpringConfiguratorView.setVisibility(View.VISIBLE);
}