use of com.google.android.glass.widget.Slider.Scroller in project gdk-apidemo-sample by googleglass.
the class SliderActivity method processSliderRequest.
/**
* Processes a request to show a slider.
*
* Starting a new Slider, regardless of its type, automatically hides any shown Slider.
*/
private void processSliderRequest(int position) {
switch(position) {
case SCROLLER:
Slider.Scroller scroller = mSlider.startScroller(MAX_SLIDER_VALUE, 0);
// Start an animation showing the different positions of the slider, the slider
// automatically hides after a short time of inactivity.
ObjectAnimator.ofFloat(scroller, "position", 0, MAX_SLIDER_VALUE).setDuration(ANIMATION_DURATION_MILLIS).start();
break;
case DETERMINATE:
final Slider.Determinate determinate = mSlider.startDeterminate(MAX_SLIDER_VALUE, 0);
ObjectAnimator animator = ObjectAnimator.ofFloat(determinate, "position", 0, MAX_SLIDER_VALUE);
// Hide the slider when the animation stops.
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
determinate.hide();
}
});
// Start an animation showing the different positions of the slider.
animator.setDuration(ANIMATION_DURATION_MILLIS).start();
break;
case GRACE_PERIOD:
// Start the grace period slider and play a sound when one of the listener method
// gets fired.
mGracePeriod = mSlider.startGracePeriod(mGracePeriodListener);
break;
case INDETERMINATE:
// Toggle between showing/hiding the indeterminate slider.
if (mIndeterminate != null) {
mIndeterminate.hide();
mIndeterminate = null;
} else {
mIndeterminate = mSlider.startIndeterminate();
}
break;
}
}
Aggregations