Java 类com.facebook.rebound.ui.SpringConfiguratorView 实例源码
项目:test4XXX
文件:OrigamiExample.java
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);
}
项目:Green
文件:OrigamiExample.java
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);
}
项目:rebound
文件:OrigamiExample.java
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);
}