Example usage for android.view.animation OvershootInterpolator OvershootInterpolator

List of usage examples for android.view.animation OvershootInterpolator OvershootInterpolator

Introduction

In this page you can find the example usage for android.view.animation OvershootInterpolator OvershootInterpolator.

Prototype

public OvershootInterpolator() 

Source Link

Usage

From source file:com.jaspervanriet.huntingthatproduct.Views.FeedContextMenuManager.java

private void performShowAnimation() {
    contextMenuView.setPivotX(contextMenuView.getWidth() / 2);
    contextMenuView.setPivotY(contextMenuView.getHeight());
    contextMenuView.setScaleX(0.1f);//ww w  .j  av  a2 s  .co  m
    contextMenuView.setScaleY(0.1f);
    contextMenuView.animate().scaleX(1f).scaleY(1f).setDuration(150)
            .setInterpolator(new OvershootInterpolator()).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    isContextMenuShowing = false;
                }
            });
}

From source file:io.apptik.multiview.ScrollersFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (recyclerView == null)
        return false;
    switch (item.getItemId()) {
    case R.id.action_text_only:
        recyclerView.setAdapter(recyclerAdapter);
        break;/* w  w  w. j ava  2  s. c o  m*/
    case R.id.action_image_only:
        break;
    case R.id.action_Image_text:
        recyclerView.setAdapter(recyclerMixedAdapter);
        break;

    case R.id.action_layout_linear:
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        break;
    case R.id.action_layout_grid:
        recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
        break;
    case R.id.action_layout_staggered:
        recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        break;

    case R.id.action_scroll_slow:
        startSmoothScroll(new FlexiSmoothScroller(getContext()).setMillisecondsPerInchSearchingTarget(100f));
        break;
    case R.id.action_scroll_fast:
        startSmoothScroll(new FlexiSmoothScroller(getContext()).setMillisecondsPerInchSearchingTarget(10f));
        break;
    case R.id.action_scroll_snap_center:
        startSmoothScroll(new FlexiSmoothScroller(getContext())
                .setHorizontalSnapPreference(BaseSmoothScroller.SNAP_TO_CENTER)
                .setVerticalSnapPreference(BaseSmoothScroller.SNAP_TO_CENTER));
        break;
    case R.id.action_scroll_overshoot:
        startSmoothScroll(new FlexiSmoothScroller(getContext()).setMillisecondsPerInchFoundTarget(300f)
                .setFoundTargetInterpolator(new OvershootInterpolator()));
        break;
    case R.id.action_scroll_bounce:
        startSmoothScroll(new FlexiSmoothScroller(getContext()).setMillisecondsPerInchFoundTarget(300f)
                .setFoundTargetInterpolator(new BounceInterpolator()));
        break;

    }
    return true;
}

From source file:com.savvasdalkitsis.betwixt.Interpolators.java

/**
 * <strong>ANDROID INTERPOLATOR</strong><br/><br/>
 * An interpolator where the change flings forward and overshoots the last value then comes back.
 *//*from   ww  w . java2 s.  com*/
@NonNull
public static Interpolator overshoot() {
    return new OvershootInterpolator();
}

From source file:com.example.mapdemo.VisibleRegionDemoActivity.java

public void animatePadding(final int toLeft, final int toTop, final int toRight, final int toBottom) {

    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    final long duration = 1000;

    final Interpolator interpolator = new OvershootInterpolator();

    final int startLeft = currentLeft;
    final int startTop = currentTop;
    final int startRight = currentRight;
    final int startBottom = currentBottom;

    currentLeft = toLeft;//from   w  w w .  j a  va 2 s .  com
    currentTop = toTop;
    currentRight = toRight;
    currentBottom = toBottom;

    handler.post(new Runnable() {
        @Override
        public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed / duration);

            int left = (int) (startLeft + ((toLeft - startLeft) * t));
            int top = (int) (startTop + ((toTop - startTop) * t));
            int right = (int) (startRight + ((toRight - startRight) * t));
            int bottom = (int) (startBottom + ((toBottom - startBottom) * t));

            mMap.setPadding(left, top, right, bottom);

            if (elapsed < duration) {
                // Post again 16ms later.
                handler.postDelayed(this, 16);
            }
        }
    });
}

From source file:io.plaidapp.ui.widget.ElasticDragDismissFrameLayout.java

@Override
public void onStopNestedScroll(View child) {
    if (Math.abs(totalDrag) >= dragDismissDistance) {
        dispatchDismissCallback();/*  w  ww .j av a2 s .co  m*/
    } else { // settle back to natural position
        animate().translationY(0f).scaleX(1f).scaleY(1f).setDuration(200L)
                //                    .setInterpolator(AnimationUtils.loadInterpolator(getContext(), android.R
                //                            .interpolator.fast_out_slow_in))
                .setInterpolator(new OvershootInterpolator()).setListener(null).start();
        totalDrag = 0;
        draggingDown = draggingUp = false;
        dispatchDragCallback(0f, 0f, 0f, 0f);
    }
}

From source file:org.shaastra.helper.SuperAwesomeCardFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/* w w w .ja  va  2  s.  com*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    //v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    if (position == 0) {
        View v1 = inflater.inflate(R.layout.event_info, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView t1 = (TextView) v1.findViewById(R.id.infotext);
        t1.setText(eintroduction);
        return v1;
    } else if (position == 1)

    {

        String Venue = new String();
        Venue = evenue;

        final String SAC = elatlong;
        //String start=String.valueOf(l.getLatitude())+String.valueOf(l.getLongitude());
        /*
        View v1=inflater.inflate(R.layout.map, container,false);
        v1.setLayoutParams(params);
        WebView wv=(WebView)v1.findViewById(R.id.wv1);
        wv.setWebChromeClient(new WebChromeClient());
        //wv.loadUrl("https://maps.google.com/maps?saddr=13,80&daddr=13,80.02");
        //wv.loadUrl("http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false");
        wv.loadUrl("http://maps.google.com/maps?f=d&daddr=51.448,-0.972");
        wv.getSettings().getBuiltInZoomControls();
        */
        View v1 = inflater.inflate(R.layout.map, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView location = (TextView) v1.findViewById(R.id.locationText);
        Button mapButton = (Button) v1.findViewById(R.id.mapButton);
        if (evenue.equalsIgnoreCase("NONE")) {
            mapButton.setAlpha(0);
        } else {
            mapButton.setAlpha(1);
        }

        location.setText(Venue);
        mapButton.setOnTouchListener(new View.OnTouchListener() {

            @TargetApi(Build.VERSION_CODES.HONEYCOMB)
            @SuppressLint("NewApi")
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                if (event.getAction() == MotionEvent.ACTION_DOWN) {

                    v.setAlpha((float) 0.4);
                    v.animate().setInterpolator(new DecelerateInterpolator()).scaleX(0.9f).scaleY(0.9f);

                }
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    v.setAlpha((float) 0.75);
                    v.animate().setInterpolator(new OvershootInterpolator()).scaleX(1f).scaleY(1f);

                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://maps.google.com/maps?f=d&daddr=" + SAC));
                    intent.setComponent(new ComponentName("com.google.android.apps.maps",
                            "com.google.android.maps.MapsActivity"));
                    startActivity(intent);
                }

                return false;
            }
        });

        return v1;
    } else if (position == 2) {
        View v1 = inflater.inflate(R.layout.event_info, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView t1 = (TextView) v1.findViewById(R.id.infotext);
        t1.setText(eformat);
        return v1;

    } else if (position == 3) {
        View v1 = inflater.inflate(R.layout.prize, container, false);
        v1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        TextView t1 = (TextView) v1.findViewById(R.id.prizeText);
        t1.setText(eprize);
        return v1;

    } else if (position == 4) {
        v.setBackgroundColor(Color.GREEN);

    } else if (position == 5) {

        v.setBackgroundColor(Color.MAGENTA);

    } else if (position == 6) {
        v.setBackgroundColor(Color.MAGENTA);

    }
    fl.addView(v);
    return fl;

}

From source file:pl.mg6.android.maps.extensions.demo.AnimateMarkersActivity.java

private Interpolator randomInterpolator() {
    int val = random.nextInt(14);
    switch (val) {
    case 0:/*www.  ja v  a 2 s  . c om*/
        return new LinearInterpolator();
    case 1:
        return new AccelerateDecelerateInterpolator();
    case 2:
        return new AccelerateInterpolator();
    case 3:
        return new AccelerateInterpolator(6.0f);
    case 4:
        return new DecelerateInterpolator();
    case 5:
        return new DecelerateInterpolator(6.0f);
    case 6:
        return new BounceInterpolator();
    case 7:
        return new AnticipateOvershootInterpolator();
    case 8:
        return new AnticipateOvershootInterpolator(6.0f);
    case 9:
        return new AnticipateInterpolator();
    case 10:
        return new AnticipateInterpolator(6.0f);
    case 11:
        return new OvershootInterpolator();
    case 12:
        return new OvershootInterpolator(6.0f);
    case 13:
        return new CycleInterpolator(1.25f);
    }
    throw new RuntimeException();
}

From source file:me.hammarstrom.imagerecognition.activities.MainActivity.java

private void convertResponseToString(BatchAnnotateImagesResponse response) {
    Log.d(TAG, ":: " + response.getResponses().toString());
    List<FaceAnnotation> faces = response.getResponses().get(0).getFaceAnnotations();
    List<EntityAnnotation> labels = response.getResponses().get(0).getLabelAnnotations();

    // Label string to be populated with data for TextToSpeech
    String label = "";
    if (labels != null && labels.size() > 0) {
        label = "The image may contain ";
        List<Animator> scoreViewAnimations = new ArrayList<>();
        List<Animator> scoreAlphaAnimations = new ArrayList<>();
        List<Animator> showScoreAnimations = new ArrayList<>();

        for (EntityAnnotation l : labels) {
            if (l.getScore() < 0.6f) {
                continue;
            }//from   w w  w . j a  v  a  2  s .  c om

            // Add label description (ex. laptop, desk, person, etc.)
            label += l.getDescription() + ", ";

            /**
             * Create a new {@link ScoreView} and populate it with label description and score
             */
            ScoreView scoreView = new ScoreView(MainActivity.this);
            int padding = (int) DeviceDimensionsHelper.convertDpToPixel(8, this);
            scoreView.setPadding(padding, padding, padding, padding);
            scoreView.setScore(l.getScore());
            scoreView.setLabelPosition(ScoreView.LABEL_POSITION_RIGHT);
            scoreView.setLabelText(l.getDescription());
            scoreView.setAlpha(0f);
            scoreView.setTranslationX((DeviceDimensionsHelper.getDisplayWidth(this) / 2) * -1);

            // Add ScoreView to result layout
            mScoreResultLayout.addView(scoreView);

            // Create animations to used to show the ScoreView in a nice way
            ObjectAnimator animator = ObjectAnimator.ofFloat(scoreView, "translationX",
                    (DeviceDimensionsHelper.getDisplayWidth(this) / 2) * -1, 0f);
            animator.setInterpolator(new OvershootInterpolator());
            scoreViewAnimations.add(animator);

            ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(scoreView, "alpha", 0f, 1f);
            scoreAlphaAnimations.add(alphaAnimator);

            // Get the animation to show the actual score from ScoreView object
            showScoreAnimations.addAll(scoreView.getShowScoreAnimationsList());
        }

        // Set reset button visibility to visible
        mButtonReset.setVisibility(View.VISIBLE);

        // Setup and play the animations
        AnimatorSet translationSet = new AnimatorSet();
        translationSet.playSequentially(scoreViewAnimations);
        translationSet.setDuration(300);

        AnimatorSet alphaSet = new AnimatorSet();
        alphaSet.playSequentially(scoreAlphaAnimations);
        alphaSet.setDuration(300);

        AnimatorSet showScoreSet = new AnimatorSet();
        showScoreSet.playTogether(showScoreAnimations);

        showLoading(false);

        AnimatorSet set = new AnimatorSet();
        set.play(translationSet).with(alphaSet).before(showScoreSet);
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                mButtonReset.animate().alpha(1f).start();
            }
        });
        set.start();
    } else {
        // Set reset button visibility to visible
        mButtonReset.setVisibility(View.VISIBLE);
        mButtonReset.setAlpha(1f);
    }

    // Handle detected faces
    String facesFound = "";
    if (faces != null && faces.size() > 0) {
        FaceGraphicOverlay faceGraphicOverlay = new FaceGraphicOverlay(MainActivity.this);
        faceGraphicOverlay.addFaces(faces);
        faceGraphicOverlay.setTag("faceOverlay");
        mCameraPreviewLayout.addView(faceGraphicOverlay);

        facesFound = FaceFoundHelper.getFacesFoundString(this, faces);
    }

    // Add the detected image data to TTS engine
    mTts.speak(label, TextToSpeech.QUEUE_FLUSH, null);
    mTts.speak(facesFound, TextToSpeech.QUEUE_ADD, null);
}

From source file:com.saulmm.cui.OrderDialogFragment.java

@NonNull
private Runnable onEnterConfirmScene(LayoutOrderConfirmationBinding confirmationBinding) {
    return () -> {
        ViewCompat.animate(confirmationBinding.txtSubtitle).scaleX(1).scaleY(1)
                .setInterpolator(new OvershootInterpolator()).setStartDelay(200).start();
    };/*from   w  w w.j  a v a 2 s .  c  o  m*/
}

From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java

public void drawFail() {
    mState = State.STATE_FAILED;/*from  w  ww  .  j a  v  a  2 s .  com*/

    ObjectAnimator failAnim = ObjectAnimator.ofFloat(this, "failAngle", 0, 180);
    failAnim.setInterpolator(new OvershootInterpolator());

    //This one doesn't do much actually, we just use it to take advantage of associating two different interpolators
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
    anim.setInterpolator(new AccelerateInterpolator());

    AnimatorSet set = new AnimatorSet();
    set.setDuration((long) (ANIMATION_DURATION_BASE / 1.7f));
    set.playTogether(failAnim, anim);
    set.start();
}