List of usage examples for android.view.animation Animation RESTART
int RESTART
To view the source code for android.view.animation Animation RESTART.
Click Source Link
From source file:de.baumann.thema.RequestActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.request_grid); switcherLoad = (ViewSwitcher) findViewById(R.id.viewSwitcherLoadingMain); context = this; android.support.v7.app.ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); }//from w w w .jav a 2 s . c om if (savedInstanceState == null) { //Loading Logo Animation ImageView logo = (ImageView) findViewById(R.id.imageViewLogo); ObjectAnimator logoAni = (ObjectAnimator) AnimatorInflater.loadAnimator(context, R.animator.request_flip); logoAni.setRepeatCount(Animation.INFINITE); logoAni.setRepeatMode(Animation.RESTART); logoAni.setTarget(logo); logoAni.setDuration(2000); logoAni.start(); taskList.execute(); } else { populateView(list_activities_final); switcherLoad.showNext(); } }
From source file:ac.robinson.paperchains.PaperChainsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!CameraUtilities.getIsCameraAvailable(getPackageManager())) { Toast.makeText(PaperChainsActivity.this, getString(R.string.hint_no_camera), Toast.LENGTH_SHORT).show(); finish();//from w w w .j av a 2 s . c o m return; } getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); setViews(R.id.viewfinder_view, R.id.preview_view, R.id.image_view); setResizeImageToView(false); // we want the high quality image setVolumeControlStream(AudioManager.STREAM_MUSIC); // set up action bar ActionBar actionBar = getSupportActionBar(); actionBar.setTitle(R.string.title_activity_capture); actionBar.setDisplayShowTitleEnabled(true); int resultPointColour = getResources().getColor(R.color.accent); ((ViewfinderView) findViewById(R.id.viewfinder_view)).setResultPointColour(resultPointColour); // set up SoundCloud API wrappers (without a user token - for playback only, initially) setupSoundCloudApiWrappers(); mCurrentMode = MODE_CAPTURE; // set up a zoomable view for the photo mImageView = (PaperChainsView) findViewById(R.id.image_view); mZoomControl = new DynamicZoomControl(); mImageView.setZoomState(mZoomControl.getZoomState()); mZoomControl.setAspectQuotient(mImageView.getAspectQuotient()); mZoomListener = new LongPressZoomListener(PaperChainsActivity.this); mZoomListener.setZoomControl(mZoomControl); // set up buttons/handlers mImageView.setOnTouchListener(mZoomListener); mImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onImageClick(); } }); mImageView.setScribbleCallback(new PaperChainsView.ScribbleCallback() { @Override public void scribbleCompleted(Path scribble) { processScribble(scribble); } }); mRecordButton = (AudioRecorderCircleButton) findViewById(R.id.record_button); mRecordButton.setOnClickListener(mRecordButtonListener); mPlayButton = (AudioRecorderCircleButton) findViewById(R.id.play_button); mPlayButton.setOnClickListener(mPlayButtonListener); mDeleteButton = (AudioRecorderCircleButton) findViewById(R.id.delete_button); mDeleteButton.setOnClickListener(mDeleteButtonListener); mSaveButton = (AudioRecorderCircleButton) findViewById(R.id.save_button); mSaveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveAudio(); } }); // set up animation for the play/save buttons mRotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setDuration(BUTTON_ANIMATION_DURATION); mRotateAnimation.setInterpolator(new LinearInterpolator()); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); }
From source file:qr.cloud.qrpedia.MessageViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_message_viewer); // set up tabs and collapse the action bar ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); if (QRCloudUtils.actionBarIsSplit(MessageViewerActivity.this)) { actionBar.setDisplayShowHomeEnabled(false); // TODO: also need to show inverted/rearranged icons }/* w w w .j av a 2 s.c o m*/ // load Google Play Services location client mWaitingForGooglePlayLocation = true; mGooglePlayLocationConnected = false; mLocationClient = new LocationClient(MessageViewerActivity.this, MessageViewerActivity.this, MessageViewerActivity.this); // refresh interval for location queries and load whether location has been updated, and product details mMinimumLocationRefreshWaitTime = getResources().getInteger(R.integer.minimum_location_refresh_time); if (savedInstanceState != null) { mLocationTabEnabled = savedInstanceState.getBoolean(getString(R.string.key_location_tab_visited)); mProductDetails = savedInstanceState.getString(getString(R.string.key_product_details)); double savedLat = savedInstanceState.getDouble(QRCloudUtils.DATABASE_PROP_LATITUDE); double savedLon = savedInstanceState.getDouble(QRCloudUtils.DATABASE_PROP_LONGITUDE); if (savedLat != 0.0d && savedLon != 0.0d) { mLocation = new Location(QRCloudUtils.DATABASE_PROP_GEOCELL); // just need any string to initialise mLocation.setLatitude(savedLat); mLocation.setLongitude(savedLon); } mManualLocationRequestTime = savedInstanceState.getLong(getString(R.string.key_location_request_time)); long currentTime = System.currentTimeMillis(); if (currentTime - mManualLocationRequestTime < LocationRetriever.LOCATION_WAIT_TIME) { // we've started but probably not finished getting the location (manual method) - try again requestManualLocationAndUpdateTab(); } } // get the code hash and details (must be after getting mProductDetails to stop multiple queries) final Intent launchIntent = getIntent(); // Bundle barcodeDetailsBundle = null; if (launchIntent != null) { final String codeContents = launchIntent.getStringExtra(QRCloudUtils.DATABASE_PROP_CONTENTS); if (codeContents != null) { // we need the hash for database lookups mCodeHash = QRCloudUtils.sha1Hash(codeContents); parseCodeDetailsAndUpdate(launchIntent, codeContents, savedInstanceState == null); } } if (mCodeHash == null) { finish(); } // set up animation for the refresh button mRotateAnimation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setDuration(600); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); // set up tab paging mViewPager = (ViewPager) findViewById(R.id.message_sort_pager); mViewPager.setOffscreenPageLimit(3); // tried to save data, but 1 is the minimum - just pre-cache everything // load the tabs (see: http://stackoverflow.com/a/12090317/1993220) mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_clock_inverse), CloudEntityListFragment.class, getSortBundle(CloudEntity.PROP_CREATED_AT), false); mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_location_inverse), CloudEntityListFragment.class, getSortBundle(QRCloudUtils.DATABASE_PROP_GEOCELL), true); mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_star_10_inverse), CloudEntityListFragment.class, getSortBundle(QRCloudUtils.DATABASE_PROP_RATING), false); mTabsAdapter.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_user_inverse), CloudEntityListFragment.class, getFilterBundle(F.Op.EQ.name(), CloudEntity.PROP_CREATED_BY, getCredentialAccountName()), false); // mTabsAdapter // .addTab(actionBar.newTab().setIcon( // mBarcodeFormat == BarcodeFormat.QR_CODE ? R.drawable.ic_action_qrcode_inverse // : R.drawable.ic_action_barcode_inverse), CodeViewerFragment.class, barcodeDetailsBundle); }
From source file:es.uniovi.imovil.fcrtrainer.BaseExerciseFragment.java
/** * Shows an animation when the user taps on the check button. * Currently requires a layout with the id result and an imageview * with the id resultimage. The implementation of this views can be * seen in fragment_hexadecimal.xml// w w w .j a v a2 s . c o m * * @param correct if the answer is correct */ @SuppressLint("NewApi") protected void showAnimationAnswer(boolean correct) { // Fade in - fade out mResult.setVisibility(View.VISIBLE); mAnimation = new AlphaAnimation(0, 1); mAnimation.setDuration(600); mAnimation.setFillBefore(true); mAnimation.setFillAfter(true); mAnimation.setRepeatCount(Animation.RESTART); mAnimation.setRepeatMode(Animation.REVERSE); mResult.startAnimation(mAnimation); if (correct) mResultImage.setImageDrawable(getResources().getDrawable(R.drawable.correct)); else mResultImage.setImageDrawable(getResources().getDrawable(R.drawable.incorrect)); // This only works in API 12+, so we skip this animation on old devices if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) { mResultImage.animate().setDuration(700).setInterpolator(mAntovershoot).scaleX(1.5f).scaleY(1.5f) .withEndAction(new Runnable() { @Override public void run() { // Back to its original size after the animation's end mResultImage.animate().scaleX(1f).scaleY(1f); } }); } }
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);/* w w w. j a v a 2 s. c o 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:com.mobility.android.ui.widget.MaterialProgressDrawable.java
private void setupAnimators() { Ring ring = mRing;/*from w w w . ja v a 2 s . c o m*/ 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; }
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 www.ja v a 2 s .c o 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:com.xfzbd.cqi.widget.srl.ShyaringanProgressDrawable.java
private void setupAnimators() { final Shyaringan ring = mRing; final Animation animation = new Animation() { @Override//from w w w . j a v a2s . co m 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. final float minProgressArc = getMinProgressArc(ring); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final 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 // final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET); // final 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 // final float minArc = MAX_PROGRESS_ARC - minProgressArc; // float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET); // final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); // ring.setEndTrim(endTrim); // } final float rotation = (startingRotation + (500f * interpolatedTime)) % 360f; XLog.e("srl --> rotation - %f - setRotation - shyaringan", rotation); 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) { XLog.e("srl --> refresh 1 - " + System.currentTimeMillis()); 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); } else { mRotationCount = (mRotationCount + 1) % (NUM_POINTS); } } }); mAnimation = animation; }
From source file:com.congxiaoyao.xber_admin.widget.MaterialProgressDrawable.java
private void setupAnimators() { final MaterialProgressDrawable.Ring ring = mRing; final Animation animation = new Animation() { @Override//w w w . j a va 2 s . c o m 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. final float minProgressArc = getMinProgressArc(ring); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final 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 final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET); final 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 final float minArc = MAX_PROGRESS_ARC - minProgressArc; float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET); final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); ring.setEndTrim(endTrim); } final 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; }
From source file:cn.spinsoft.wdq.widget.swipe.MaterialProgressDrawable.java
private void setupAnimators() { final Ring ring = mRing; final Animation animation = new Animation() { @Override//from w w w . j a v a2 s. c o m 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. final float minProgressArc = getMinProgressArc(ring); final float startingEndTrim = ring.getStartingEndTrim(); final float startingTrim = ring.getStartingStartTrim(); final 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 final float scaledTime = (interpolatedTime) / (1.0f - START_TRIM_DURATION_OFFSET); final 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 final float minArc = MAX_PROGRESS_ARC - minProgressArc; float scaledTime = (interpolatedTime - START_TRIM_DURATION_OFFSET) / (1.0f - START_TRIM_DURATION_OFFSET); final float endTrim = startingEndTrim + (minArc * MATERIAL_INTERPOLATOR.getInterpolation(scaledTime)); ring.setEndTrim(endTrim); } final 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; }