Example usage for android.view.animation LinearInterpolator LinearInterpolator

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

Introduction

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

Prototype

public LinearInterpolator() 

Source Link

Usage

From source file:com.example.piechart3d.PieChart3DView.java

@Override
protected void onAttachedToWindow() {
    // TODO Auto-generated method stub
    super.onAttachedToWindow();

    ObjectAnimator mXAnimator = ObjectAnimator.ofFloat(mRenderer, "angle_x", 0, maxX);
    mXAnimator.setDuration(2000);/*from w w  w .ja v  a 2 s  .  c om*/

    mXAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationCancel(final Animator animation) {
        }

        @Override
        public void onAnimationEnd(final Animator animation) {
            // progressBar.setProgress(progress);
        }

        @Override
        public void onAnimationRepeat(final Animator animation) {
        }

        @Override
        public void onAnimationStart(final Animator animation) {
        }
    });
    mXAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(final ValueAnimator animation) {

        }
    });
    LinearInterpolator di = new LinearInterpolator();
    mXAnimator.setInterpolator(di);
    mXAnimator.start();
}

From source file:io.github.runassudo.ptoffline.ui.LocationGpsView.java

public void activateGPS() {
    if (searching)
        return;/*from www  .j a v  a2 s.  c  o  m*/

    // check permissions
    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
                Manifest.permission.ACCESS_FINE_LOCATION)) {
            Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
        } else {
            // No explanation needed, we can request the permission
            ActivityCompat.requestPermissions(activity,
                    new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, caller);
        }

        return;
    }

    searching = true;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {
        locationManager.removeUpdates(this);
        Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        // Set the flag that there is currently no active search. Otherwise the App won't
        // allow new searches even after GPS has been reenabled, because the app "hangs" in
        // a semistate where searching = true but now real search is active.
        searching = false;
        return;
    }

    // clear input
    setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.startAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    if (gpsListener != null)
        gpsListener.activateGPS();
}

From source file:com.andremion.music.MusicCoverView.java

public MusicCoverView(Context context, AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MusicCoverView);
    @Shape/*from   ww  w  . j  av a  2s  .co m*/
    int shape = a.getInt(R.styleable.MusicCoverView_shape, SHAPE_SQUARE);
    @ColorInt
    int trackColor = a.getColor(R.styleable.MusicCoverView_trackColor, TRACK_COLOR);
    a.recycle();

    // TODO: Canvas.clipPath works wrong when running with hardware acceleration on Android N
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
    }

    final float density = getResources().getDisplayMetrics().density;
    mTrackSize = TRACK_SIZE * density;
    mTrackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTrackPaint.setStyle(Paint.Style.STROKE);
    mTrackPaint.setStrokeWidth(TRACK_WIDTH * density);

    mDiscPaintCenterDecor = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDiscPaintCenterDecor.setStyle(Paint.Style.FILL);
    mDiscPaintCenter = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDiscPaintCenter.setStyle(Paint.Style.FILL);

    setShape(shape);
    setTrackColor(trackColor);
    if (getDrawable() != null && ((BitmapDrawable) getDrawable()).getBitmap() != null) {
        setCenterColor(DISC_CENTER_COLOR, Palette.generate(((BitmapDrawable) getDrawable()).getBitmap(), 32)
                .getLightVibrantColor(DISC_CENTER_DECOR_COLOR));
    } else {
        setCenterColor(DISC_CENTER_COLOR, DISC_CENTER_DECOR_COLOR);
    }
    setScaleType();

    mStartRotateAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, 0, FULL_ANGLE);
    mStartRotateAnimator.setInterpolator(new LinearInterpolator());
    if (SHAPE_SQUARE == mShape) {
        mStartRotateAnimator.setDuration(DURATION_SQUARE);
    } else {
        mStartRotateAnimator.setDuration(DURATION);
        mStartRotateAnimator.setRepeatCount(Animation.INFINITE);
    }

    mStartRotateAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            float current = getRotation();
            float target = current > HALF_ANGLE ? FULL_ANGLE : 0; // Choose the shortest distance to 0 rotation
            float diff = target > 0 ? FULL_ANGLE - current : current;
            mEndRotateAnimator.setFloatValues(current, target);
            if (SHAPE_SQUARE == mShape) {
                mEndRotateAnimator.setDuration((int) (DURATION_SQUARE_PER_DEGREES * diff));
            } else {
                mEndRotateAnimator.setDuration((int) (DURATION_PER_DEGREES * diff));
            }

            mEndRotateAnimator.start();
        }
    });

    mEndRotateAnimator = ObjectAnimator.ofFloat(MusicCoverView.this, View.ROTATION, 0);
    mEndRotateAnimator.setInterpolator(new LinearInterpolator());
    mEndRotateAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setRotation(0);
            // isRunning method return true if it's called form here.
            // So we need call from post method to get the right returning.
            post(new Runnable() {
                @Override
                public void run() {
                    if (mCallbacks != null) {
                        mCallbacks.onRotateEnd(MusicCoverView.this);
                    }
                }
            });
        }
    });

    mRectToCircleTransition = new MorphTransition(SHAPE_RECTANGLE);
    mRectToCircleTransition.addTarget(this);
    mRectToCircleTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_CIRCLE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });

    mCircleToRectTransition = new MorphTransition(SHAPE_CIRCLE);
    mCircleToRectTransition.addTarget(this);
    mCircleToRectTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_RECTANGLE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });

    mSquareToSquareTransition = new MorphTransition(SHAPE_SQUARE);
    mSquareToSquareTransition.addTarget(this);
    mSquareToSquareTransition.addListener(new TransitionAdapter() {
        @Override
        public void onTransitionStart(Transition transition) {
            mIsMorphing = true;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mIsMorphing = false;
            mShape = SHAPE_SQUARE;
            if (mCallbacks != null) {
                mCallbacks.onMorphEnd(MusicCoverView.this);
            }
        }
    });
}

From source file:de.grobox.liberario.locations.LocationGpsView.java

public void activateGPS() {
    if (searching)
        return;/*from  w ww  .jav a 2s .  c o m*/

    // check permissions
    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        /*         if(ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION)) {
                    Toast.makeText(getContext(), R.string.permission_denied_gps, Toast.LENGTH_LONG).show();
                 } else {
                    // No explanation needed, we can request the permission
                    ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, caller);
                 }
        */
        return;
    }

    searching = true;

    List<String> providers = locationManager.getProviders(true);

    for (String provider : providers) {
        // Register the listener with the Location Manager to receive location updates
        locationManager.requestSingleUpdate(provider, this, null);

        Log.d(getClass().getSimpleName(), "Register provider for location updates: " + provider);
    }

    // check if there is a non-passive provider available
    if (providers.size() == 0
            || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) {
        locationManager.removeUpdates(this);
        Toast.makeText(getContext(), getContext().getString(R.string.error_no_location_provider),
                Toast.LENGTH_LONG).show();

        // Set the flag that there is currently no active search. Otherwise the App won't
        // allow new searches even after GPS has been reenabled, because the app "hangs" in
        // a semistate where searching = true but now real search is active.
        searching = false;
        return;
    }

    // clear input
    setLocation(null, TransportrUtils.getTintedDrawable(getContext(), R.drawable.ic_gps));
    ui.clear.setVisibility(View.VISIBLE);

    // clear current GPS location, because we are looking to find a new one
    gps_location = null;

    // show GPS button blinking
    final Animation animation = new AlphaAnimation(1, 0);
    animation.setDuration(500);
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    ui.status.startAnimation(animation);

    ui.location.setHint(R.string.stations_searching_position);
    ui.location.clearFocus();

    if (gpsListener != null)
        gpsListener.activateGPS();
}

From source file:com.arsy.maps_library.MapRipple.java

private void startAnimation(final int numberOfRipple) {
    ValueAnimator animator = ValueAnimator.ofInt(0, (int) mDistance);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setRepeatMode(ValueAnimator.RESTART);
    animator.setDuration(mRippleDuration);
    animator.setEvaluator(new IntEvaluator());
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from w  w w  . jav a2s  .c  o  m*/
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int animated = (int) valueAnimator.getAnimatedValue();
            mGroundOverlays[numberOfRipple].setDimensions(animated);
            if (mDistance - animated <= 10) {
                if (mLatLng != mPrevLatLng) {
                    mGroundOverlays[numberOfRipple].setPosition(mLatLng);
                }
            }
        }
    });
    animator.start();
    mAnimators[numberOfRipple] = animator;
}

From source file:com.telenav.expandablepager.SlidingContainer.java

/**
 * Convenience method, uses FastOutSlowInInterpolator and default animation duration. See {@link SlidingContainer#animate(float, int, Interpolator)}
 * @param amount translationY amount/*from ww  w . ja  va 2  s  .  c  o m*/
 */
private void animate(float amount) {
    animate(amount, duration, new LinearInterpolator());
}

From source file:com.example.map.BasicMapActivity.java

public void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) {
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    Projection proj = mMap.getProjection();
    Point startPoint = proj.toScreenLocation(marker.getPosition());
    final LatLng startLatLng = proj.fromScreenLocation(startPoint);
    final long duration = 500;

    final Interpolator interpolator = new LinearInterpolator();

    handler.post(new Runnable() {
        @Override/* www  .  jav  a  2  s . co  m*/
        public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed / duration);
            double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude;
            double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude;
            marker.setPosition(new LatLng(lat, lng));

            if (t < 1.0) {
                // Post again 16ms later.
                handler.postDelayed(this, 16);
            } else {
                if (hideMarker) {
                    marker.setVisible(false);
                } else {
                    marker.setVisible(true);
                }
            }
        }
    });
}

From source file:com.haibin.calendarview.CalendarView.java

public void showSelectLayout(final int year) {
    mLinearWeek.animate().translationY(-mLinearWeek.getHeight()).setInterpolator(new LinearInterpolator())
            .setDuration(180).setListener(new AnimatorListenerAdapter() {
                @Override//from  w  w  w.j  av a  2 s .  c o  m
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mLinearWeek.setVisibility(GONE);
                    mSelectLayout.setVisibility(VISIBLE);
                    mSelectLayout.init(year);
                }
            });
    mViewPager.animate().scaleX(0).scaleY(0).setDuration(180).setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mViewPager.setVisibility(GONE);
                }
            });
}

From source file:it.chefacile.app.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContext = this;
    chefacileDb = new DatabaseHelper(this);
    // FilterButton = (ImageButton) findViewById(R.id.buttonfilter);
    TutorialButton = (ImageButton) findViewById(R.id.button);
    //  AddButton = (ImageButton) findViewById(R.id.button2);
    responseView = (TextView) findViewById(R.id.responseView);
    editText = (EditText) findViewById(R.id.ingredientText);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    //Show = (ImageButton) findViewById(R.id.buttonShow);
    //Show2 = (ImageButton) findViewById(R.id.buttonShow2);
    materialAnimatedSwitch = (MaterialAnimatedSwitch) findViewById(R.id.pin);
    //buttoncuisine = (ImageButton) findViewById(R.id.btn_cuisine);
    //buttondiet = (ImageButton) findViewById(R.id.btn_diet);
    //buttonintol = (ImageButton) findViewById(R.id.btn_intoll);
    //Mostra = (Button) findViewById(R.id.btn_mostra);

    final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    animation.setDuration(1000); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(5); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE);

    ImageView icon = new ImageView(this); // Create an icon
    icon.setImageDrawable(getResources().getDrawable(R.drawable.logo));

    final com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton actionButton = new com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.Builder(
            this).setPosition(
                    com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.POSITION_RIGHT_CENTER)
                    .setContentView(icon).build();

    SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);
    // repeat many times:
    ImageView dietIcon = new ImageView(this);
    dietIcon.setImageDrawable(getResources().getDrawable(R.drawable.diet));
    SubActionButton button1 = itemBuilder.setContentView(dietIcon).build();
    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showSingleChoiceDialogDiet(v);
        }//from w  w  w. j av  a 2  s.c  om
    });

    ImageView intolIcon = new ImageView(this);
    intolIcon.setImageDrawable(getResources().getDrawable(R.drawable.intoll));
    SubActionButton button2 = itemBuilder.setContentView(intolIcon).build();
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showMultiChoiceDialogIntol(v);
        }
    });

    ImageView cuisineIcon = new ImageView(this);
    cuisineIcon.setImageDrawable(getResources().getDrawable(R.drawable.cook12));
    SubActionButton button3 = itemBuilder.setContentView(cuisineIcon).build();
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showMultiChoiceDialogCuisine(v);
        }
    });

    ImageView favouriteIcon = new ImageView(this);
    favouriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.favorite));
    SubActionButton button4 = itemBuilder.setContentView(favouriteIcon).build();
    button4.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showSimpleListDialogFav(v);
        }
    });

    ImageView wandIcon = new ImageView(this);
    wandIcon.setImageDrawable(getResources().getDrawable(R.drawable.wand));
    SubActionButton button5 = itemBuilder.setContentView(wandIcon).build();
    button5.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            sugg = getSuggestion();
            suggOccurrences = getCount();
            showSimpleListDialogSuggestions(v);
        }
    });

    final FloatingActionButton actionABC = (FloatingActionButton) findViewById(R.id.action_abc);

    actionABC.bringToFront();
    actionABC.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (ingredients.length() < 2) {
                Snackbar.make(responseView, "Insert at least one ingredient", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            } else {
                new RetrieveFeedTask().execute();
            }
        }

        // Snackbar.make(view, "Non disponibile, mangia l'aria", Snackbar.LENGTH_LONG)
        //         .setAction("Action", null).show();

    });

    FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this).setStartAngle(90).setEndAngle(270)
            .addSubActionView(button1).addSubActionView(button2).addSubActionView(button3)
            .addSubActionView(button4).addSubActionView(button5).attachTo(actionButton).build();

    startDatabase(chefacileDb);

    for (int j = 0; j < cuisineItems.length; j++) {
        cuisineItems[j] = cuisineItems[j].substring(0, 1).toUpperCase() + cuisineItems[j].substring(1);
    }
    Arrays.sort(cuisineItems);

    for (int i = 0; i < 24; i++) {
        cuisineBool[i] = false;
    }

    Arrays.sort(intolItems);

    for (int i = 0; i < 11; i++) {
        intolBool[i] = false;
    }

    mListView = (MaterialListView) findViewById(R.id.material_listview);

    adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);

    TutorialButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, IntroScreenActivity.class));
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

        }
    });

    iv = (ImageView) findViewById(R.id.imageView);
    iv.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            clicks++;
            Log.d("CLICKS", String.valueOf(clicks));
            if (clicks == 15) {
                Log.d("IMAGE SHOWN", "mai vero");
                setBackground(iv);
            }
        }
    });

    materialAnimatedSwitch.setOnCheckedChangeListener(new MaterialAnimatedSwitch.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(boolean isChecked) {
            if (isChecked == true) {
                ranking = 2;
                Toast.makeText(getApplicationContext(), "Minimize missing ingredients", Toast.LENGTH_SHORT)
                        .show();
            } else {
                ranking = 1;
                Toast.makeText(getApplicationContext(), "Maximize used ingredients", Toast.LENGTH_SHORT).show();
            }
            Log.d("Ranking", String.valueOf(ranking));
        }
    });

    final CharSequence[] items = { "Maximize used ingredients", "Minimize missing ingredients" };

    editText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    if (!(editText.getText().toString().trim().equals(""))) {

                        String input;
                        String s1 = editText.getText().toString().substring(0, 1).toUpperCase();
                        String s2 = editText.getText().toString().substring(1);
                        input = s1 + s2;

                        Log.d("INPUT: ", input);
                        searchedIngredients.add(input);
                        Log.d("SEARCHED INGR LIST", searchedIngredients.toString());

                        if (!chefacileDb.findIngredientPREF(input)) {
                            if (chefacileDb.findIngredient(input)) {
                                chefacileDb.updateCount(input);
                                mapIngredients = chefacileDb.getDataInMapIngredient();
                                Map<String, Integer> map2;
                                map2 = sortByValue(mapIngredients);
                                Log.d("MAPPACOUNT: ", map2.toString());

                            } else {
                                if (chefacileDb.occursExceeded()) {
                                    //chefacileDb.deleteMinimum(input);
                                    // chefacileDb.insertDataIngredient(input);
                                    mapIngredients = chefacileDb.getDataInMapIngredient();
                                    Map<String, Integer> map3;
                                    map3 = sortByValue(mapIngredients);
                                    Log.d("MAPPAINGREDIENTE: ", map3.toString());

                                } else {
                                    chefacileDb.insertDataIngredient(input);
                                    mapIngredients = chefacileDb.getDataInMapIngredient();
                                    Map<String, Integer> map3;
                                    map3 = sortByValue(mapIngredients);
                                    Log.d("MAPPAINGREDIENTE: ", map3.toString());
                                }
                            }
                        }
                    }

                    if (editText.getText().toString().trim().equals("")) {
                        ingredients += editText.getText().toString().trim() + "";
                        editText.getText().clear();

                    } else {
                        ingredients += editText.getText().toString().replaceAll(" ", "+").trim().toLowerCase()
                                + ",";
                        singleIngredient = editText.getText().toString().trim().toLowerCase();
                        currentIngredient = singleIngredient;
                        new RetrieveIngredientTask().execute();

                        //adapter.add(singleIngredient.substring(0,1).toUpperCase() + singleIngredient.substring(1));
                    }

                    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

                    in.hideSoftInputFromWindow(editText.getApplicationWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);

                    actionABC.startAnimation(animation);

                    return true;
                default:
                    break;
                }
            }
            return false;
        }
    });

    responseView = (TextView) findViewById(R.id.responseView);
    editText = (EditText) findViewById(R.id.ingredientText);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);

}

From source file:com.lovejjfg.arsenal.ui.widget.JumpBall.java

private void init() {
    if (mPaint == null) {
        mPaint = new Paint();
        mPaint.setAntiAlias(true);//from   www .j a  va 2 s . c  o  m
        mPaint.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    }

    if (mPath == null) {
        mPath = new Path();
    }

    pullAnimator = ValueAnimator.ofInt(0, pullRange, 0);
    pullAnimator.setDuration((long) (dropTime * 0.5f));
    pullAnimator.addUpdateListener(animation -> {
        mChange = (Integer) animation.getAnimatedValue();
        if (animation.getAnimatedFraction() > 0.3) {
            dropAnimator.setIntValues(dropHeight, 0, dropHeight);
            dropAnimator.setDuration(dropTime * 2);
            dropAnimator.start();
        }
        Log.e("TAG", "onAnimationUpdate: " + mChange);
        invalidate();
    });

    pullAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {

        }
    });

    dropAnimator = ValueAnimator.ofInt(0, dropHeight);
    //        dropAnimator.setRepeatMode(ValueAnimator.REVERSE);
    //        dropAnimator.setRepeatCount(20);
    dropAnimator.setDuration(dropTime);
    dropAnimator.setInterpolator(new LinearInterpolator());
    dropAnimator.addUpdateListener(animation -> {
        mTranslateValue = (Integer) animation.getAnimatedValue();
        invalidate();
    });

    dropAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            //                dropAnimator = ValueAnimator.ofInt(dropHeight, 0, dropHeight);
            pullAnimator.start();
        }
    });
    dropAnimator.start();

    radioAnimator = ValueAnimator.ofFloat(mCircleRadius, mWidth);
    //        radioAnimator.setRepeatMode(ValueAnimator.REVERSE);
    //        radioAnimator.setRepeatCount(20);
    radioAnimator.setDuration(600);
    radioAnimator.setInterpolator(new LinearInterpolator());
    radioAnimator.addUpdateListener(animation -> {
        mCurrentRadio = (float) animation.getAnimatedValue();
        invalidate();
    });

    radioAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            pullAnimator.cancel();
            dropAnimator.cancel();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            isEnd = false;
            mCurrentRadio = mCircleRadius;
            if (dismissListener != null) {
                dismissListener.onDismiss();
            }
            setVisibility(GONE);

        }
    });
    //        radioAnimator.start();
}