Java Code Examples for android.view.animation.Animation#setRepeatMode()
The following examples show how to use
android.view.animation.Animation#setRepeatMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FakeLoadingWithLogoView.java From CommonUtils with Apache License 2.0 | 6 votes |
public void animateTo(int duration, float to, @NonNull Interpolator interpolator, boolean repeatInfinite, @Nullable Animation.AnimationListener listener) { float startFrom = percentage; float toGo = to - startFrom; Animation anim = new Animation() { { setInterpolator(interpolator); setDuration(duration); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { setPercentage(startFrom + interpolatedTime * toGo); } }; if (repeatInfinite) { anim.setRepeatCount(Animation.INFINITE); anim.setRepeatMode(Animation.RESTART); } else { anim.setRepeatCount(0); } anim.setAnimationListener(listener); startAnimationInternal(anim); }
Example 2
Source File: BridgeActivity.java From Android-Bridge-App with MIT License | 6 votes |
private void setupUpdateService() { if (isInternalVersion()) { updateAvailableReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { btnInstallUpdate.setVisibility(View.VISIBLE); Animation mAnimation = new AlphaAnimation(1, 0); mAnimation.setDuration(200); mAnimation.setInterpolator(new LinearInterpolator()); mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.REVERSE); btnInstallUpdate.startAnimation(mAnimation); } }; updateAvailableFilter = new IntentFilter(getResources().getString(R.string.intent_filter_update_available)); bridgeUpdateService = new BridgeUpdateService(); bridgeServiceIntent = new Intent(this, bridgeUpdateService.getClass()); if (!isMyServiceRunning(bridgeUpdateService.getClass())) { startService(bridgeServiceIntent); } } }
Example 3
Source File: BaseActivity.java From timecat with Apache License 2.0 | 6 votes |
@SuppressLint("NewApi") public void showRefreshAnimation(MenuItem item) { hideRefreshAnimation(); refreshItem = item; //这里使用一个ImageView设置成MenuItem的ActionView,这样我们就可以使用这个ImageView显示旋转动画了 ImageView refreshActionView = (ImageView) getLayoutInflater().inflate(R.layout.action_view, null); refreshActionView.setImageResource(R.drawable.ic_autorenew_white_24dp); refreshItem.setActionView(refreshActionView); //显示刷新动画 Animation animation = AnimationUtils.loadAnimation(this, R.anim.refresh); animation.setRepeatMode(Animation.RESTART); animation.setRepeatCount(1); refreshActionView.startAnimation(animation); new Handler().postDelayed(new Runnable() { @Override public void run() { hideRefreshAnimation(); } }, 1000); }
Example 4
Source File: WebActivity.java From Floo with Apache License 2.0 | 6 votes |
@Override @SuppressLint("SetJavaScriptEnabled") protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web); WebView webView = (WebView) findViewById(R.id.web_view); String url = getIntent().getStringExtra(URL); if (url == null && getIntent().getData() != null) { url = getIntent().getData().getQueryParameter(URL); } if (url == null) { finish(); } webView.setWebViewClient(new InnerWebViewClient()); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(url); loading = (TextView) findViewById(R.id.loading); Animation animation = new ScaleAnimation(1.0f, 1.2f, 1.0f, 1.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setRepeatMode(Animation.REVERSE); animation.setRepeatCount(Animation.INFINITE); animation.setDuration(500); loading.startAnimation(animation); setTitle(url); }
Example 5
Source File: MainNavigationActivity.java From beaconloc with Apache License 2.0 | 5 votes |
public void swappingFloatingScanIcon(boolean isScanning) { if (isScanning) { Animation mAnimation = new AlphaAnimation(1, 0); mAnimation.setDuration(200); mAnimation.setInterpolator(new LinearInterpolator()); mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.REVERSE); fab.startAnimation(mAnimation); } else { fab.clearAnimation(); } }
Example 6
Source File: AnimationFactory.java From PullToRefresh with MIT License | 5 votes |
private void configureAnimation(Animation animation, Interpolator interpolator, int duration, int startOffset, int repeatMode, int repeatCount) { animation.setInterpolator(interpolator); animation.setDuration(duration); animation.setStartOffset(startOffset); animation.setRepeatMode(repeatMode); animation.setRepeatCount(repeatCount); }
Example 7
Source File: AnimationUtils.java From patrol-android with GNU General Public License v3.0 | 5 votes |
public static Animation getBlinkAnimation(){ Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible animation.setDuration(300); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in return animation; }
Example 8
Source File: RentalsSunDrawable.java From android-Ultra-Pull-To-Refresh-With-Load-More-master with MIT License | 5 votes |
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
Example 9
Source File: LogInActivity.java From PracticeCode with Apache License 2.0 | 5 votes |
private void initAnimation() { Animation logInAnimation = new TranslateAnimation(0, 0, 0, 400); logInAnimation.setFillAfter(true); logInAnimation.setDuration(1300); logInAnimation.setInterpolator(this, android.R.anim.accelerate_decelerate_interpolator); FadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); FadeOutAnimation.setDuration(600); FadeOutAnimation.setFillAfter(true); FadeInAnimation = new AlphaAnimation(0.0f, 1.0f); FadeInAnimation.setDuration(600); FadeInAnimation.setFillAfter(true); Animation flashFadeInnOut = new AlphaAnimation(0.0f, 1.0f); flashFadeInnOut.setDuration(1000); flashFadeInnOut.setFillAfter(true); flashFadeInnOut.setInterpolator(this, android.R.anim.accelerate_decelerate_interpolator); flashFadeInnOut.setRepeatMode(Animation.REVERSE); flashFadeInnOut.setRepeatCount(Animation.INFINITE); FlashFadeInnOutSet = new AnimationSet(true); FlashFadeInnOutSet.addAnimation(flashFadeInnOut); FlashFadeInnOutSet.addAnimation(logInAnimation); logInAnimationReverse = new TranslateAnimation(0, 0, icon.getY(), 0); logInAnimationReverse.setDuration(2000); logInAnimationReverse.setInterpolator(this, android.R.anim.decelerate_interpolator); logInAnimationReverse.setFillAfter(true); }
Example 10
Source File: SunRoseRefreshView.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
Example 11
Source File: AudioNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
private void startRecording() { recording = true; mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS); mRecorder.setOutputFile(mFilePath); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); try { mRecorder.prepare(); final Animation animation = new AlphaAnimation(1, (float)0.5); // Change alpha from fully visible to invisible animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in btnRecord.startAnimation(animation); startTime = System.currentTimeMillis(); AudioNoteActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if (mRecorder != null) { long time = System.currentTimeMillis() - startTime; int seconds = (int) time / 1000; int minutes = seconds / 60; seconds = seconds % 60; tvRecordingTime.setText(String.format("%02d", minutes) + ":" + String.format("%02d", seconds)); mHandler.postDelayed(this, 100); } } }); mRecorder.start(); } catch (IOException e) { recording = false; e.printStackTrace(); } }
Example 12
Source File: TokenHolder.java From alpha-wallet-android with MIT License | 5 votes |
private void animateTextWhileWaiting() { emptyTicker(); layoutValueDetails.setVisibility(View.VISIBLE); Animation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(450); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); text24Hours.startAnimation(anim); textAppreciation.startAnimation(anim); balanceCurrency.startAnimation(anim); }
Example 13
Source File: UiUtils.java From android-agera with Apache License 2.0 | 5 votes |
/** * Starts an animation that will jank if the UI thread is busy. * @param animView */ public static void startAnimation(View animView) { Animation tx = new TranslateAnimation(-350, 350, 0, 0); tx.setDuration(1000); tx.setRepeatCount(Animation.INFINITE); tx.setInterpolator(new AccelerateDecelerateInterpolator()); tx.setRepeatMode(Animation.REVERSE); animView.startAnimation(tx); }
Example 14
Source File: ResultsActivity.java From Onesearch with MIT License | 5 votes |
private void updateSavedScoreAndRenderViews() { TextView scoreTextView = (TextView) findViewById(R.id.tvScoreResult); scoreTextView.setText(Integer.toString(mScore)); if (mGameMode != null) { SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE); int bestScore = prefs.getInt(SCORE_PREFIX + mGameMode.getDifficulty(), 0); mPreviousBestScore = bestScore; if (mScore > bestScore) { SharedPreferences.Editor editor = getSharedPreferences(PREF_NAME, MODE_PRIVATE).edit(); editor.putInt(SCORE_PREFIX + mGameMode.getDifficulty(), mScore); editor.apply(); findViewById(R.id.tvBestScoreResultNotify).setVisibility(View.VISIBLE); Animation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(200); anim.setStartOffset(0); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(6); findViewById(R.id.tvBestScoreResultNotify).startAnimation(anim); ((TextView) findViewById(R.id.tvBestScoreResult)).setText(Integer.toString(mScore)); } else { ((TextView) findViewById(R.id.tvBestScoreResult)).setText(Integer.toString(bestScore)); } } }
Example 15
Source File: UiUtils.java From android-agera with Apache License 2.0 | 5 votes |
/** * Starts an animation that will jank if the UI thread is busy. * @param animView */ static void startAnimation(View animView) { Animation tx = new TranslateAnimation(-350, 350, 0, 0); tx.setDuration(1000); tx.setRepeatCount(Animation.INFINITE); tx.setInterpolator(new AccelerateDecelerateInterpolator()); tx.setRepeatMode(Animation.REVERSE); animView.startAnimation(tx); }
Example 16
Source File: SunRefreshDrawable.java From CanRefresh with Apache License 2.0 | 5 votes |
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
Example 17
Source File: RentalsSunDrawable.java From android-Ultra-Pull-To-Refresh with MIT License | 5 votes |
private void setupAnimations() { mAnimation = new Animation() { @Override public void applyTransformation(float interpolatedTime, Transformation t) { setRotate(interpolatedTime); } }; mAnimation.setRepeatCount(Animation.INFINITE); mAnimation.setRepeatMode(Animation.RESTART); mAnimation.setInterpolator(LINEAR_INTERPOLATOR); mAnimation.setDuration(ANIMATION_DURATION); }
Example 18
Source File: PartyActivity.java From Musync with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getSupportActionBar().hide(); setContentView(R.layout.activity_party); getWindow().setStatusBarColor(getResources().getColor(android.R.color.white)); Typeface regular = Typeface.createFromAsset(getAssets(), "fonts/product_san_regular.ttf"); Typeface bold = Typeface.createFromAsset(getAssets(),"fonts/product_sans_bold.ttf"); FontChanger fontChanger = new FontChanger(regular); fontChanger.replaceFonts((ViewGroup)this.findViewById(android.R.id.content)); final ImageView cld1 = (ImageView)findViewById(R.id.cld1); final ImageView cld2 = (ImageView)findViewById(R.id.cld2); final ImageView cld3 = (ImageView)findViewById(R.id.cld3); final ImageView cld4 = findViewById(R.id.cld4); sendBTN = findViewById(R.id.sendBTN); messageET = findViewById(R.id.messageET); messageRV = findViewById(R.id.messageRV); messageList = new ArrayList<>(); customListAdapter = new CustomListAdapter(messageList,getApplicationContext()); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext(),LinearLayoutManager.VERTICAL,false); messageRV.setLayoutManager(linearLayoutManager); messageRV.setAdapter(customListAdapter); Bitmap oldSB = ((BitmapDrawable)sendBTN.getDrawable()).getBitmap(); sendBTN.setImageBitmap(addGradient(oldSB)); Bitmap oldCld1= ((BitmapDrawable)cld1.getDrawable()).getBitmap(); Bitmap newCld1 = addGradient(oldCld1); cld1.setImageDrawable(new BitmapDrawable(getResources(),newCld1)); Bitmap oldCld2= ((BitmapDrawable)cld2.getDrawable()).getBitmap(); Bitmap newCld2 = addGradient(oldCld2); cld2.setImageDrawable(new BitmapDrawable(getResources(),newCld2)); Bitmap oldCld3= ((BitmapDrawable)cld3.getDrawable()).getBitmap(); Bitmap newCld3 = addGradient(oldCld3); cld3.setImageDrawable(new BitmapDrawable(getResources(),newCld3)); Bitmap oldCld4= ((BitmapDrawable)cld4.getDrawable()).getBitmap(); Bitmap newCld4 = addGradient(oldCld4); cld4.setImageDrawable(new BitmapDrawable(getResources(),newCld4)); final Animation animSlide1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide); animSlide1.setRepeatCount(-1); animSlide1.setRepeatMode(Animation.RESTART); final Animation animSlide2 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide2); animSlide2.setRepeatCount(-1); animSlide2.setRepeatMode(Animation.RESTART); final Animation animSlide3 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide3); animSlide3.setRepeatCount(-1); animSlide3.setRepeatMode(Animation.RESTART); final Animation animSlide4 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide4); animSlide4.setRepeatCount(-1); animSlide4.setRepeatMode(Animation.RESTART); cld1.startAnimation(animSlide1); cld2.startAnimation(animSlide2); cld3.startAnimation(animSlide3); cld4.startAnimation(animSlide4); sendBTN.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(messageET.getText().toString().trim().length()!=0){ send(messageET.getText().toString()); } } }); }
Example 19
Source File: MainActivity.java From Android-Basics-Codes with Artistic License 2.0 | 4 votes |
public void mahang (View view){ AnimationSet set = new AnimationSet(false); TranslateAnimation tras = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2); // ������ʾʱ�䳤�� tras.setDuration(2000); // �����ظ����� tras.setRepeatCount(2); // ���ö����ظ���ģʽ tras.setRepeatMode(Animation.REVERSE); RotateAnimation rotate = new RotateAnimation(360, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ������ʾʱ�䳤�� rotate.setDuration(2000); // �����ظ����� rotate.setRepeatCount(2); // ���ö����ظ���ģʽ rotate.setRepeatMode(Animation.REVERSE); ScaleAnimation scale = new ScaleAnimation(4f, 0.2f, 4f, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ������ʾʱ�䳤�� scale.setDuration(2000); // �����ظ����� scale.setRepeatCount(2); // ���ö����ظ���ģʽ scale.setRepeatMode(Animation.REVERSE); Animation alpha = new AlphaAnimation(1f, 0.1f); // ������ʾʱ�䳤�� alpha.setDuration(2000); // �����ظ����� alpha.setRepeatCount(2); // ���ö����ظ���ģʽ alpha.setRepeatMode(Animation.REVERSE); set.addAnimation(tras); set.addAnimation(alpha); set.addAnimation(rotate); set.addAnimation(scale); // ��ImageView�ϲ��Ŷ��� iv.startAnimation(set); }
Example 20
Source File: FigureSpinner.java From MillSpinners with Apache License 2.0 | 4 votes |
private void init() { final LayoutParams tempFigureLayoutParams = new LayoutParams(this.diameter, this.diameter); tempFigureLayoutParams.gravity = Gravity.CENTER; for (int i = 0; i < this.figureViews.length; i++) { final FigureView figureView = new FigureView(getContext()); figureView.setColor(this.colors[i]); figureView.setFigureMargin(this.marginFigureCounter += this.marginFigure); if (this.isRounded) { figureView.setRounded(); } Animation tempAnimation = new RotateAnimation(0, this.angle, this.radius, this.radius); tempAnimation.setStartOffset(this.startOffsetCounter); tempAnimation.setDuration(this.speed - this.startOffsetCounter); this.startOffsetCounter -= this.startOffset; figureView.setDrawingCacheEnabled(true); tempAnimation.setFillEnabled(true); tempAnimation.setFillBefore(true); tempAnimation.setFillAfter(true); tempAnimation.setRepeatMode(Animation.RESTART); tempAnimation.setRepeatCount(Animation.INFINITE); tempAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); figureView.startAnimation(tempAnimation); figureView.setLayoutParams(tempFigureLayoutParams); this.figureViews[i] = figureView; this.addView(figureView); } if (this.isRotated) { final Animation spinningAnimation = new RotateAnimation(0, 360, this.radius, this.radius); spinningAnimation.setDuration(this.speed * 5); spinningAnimation.setInterpolator(new LinearInterpolator()); spinningAnimation.setRepeatMode(Animation.RESTART); spinningAnimation.setRepeatCount(Animation.INFINITE); startAnimation(spinningAnimation); } }