Search in sources :

Example 1 with Slider

use of com.google.android.glass.widget.Slider 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;
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) Scroller(com.google.android.glass.widget.Slider.Scroller) Slider(com.google.android.glass.widget.Slider) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Determinate(com.google.android.glass.widget.Slider.Determinate)

Aggregations

Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 Slider (com.google.android.glass.widget.Slider)1 Determinate (com.google.android.glass.widget.Slider.Determinate)1 Scroller (com.google.android.glass.widget.Slider.Scroller)1