List of usage examples for android.view.animation Animation setRepeatMode
public void setRepeatMode(int repeatMode)
From source file:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java
public Animation getBlinkAnimation() { Animation animation = new AlphaAnimation(1, 0); animation.setDuration(600);/* ww w . ja va 2 s .c o m*/ animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(1); animation.setRepeatMode(Animation.REVERSE); return animation; }
From source file:com.khoahuy.phototag.HomeActivity.java
private void showReady2ScanBlinkText() { TextView myText = (TextView) findViewById(R.id.text_ready2scan); Animation anim = new AlphaAnimation(0.4f, 1.0f); anim.setDuration(200); //You can manage the time of the blink with this parameter anim.setStartOffset(800);/*from w ww .j a v a2s . c o m*/ anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); myText.startAnimation(anim); }
From source file:com.libreteam.driver.Driver_RideOffer.java
private void blinkCountDown() { // MediaPlayer mp = MediaPlayer.create(getActivity(), R.raw.alert); // mp.start(); Animation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(150);//from w w w. j a v a 2 s.c om anim.setStartOffset(120); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); txtCountDown.startAnimation(anim); }
From source file:org.secuso.privacyfriendlydicegame.MainActivity.java
public void hints(int position) { TextView hint = (TextView) findViewById(R.id.initialTextView); TextView initialText = (TextView) findViewById(R.id.initialTextTextView); TextView hint2 = (TextView) findViewById(R.id.initialTextView2); ImageView background = (ImageView) findViewById(R.id.backgroundImageView); Animation anim = new AlphaAnimation(0.0f, 1.0f); if (position == 0) { hint.setVisibility(View.VISIBLE); hint2.setVisibility(View.VISIBLE); background.setVisibility(View.VISIBLE); initialText.setVisibility(View.VISIBLE); anim.setDuration(1000);/*w w w .j av a2 s . co m*/ anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); hint.startAnimation(anim); hint2.startAnimation(anim); } else { hint.clearAnimation(); hint2.clearAnimation(); hint.setVisibility(View.INVISIBLE); hint2.setVisibility(View.INVISIBLE); background.setVisibility(View.INVISIBLE); initialText.setVisibility(View.INVISIBLE); } }
From source file:de.grobox.liberario.DirectionsFragment.java
private void pressGpsButton() { 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); }/*from w w w . j a va 2s.c o m*/ // check if there is a non-passive provider available if (providers.size() == 0 || (providers.size() == 1 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER))) { removeUpdates(); Toast.makeText(getActivity(), getResources().getString(R.string.error_no_location_provider), Toast.LENGTH_LONG).show(); return; } // 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); mView.findViewById(R.id.fromStatusButton).setAnimation(animation); mGpsPressed = true; gps_loc = null; }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * On click image view to start stop recording * //from w w w . j a v a 2 s. co m * Records time SYNCHRONOUSLY * * @param v */ public void onClickSwitchAction(View v) { Drawable drwStart = getResources().getDrawable(R.drawable.play); Drawable drwStop = getResources().getDrawable(R.drawable.stop); LinearLayout lllFrag = (LinearLayout) v.getParent(); LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker); LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus); TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording); ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording); Animation anim = new AlphaAnimation(0.0f, 1.0f); Log.d(CLASSNAME, "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); ImageView iv = (ImageView) v; int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus(); if (currentStatus == ActivitySession.STATUS_STOPPED) { Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED"); iv.setImageDrawable(drwStop); llTimePicker.setVisibility(View.INVISIBLE); anim.setDuration(500); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn(); } else { Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED"); iv.setImageDrawable(drwStart); llTimePicker.setVisibility(View.VISIBLE); anim.setRepeatCount(0); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckOut = new Date().getTime(); long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut(); // Save data into both databases DateUtils du = new DateUtils(); Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional // Save in backend recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS); // Save in local database recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT).show(); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); // ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart); // ivParent.setImageResource(R.drawable.rec_50x); //TextView tvTimeStamp = (TextView) liContent.getChildAt(1); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); } tvRecording.startAnimation(anim); ivRecording.startAnimation(anim); Log.d(CLASSNAME, "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); }
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 a va2 s. c o m }); 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:android.wuliqing.com.mylibrary.header.MaterialProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final Animation finishRingAnimation = new Animation() { public void applyTransformation(float interpolatedTime, Transformation t) { // shrink back down and complete a full rotation before starting other circles // Rotation goes between [0..1]. float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f); final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime; ring.setStartTrim(startTrim); final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime); ring.setRotation(rotation);/*from w w w . j a va 2 s . co m*/ ring.setArrowScale(1 - interpolatedTime); } }; finishRingAnimation.setInterpolator(EASE_INTERPOLATOR); finishRingAnimation.setDuration(ANIMATION_DURATION / 2); finishRingAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { ring.goToNextColor(); ring.storeOriginals(); ring.setShowArrow(false); mParent.startAnimation(mAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); final Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { // The minProgressArc is calculated from 0 to create an angle that // matches the stroke width. final float minProgressArc = (float) Math .toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius())); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); // Offset the minProgressArc to where the endTrim is located. final float minArc = MAX_PROGRESS_ARC - minProgressArc; final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setEndTrim(endTrim); final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setStartTrim(startTrim); final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setDuration(ANIMATION_DURATION); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } }); mFinishAnimation = finishRingAnimation; mAnimation = animation; }
From source file:cn.xiaocool.hongyunschool.view.MaterialProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final Animation finishRingAnimation = new Animation() { public void applyTransformation(float interpolatedTime, Transformation t) { // shrink back down and complete a full rotation before starting // other circles // Rotation goes between [0..1]. float targetRotation = (float) (Math.floor(ring.getStartingRotation() / MAX_PROGRESS_ARC) + 1f); final float startTrim = ring.getStartingStartTrim() + (ring.getStartingEndTrim() - ring.getStartingStartTrim()) * interpolatedTime; ring.setStartTrim(startTrim); final float rotation = ring.getStartingRotation() + ((targetRotation - ring.getStartingRotation()) * interpolatedTime); ring.setRotation(rotation);//from ww w.j av a 2 s .c om ring.setArrowScale(1 - interpolatedTime); } }; finishRingAnimation.setInterpolator(EASE_INTERPOLATOR); finishRingAnimation.setDuration(ANIMATION_DURATION / 2); finishRingAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { ring.goToNextColor(); ring.storeOriginals(); ring.setShowArrow(false); mParent.startAnimation(mAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); final Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { // The minProgressArc is calculated from 0 to create an angle // that // matches the stroke width. final float minProgressArc = (float) Math .toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius())); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final float startingRotation = ring.getStartingRotation(); // Offset the minProgressArc to where the endTrim is located. final float minArc = MAX_PROGRESS_ARC - minProgressArc; final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setEndTrim(endTrim); final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime)); ring.setStartTrim(startTrim); final float rotation = startingRotation + (0.25f * interpolatedTime); ring.setRotation(rotation); float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS)); setRotation(groupRotation); } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setDuration(ANIMATION_DURATION); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } }); mFinishAnimation = finishRingAnimation; mAnimation = animation; }
From source file:com.mobility.android.ui.widget.MaterialProgressDrawable.java
private void setupAnimators() { Ring ring = mRing;/*from w ww . j av a 2s .c om*/ Animation animation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { if (mFinishing) { applyFinishTranslation(interpolatedTime, ring); } else { // The minProgressArc is calculated from 0 to create an // angle that matches the stroke width. float minProgressArc = getMinProgressArc(ring); float startingEndTrim = ring.getStartingEndTrim(); float startingTrim = ring.getStartingStartTrim(); float startingRotation = ring.getStartingRotation(); updateRingColor(interpolatedTime, ring); // Moving the start trim only occurs in the first 50% of a // single ring animation if (interpolatedTime <= START_TRIM_DURATION_OFFSET) { // scale the interpolatedTime so that the full // transformation from 0 - 1 takes place in the // remaining time float scaledTime = interpolatedTime / (1.0f - START_TRIM_DURATION_OFFSET); float startTrim = startingTrim + (MAX_PROGRESS_ARC - minProgressArc) * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime); ring.setStartTrim(startTrim); } // Moving the end trim starts after 50% of a single ring // animation completes if (interpolatedTime > END_TRIM_START_DELAY_OFFSET) { // scale the interpolatedTime so that the full // transformation from 0 - 1 takes place in the // remaining time float minArc = MAX_PROGRESS_ARC - minProgressArc; float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET); float endTrim = startingEndTrim + minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime); ring.setEndTrim(endTrim); } float rotation = startingRotation + 0.25f * interpolatedTime; ring.setRotation(rotation); float groupRotation = FULL_ROTATION / NUM_POINTS * interpolatedTime + FULL_ROTATION * mRotationCount / NUM_POINTS; setRotation(groupRotation); } } }; animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.RESTART); animation.setInterpolator(LINEAR_INTERPOLATOR); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mRotationCount = 0; } @Override public void onAnimationEnd(Animation animation) { // do nothing } @Override public void onAnimationRepeat(Animation animation) { ring.storeOriginals(); ring.goToNextColor(); ring.setStartTrim(ring.getEndTrim()); if (mFinishing) { // finished closing the last ring from the swipe gesture; go // into progress mode mFinishing = false; animation.setDuration(ANIMATION_DURATION); ring.setShowArrow(false); } else { mRotationCount = (mRotationCount + 1) % NUM_POINTS; } } }); mAnimation = animation; }