List of usage examples for android.view.animation RotateAnimation setDuration
public void setDuration(long durationMillis)
From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java
private ImageView getRotationImage() { RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setDuration(1000L); rotateAnimation.setRepeatMode(Animation.INFINITE); rotateAnimation.setRepeatCount(Animation.INFINITE); rotateAnimation.setFillEnabled(false); rotateAnimation.setInterpolator(new LinearInterpolator()); Drawable drawable = MBResourceService.getInstance().getImageByID(_refreshToolDef.getIcon()); ImageView rotationImage = new ImageView(_context); rotationImage.setImageDrawable(drawable); rotationImage.setAnimation(rotateAnimation); return rotationImage; }
From source file:net.willwebberley.gowertides.ui.DayFragment.java
private void setWeatherInfo() { Weather weather = day.getWeather();/* w w w. j a v a 2 s .c o m*/ String weather_description = weather.description; String unitType = prefs.getString("unitFormat", "true"); Boolean metric = false; if (unitType.equals("true")) { metric = true; } int max_temp = weather.getMaxTemp(metric); int min_temp = weather.getMinTemp(metric); int wind_speed = weather.getWindSpeed(metric); Double prep = weather.precipitation; String direction = weather.wind_direction; Spanned temp = null, wind = null; if (metric) { temp = Html.fromHtml("<b>" + min_temp + "°C - " + max_temp + "°C</b>"); wind = Html.fromHtml("<b>" + wind_speed + "km/h</b> from <b>" + direction + "</b>"); } else { temp = Html.fromHtml("<b>" + min_temp + "°F - " + max_temp + "°F</b>"); wind = Html.fromHtml("<b>" + wind_speed + "mph</b> from <b>" + direction + "</b>"); } Spanned precipitation = Html.fromHtml("<b>" + prep + "mm</b>"); ((TextView) layoutView.findViewById(R.id.weather_description)).setText(weather_description); ((TextView) layoutView.findViewById(R.id.weatherTemp)).setText(temp); ((TextView) layoutView.findViewById(R.id.weatherTemp)).setTextColor(Color.rgb(100, 100, 100)); ((TextView) layoutView.findViewById(R.id.weatherWind)).setText(wind); ((TextView) layoutView.findViewById(R.id.weatherWind)).setTextColor(Color.rgb(100, 100, 100)); ((TextView) layoutView.findViewById(R.id.weatherPrecipitation)).setText(precipitation); ((TextView) layoutView.findViewById(R.id.weatherPrecipitation)).setTextColor(Color.rgb(100, 100, 100)); String icon = weather.getWeatherIcon(); try { InputStream ims = getActivity().getAssets().open("icons/" + icon); Drawable d = Drawable.createFromStream(ims, null); ((ImageView) layoutView.findViewById(R.id.weatherIcon)).setImageDrawable(d); InputStream ims2 = getActivity().getAssets().open("icons/arrow.png"); Drawable d2 = Drawable.createFromStream(ims2, null); ((ImageView) layoutView.findViewById(R.id.weatherWindIcon)).setImageDrawable(d2); RotateAnimation rAnim = new RotateAnimation(0, weather.wind_degree, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rAnim.setDuration(500); rAnim.setFillEnabled(true); rAnim.setFillAfter(true); ((ImageView) layoutView.findViewById(R.id.weatherWindIcon)).startAnimation(rAnim); } catch (Exception e) { System.err.println(e); } }
From source file:com.nextgis.mobile.fragment.LayersFragment.java
public void refresh(boolean start) { if (mSyncButton == null) { return;// w w w . j a v a 2 s . com } if (start) { RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation.setFillAfter(true); rotateAnimation.setDuration(700); rotateAnimation.setRepeatCount(500); mSyncButton.startAnimation(rotateAnimation); } else { mSyncButton.clearAnimation(); } }
From source file:com.sociablue.nanodegree_p1.MovieListFragment.java
private void initializeFab(View rootView) { final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container); final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab); final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar); final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar); Fab.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from w ww .j a v a 2s. com public void onClick(View v) { //Menu Button Icon Animation //Setting up necessary variables long animationDuration = 500; float containerHeight = buttonContainer.getHeight(); float containerCenterY = containerHeight / 2; float containerCenterX = buttonContainer.getWidth() / 2; float topBarCenter = topBar.getTop() + topBar.getHeight() / 2; float widthOfBar = topBar.getWidth(); float heightOfBar = topBar.getHeight(); final float distanceBetweenBars = (containerCenterY - topBarCenter); /** *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties *and objects at the same time. Also, will try to break intialization into smaller functions. */ //Setting up animations of hamburger bars and rotation /** * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar. * Y Translation is 1/2 the height of the hamburger bar minus the distance. * Subtracting the distance from the height because the distance between bars is * calculated of the exact center of the button. * With out the subtraction the bar would translate slightly below the middle bar. */ float yTranslation = heightOfBar / 2 - distanceBetweenBars; float xTranslation = widthOfBar / 2 + heightOfBar / 2; TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars); topBarTranslationAnim.setDuration((long) (animationDuration * 0.8)); topBarTranslationAnim.setFillAfter(true); //Animation for bottom hamburger bar. Translates and Rotates to create 'X' AnimationSet bottomBarAnimation = new AnimationSet(true); bottomBarAnimation.setFillAfter(true); //Rotate to create cross. (The cross becomes the X after the button rotation completes" RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f); bottomBarRotationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarRotationAnimation); //Translate to correct X alignment TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -yTranslation); bottomBarTranslationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarTranslationAnimation); //Button Specific Animations //Rotate Button Container RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); containerRotationAnimation.setDuration(animationDuration); containerRotationAnimation.setFillAfter(true); //Animate change of button color between Active and Disabled colors that have been //defined in color.xml int activeColor = getResources().getColor(R.color.active_button); int disabledColor = getResources().getColor(R.color.disabled_button); //Need to use ValueAnimator because property animator does not support BackgroundTint ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor); buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue())); } }); buttonColorAnimation.setDuration(animationDuration); //Start all the animations topBar.startAnimation(topBarTranslationAnim); bottomBar.startAnimation(bottomBarAnimation); buttonContainer.startAnimation(containerRotationAnimation); buttonColorAnimation.start(); //Toogle mMenu open and closed if (mMenu.isOpen()) { //If mMenu is open, do the reverse of the animation containerRotationAnimation .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator())); mMenu.close(); } else { bottomBarAnimation.setInterpolator(new AccelerateInterpolator()); mMenu.open(); } } }); }
From source file:com.jackie.refresh.RefreshLayoutBase.java
private void rotateHeaderArrow() { Log.d(TAG, "rotateHeaderArrow() called with: mCurrentStatus = " + mCurrentStatus); if (mCurrentStatus == STATUS_REFRESHING) { return;/*from w ww . j a va 2 s . com*/ } else if (mCurrentStatus == STATUS_PULL_TO_REFRESH && !isArrowUp) { return; } else if (mCurrentStatus == STATUS_RELEASE_TO_REFRESH && isArrowUp) { return; } mRefreshProgress.setVisibility(View.GONE); mArrowImg.setVisibility(View.VISIBLE); float pivotX = mArrowImg.getWidth() / 2f; float pivotY = mArrowImg.getHeight() / 2f; float fromDegrees = 0f; float toDegrees = 0f; if (mCurrentStatus == STATUS_PULL_TO_REFRESH) { fromDegrees = 180f; toDegrees = 360f; } else if (mCurrentStatus == STATUS_RELEASE_TO_REFRESH) { fromDegrees = 0f; toDegrees = 180f; } RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, pivotX, pivotY); animation.setDuration(100); animation.setFillAfter(true); mArrowImg.startAnimation(animation); if (mCurrentStatus == STATUS_RELEASE_TO_REFRESH) { isArrowUp = true; } else { isArrowUp = false; } }
From source file:com.rks.musicx.misc.utils.Helper.java
/** * Rotate ImageView//from w ww.ja v a 2 s . co m * * @param view */ public static void rotationAnim(@NonNull View view) { RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation1.setInterpolator(new LinearInterpolator()); rotateAnimation1.setDuration(300); rotateAnimation1.setRepeatCount(0); view.startAnimation(rotateAnimation1); }
From source file:app.sunstreak.yourpisd.LoginActivity.java
/** * Shows the progress UI and hides the login form. *//*from ww w . j a va2 s.c om*/ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void showProgress(final boolean show) { // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow // for very easy animations. If available, use these APIs to fade-in // the progress spinner. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); mLoginFormView.setVisibility(View.VISIBLE); mLoginFormView.animate().setDuration(shortAnimTime) //.translationY(-200) .alpha(show ? 0 : 1).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); } }); mLoginStatusView.setVisibility(View.VISIBLE); mLoginStatusView.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); } }); // mLoginFormView.setVisibility(View.VISIBLE); // mLoginFormView.animate().setDuration(500).setInterpolator(new DecelerateInterpolator()) // .translationY(height*(show? -1 : 1)).setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginFormView.setVisibility(show ? View.INVISIBLE // : View.VISIBLE); // } // }); // mLoginStatusView.setVisibility(View.VISIBLE); // mLoginStatusView.animate().setDuration(shortAnimTime).translationY(0) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginStatusView.setVisibility(show ? View.VISIBLE // : View.INVISIBLE); // System.out.println("show loading: " + show); // } // }); if (DateHelper.isAprilFools()) { mLoginStatusView.removeAllViews(); try { ImageView img = new ImageView(this); //noinspection ResourceType img.setId(1337); InputStream is = getAssets().open("nyan.png"); img.setImageBitmap(BitmapFactory.decodeStream(is)); is.close(); TextView april = new TextView(this); april.setText( "Today and tomorrow, we shall pay \"homage\" to the numerous poor designs of the internet"); april.setGravity(Gravity.CENTER_HORIZONTAL); mLoginStatusView.addView(img); mLoginStatusView.addView(april); RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotateAnimation1.setInterpolator(new LinearInterpolator()); rotateAnimation1.setDuration(500); rotateAnimation1.setRepeatCount(Animation.INFINITE); img.startAnimation(rotateAnimation1); } catch (Exception e) { e.printStackTrace(); return; } } // mLoginStatusView.animate().setDuration(shortAnimTime) // .alpha(show ? 1 : 0) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginStatusView.setVisibility(show ? View.VISIBLE // : View.GONE); // } // }); // mLoginFormView.setVisibility(View.VISIBLE); // mLoginFormView.animate().setDuration(shortAnimTime) // .alpha(show ? 0 : 1) // .setListener(new AnimatorListenerAdapter() { // @Override // public void onAnimationEnd(Animator animation) { // mLoginFormView.setVisibility(show ? View.GONE // : View.VISIBLE); // } // }); } /* else if(getIntent().getExtras().getBoolean("Refresh")){ // The ViewPropertyAnimator APIs are not available, so simply show // and hide the relevant UI components. mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE); mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE); }*/ }
From source file:com.acceleratedio.pac_n_zoom.AnimActivity.java
private void mainAnmLoop() { AnimationSet anmSet = null;// w w w. ja v a 2 s.com if (onClickFlg == 1) { if (anmSet != null) { anmSet.cancel(); anmSet.reset(); } return; } // --- Loop through the frames int frm_nmbr = svg_data.frm.size(); if (++frm_mbr >= frm_nmbr) frm_mbr = 0; // -- You need to turn the sprites on and off for the current frame LoadSVG.frame crt_frm = svg_data.frm.get(frm_mbr); String crt_frm_ordr = crt_frm.frm_ordr; ArrayList<String> sprt_ordr = svg_data.svg.ordr; int crt_dur = crt_frm.end - crt_frm.bgn; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); int frm_sprt_mbr = 0; for (int sprt_mbr = 0; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); int sym_mbr = Integer.parseInt(sprt_id.substring(1, sprt_id.indexOf('_'))) - 2; if (sym_mbr >= 0) { // not g1 which is not loaded LoadSVG.symbol crt_sym = svg_data.symbl.get(sym_mbr); if (crt_frm_ordr.indexOf(sprt_id) >= 0) { // Sprite is present if (crt_sym.aud_id != null && !crt_sym.aud_id.equals("")) { // The sprite is audio SoundPool mSoundPool = loadSVG.getMSoundPool(); int streamId = mSoundPool.play(svg_data.soundId[sym_mbr], 1.0f, 1.0f, 1, 0, 1.0f); mSoundPool.setLoop(streamId, -1); } else { // The sprite is graphic anim_view = anmViews.get(sprt_mbr); anim_view.setAlpha(1f); int xfm_idx = crt_frm.xfm_idx[frm_sprt_mbr]; if (xfm_idx >= 0) { // An animation tag is present anmSet = new AnimationSet(false); LoadSVG.xfrm crt_xfm = svg_data.xfm.get(xfm_idx); ArrayList<Integer[]> pnts = crt_xfm.mov_path; int init_scl = (int) (initScl[sprt_mbr] * 100); if (pnts.size() > 0) { final Path path = new Path(); ld_scl_pth_pnts(pnts, path); PathAnimation pthAnm = new PathAnimation(path); pthAnm.setDuration(crt_dur); pthAnm.setInterpolator(new LinearInterpolator()); pthAnm.setFillAfter(true); // Needed to keep the result of the animation anmSet.addAnimation(pthAnm); } if (crt_xfm.scl_bgn != init_scl) { float crt_scl = crt_xfm.scl_bgn / init_scl; float end_scl = crt_scl; if (crt_xfm.scl_end != crt_xfm.scl_bgn) end_scl = crt_xfm.scl_end / init_scl; ScaleAnimation sclAnm = new ScaleAnimation(crt_scl, end_scl, crt_scl, end_scl, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); sclAnm.setDuration(crt_dur); anmSet.addAnimation(sclAnm); } if (crt_xfm.rot_bgn != 0) { float crt_rot = crt_xfm.rot_bgn; float end_rot = crt_rot; if (crt_xfm.rot_end != crt_xfm.rot_bgn) end_rot = crt_xfm.rot_end; RotateAnimation rotAnm = new RotateAnimation(crt_rot, end_rot, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotAnm.setDuration(crt_dur); anmSet.addAnimation(rotAnm); } anim_view.startAnimation(anmSet); //start animation } } frm_sprt_mbr++; } else { // The sprite is not present if (!(crt_sym.aud_id != null && !crt_sym.aud_id.equals(""))) { // The sprite is graphic anim_view = anmViews.get(sprt_mbr); anim_view.setAlpha(0f); } } } else { // g1 if (crt_frm_ordr.indexOf(sprt_id) >= 0) frm_sprt_mbr++; } } waitDur(crt_dur); }
From source file:com.evandroid.musica.fragment.LocalLyricsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (this.isHidden()) return;/*from w ww. j av a 2 s .co m*/ megaListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { final ImageView indicator = (ImageView) v.findViewById(R.id.group_indicator); RotateAnimation anim; if (megaListView.isGroupExpanded(groupPosition)) { megaListView.collapseGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(180f, 360f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(3)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } else { megaListView.expandGroupWithAnimation(groupPosition); if (indicator != null) { anim = new RotateAnimation(0f, 180f, indicator.getWidth() / 2, indicator.getHeight() / 2); anim.setInterpolator(new DecelerateInterpolator(2)); anim.setDuration(500); anim.setFillAfter(true); indicator.startAnimation(anim); } } return true; } }); megaListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mSwiping) { mSwiping = false; return false; } final MainLyricActivity mainLyricActivity = (MainLyricActivity) getActivity(); megaListView.setOnChildClickListener(null); // prevents bug on double tap mainLyricActivity.updateLyricsFragment(R.animator.slide_out_start, R.animator.slide_in_start, true, lyricsArray.get(groupPosition).get(childPosition)); return true; } }); this.isActiveFragment = true; new DBContentLister(this).execute(); }
From source file:Steps.StepsFragment.java
/** * Animate the new sticker rotating them on left and right and back again * * @param sticker//from w ww .j a v a 2 s . c o m * @param durationMillis */ private void animate(final RelativeLayout sticker, long durationMillis) { //final AnimationSet as = new AnimationSet(true); as.setFillEnabled(true); as.setFillAfter(true); //left rotations final RotateAnimation rotateLeft = new RotateAnimation((float) 320, (float) 375, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateLeft.setDuration(durationMillis); rotateLeft.setFillEnabled(true); if (firstTime) as.addAnimation(rotateLeft); //right rotations Animation rotateRight = new RotateAnimation((float) 375, (float) 320, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateRight.setStartOffset(durationMillis); rotateRight.setDuration(durationMillis); rotateRight.setFillEnabled(true); rotateRight.setFillAfter(true); if (firstTime) as.addAnimation(rotateRight); //sticker.clearAnimation(); sticker.startAnimation(as); firstTime = false; }