List of usage examples for android.view.animation ScaleAnimation setDuration
public void setDuration(long durationMillis)
From source file:com.acceleratedio.pac_n_zoom.AnimActivity.java
private void mainAnmLoop() { AnimationSet anmSet = null;// w w w .ja v a 2s . c om 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.appolica.interactiveinfowindow.InfoWindowManager.java
private void animateWindowOpen(@NonNull final InfoWindow infoWindow, @NonNull final View container) { final SimpleAnimationListener animationListener = new SimpleAnimationListener() { @Override//from w w w.ja va2 s .c om public void onAnimationStart(Animation animation) { container.setVisibility(View.VISIBLE); propagateShowEvent(infoWindow, InfoWindow.State.SHOWING); } @Override public void onAnimationEnd(Animation animation) { propagateShowEvent(infoWindow, InfoWindow.State.SHOWN); setCurrentWindow(infoWindow); } }; if (showAnimation == null) { container.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { final int containerWidth = container.getWidth(); final int containerHeight = container.getHeight(); final float pivotX = container.getX() + containerWidth / 2; final float pivotY = container.getY() + containerHeight; final ScaleAnimation scaleAnimation = new ScaleAnimation(0f, 1f, 0f, 1f, pivotX, pivotY); scaleAnimation.setDuration(DURATION_WINDOW_ANIMATION); scaleAnimation.setInterpolator(new DecelerateInterpolator()); scaleAnimation.setAnimationListener(animationListener); container.startAnimation(scaleAnimation); container.getViewTreeObserver().removeOnPreDrawListener(this); return true; } }); } else { showAnimation.setAnimationListener(animationListener); container.startAnimation(showAnimation); } }
From source file:com.chuhan.privatecalc.fragment.os.FragmentManager.java
static Animation makeOpenCloseAnimation(Context context, float startScale, float endScale, float startAlpha, float endAlpha) { AnimationSet set = new AnimationSet(false); ScaleAnimation scale = new ScaleAnimation(startScale, endScale, startScale, endScale, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f); scale.setInterpolator(DECELERATE_QUINT); scale.setDuration(ANIM_DUR); set.addAnimation(scale);/*w w w.j a va2 s . com*/ AlphaAnimation alpha = new AlphaAnimation(startAlpha, endAlpha); alpha.setInterpolator(DECELERATE_CUBIC); alpha.setDuration(ANIM_DUR); set.addAnimation(alpha); return set; }
From source file:com.ebaonet.lawyer.ui.weight.DraggableGridViewPager.java
private void animateDragged() { if (mLastDragged >= 0) { final View v = getChildAt(mLastDragged); final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); r.inset(-r.width() / 20, -r.height() / 20); v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY)); v.layout(r.left, r.top, r.right, r.bottom); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2); scale.setDuration(ANIMATION_DURATION); AlphaAnimation alpha = new AlphaAnimation(1, .8f); alpha.setDuration(ANIMATION_DURATION); animSet.addAnimation(scale);//from www . j a va 2s. co m animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }
From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java
/** * Animates the play button to a pause button. *//* w ww .ja va 2s . c o m*/ private void animatePlayToPause() { //Check to make sure the current icon is the play icon. if (mPlayPauseButton.getId() != R.drawable.ic_play) return; //Fade out the play button. final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleOut.setDuration(150); scaleOut.setInterpolator(new AccelerateInterpolator()); //Scale in the pause button. final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleIn.setDuration(150); scaleIn.setInterpolator(new DecelerateInterpolator()); scaleOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setImageResource(R.drawable.ic_play); mPlayPauseButton.setPadding(0, 0, 0, 0); mPlayPauseButton.startAnimation(scaleIn); } @Override public void onAnimationRepeat(Animation animation) { } }); scaleIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setScaleX(1.0f); mPlayPauseButton.setScaleY(1.0f); mPlayPauseButton.setId(R.drawable.ic_play); } @Override public void onAnimationRepeat(Animation animation) { } }); mPlayPauseButton.startAnimation(scaleOut); }
From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java
/** * Animates the pause button to a play button. */// w ww. j a v a2 s. c o m private void animatePauseToPlay() { //Check to make sure the current icon is the pause icon. if (mPlayPauseButton.getId() != R.drawable.ic_play) return; //Scale out the pause button. final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleOut.setDuration(150); scaleOut.setInterpolator(new AccelerateInterpolator()); //Scale in the play button. final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleIn.setDuration(150); scaleIn.setInterpolator(new DecelerateInterpolator()); scaleOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setImageResource(R.drawable.ic_play); mPlayPauseButton.setPadding(0, 0, -5, 0); mPlayPauseButton.startAnimation(scaleIn); } @Override public void onAnimationRepeat(Animation animation) { } }); scaleIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setScaleX(1.0f); mPlayPauseButton.setScaleY(1.0f); mPlayPauseButton.setId(R.drawable.ic_play); } @Override public void onAnimationRepeat(Animation animation) { } }); mPlayPauseButton.startAnimation(scaleOut); }
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
protected void animateDragged() { View view = imgBarAvatar;// www . j a v a 2s.c o m float x = 0; try { x = imgBarAvatar.getX(); } catch (NoSuchMethodError e) { } if (pager.getCurrentItem() == 0) { btnOptionsColumnsEdit.setVisibility(View.GONE); } else { btnOptionsColumnsEdit.setVisibility(View.VISIBLE); } view.layout(imgBarAvatar.getLeft(), imgBarAvatar.getTop(), imgBarAvatar.getRight(), imgBarAvatar.getBottom()); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, imgBarAvatar.getHeight() * 3 / 4, imgBarAvatar.getWidth() * 3 / 4); scale.setDuration(150); animSet.addAnimation(scale); animSet.setFillEnabled(true); animSet.setFillAfter(true); view.clearAnimation(); view.startAnimation(animSet); showOptionsColumns((int) x, pager.getCurrentItem(), false); }
From source file:com.android.hcframe.DraggableGridViewPager.java
private void animateDragged() { if (mLastDragged >= 0) { final View v = getChildAt(mLastDragged); final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); r.inset(-r.width() / 20, -r.height() / 20); v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY)); v.layout(r.left, r.top, r.right, r.bottom); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2); scale.setDuration(ANIMATION_DURATION); AlphaAnimation alpha = new AlphaAnimation(1, .5f); alpha.setDuration(ANIMATION_DURATION); animSet.addAnimation(scale);//from w w w .ja v a2s.co m animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }
From source file:com.icloud.listenbook.base.view.DraggableGridViewPager.java
/*** * ?/* ww w. j a va 2 s .c om*/ * **/ private void animateDragged() { if (mLastDragged >= 0) { final View v = getChildAt(mLastDragged); final Rect r = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); r.inset(-r.width() / 20, -r.height() / 20); v.measure(MeasureSpec.makeMeasureSpec(r.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(r.height(), MeasureSpec.EXACTLY)); v.layout(r.left, r.top, r.right, r.bottom); AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation(0.9091f, 1, 0.9091f, 1, v.getWidth() / 2, v.getHeight() / 2); scale.setDuration(ANIMATION_DURATION); AlphaAnimation alpha = new AlphaAnimation(1, .5f); alpha.setDuration(ANIMATION_DURATION); animSet.addAnimation(scale); animSet.addAnimation(alpha); animSet.setFillEnabled(true); animSet.setFillAfter(true); v.clearAnimation(); v.startAnimation(animSet); } }