List of usage examples for android.view.animation LinearInterpolator LinearInterpolator
public LinearInterpolator()
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
/** * @param drawable/* ww w . j a va2 s. com*/ * @param left * @param right * @return */ public TSnackbar addIconProgressLoading(Drawable drawable, boolean left, boolean right) { final ObjectAnimator animator = ObjectAnimator.ofInt(drawable, "level", 0, 10000); animator.setDuration(1000); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.INFINITE); mView.setBackgroundColor(mContext.getResources().getColor(Prompt.SUCCESS.getBackgroundColor())); if (left) { mView.getMessageView().setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); } if (right) { mView.getMessageView().setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null); } animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (mCallback != null) { mCallback.onShown(TSnackbar.this); } SnackbarManager.getInstance().onShown(mManagerCallback); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animator.start(); return this; }
From source file:app.sunstreak.yourpisd.LoginActivity.java
/** * Shows the progress UI and hides the login form. *///from w w w. j a v a2s. c o m @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.rks.musicx.misc.utils.Helper.java
/** * Rotate ImageView/*from ww w .ja v a2s. 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:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java
public Animation getBlinkAnimation() { Animation animation = new AlphaAnimation(1, 0); animation.setDuration(600);/*from ww w . j av a 2s.c o m*/ animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(1); animation.setRepeatMode(Animation.REVERSE); return animation; }
From source file:com.taobao.weex.ui.animation.WXAnimationModule.java
private static @Nullable Interpolator createTimeInterpolator(@NonNull WXAnimationBean animation) { String interpolator = animation.timingFunction; if (!TextUtils.isEmpty(interpolator)) { switch (interpolator) { case WXAnimationBean.EASE_IN: return new AccelerateInterpolator(); case WXAnimationBean.EASE_OUT: return new DecelerateInterpolator(); case WXAnimationBean.EASE_IN_OUT: return new AccelerateDecelerateInterpolator(); case WXAnimationBean.LINEAR: return new LinearInterpolator(); default:/*from www . j a va2s. c om*/ //Parse cubic-bezier try { SingleFunctionParser<Float> parser = new SingleFunctionParser<>(animation.timingFunction, new SingleFunctionParser.FlatMapper<Float>() { @Override public Float map(String raw) { return Float.parseFloat(raw); } }); List<Float> params = parser.parse(WXAnimationBean.CUBIC_BEZIER); if (params != null && params.size() == WXAnimationBean.NUM_CUBIC_PARAM) { return PathInterpolatorCompat.create(params.get(0), params.get(1), params.get(2), params.get(3)); } else { return null; } } catch (RuntimeException e) { return null; } } } return null; }
From source file:com.acceleratedio.pac_n_zoom.AnimActivity.java
private void mainAnmLoop() { AnimationSet anmSet = null;/*from w w w .j ava 2 s .co m*/ 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:org.runbuddy.tomahawk.views.PlaybackPanel.java
private void setupAnimations() { ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(this) { @Override//from www . j a va2s.c o m public void run() { mAnimators.clear(); // get relevant dimension sizes first Resources resources = TomahawkApp.getContext().getResources(); int panelHeight = resources.getDimensionPixelSize(R.dimen.playback_panel_height); int paddingSmall = resources.getDimensionPixelSize(R.dimen.padding_small); int paddingLarge = resources.getDimensionPixelSize(R.dimen.padding_large); int panelBottom = resources.getDimensionPixelSize(R.dimen.playback_clear_space_bottom); int headerClearSpace = resources .getDimensionPixelSize(R.dimen.header_clear_space_nonscrollable_playback); boolean isLandscape = resources.getBoolean(R.bool.is_landscape); // Setup mTextViewContainer animation Keyframe kfY0 = Keyframe.ofFloat(0f, getHeight() - mTextViewContainer.getHeight() / 2 - panelHeight / 2); Keyframe kfY1 = Keyframe.ofFloat(0.5f, isLandscape ? getHeight() + paddingLarge - panelBottom - mTextViewContainer.getHeight() : getHeight() + paddingSmall - panelBottom); Keyframe kfY2 = Keyframe.ofFloat(1f, headerClearSpace / 2 - mTextViewContainer.getHeight() / 2); PropertyValuesHolder pvhY = PropertyValuesHolder.ofKeyframe("y", kfY0, kfY1, kfY2); Keyframe kfScale0 = Keyframe.ofFloat(0f, 1f); Keyframe kfScale1 = Keyframe.ofFloat(0.5f, isLandscape ? 1.25f : 1.5f); Keyframe kfScale2 = Keyframe.ofFloat(1f, isLandscape ? 1.25f : 1.5f); PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe("scaleY", kfScale0, kfScale1, kfScale2); PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe("scaleX", kfScale0, kfScale1, kfScale2); ValueAnimator animator = ObjectAnimator .ofPropertyValuesHolder(mTextViewContainer, pvhY, pvhScaleX, pvhScaleY).setDuration(20000); animator.setInterpolator(new LinearInterpolator()); animator.setCurrentPlayTime(mLastPlayTime); mAnimators.add(animator); // Setup mPanelContainer animation kfY0 = Keyframe.ofFloat(0f, getHeight() - mPanelContainer.getHeight()); kfY1 = Keyframe.ofFloat(0.5f, getHeight() - mPanelContainer.getHeight()); kfY2 = Keyframe.ofFloat(1f, headerClearSpace - mPanelContainer.getHeight()); pvhY = PropertyValuesHolder.ofKeyframe("y", kfY0, kfY1, kfY2); animator = ObjectAnimator.ofPropertyValuesHolder(mPanelContainer, pvhY).setDuration(20000); animator.setInterpolator(new LinearInterpolator()); animator.setCurrentPlayTime(mLastPlayTime); mAnimators.add(animator); // Setup mTextViewContainer backgroundColor alpha animation Keyframe kfColor1 = Keyframe.ofInt(0f, 0x0); Keyframe kfColor2 = Keyframe.ofInt(0.5f, isLandscape ? 0xFF : 0x0); Keyframe kfColor3 = Keyframe.ofInt(1f, 0xFF); PropertyValuesHolder pvhColor = PropertyValuesHolder.ofKeyframe("color", kfColor1, kfColor2, kfColor3); animator = ValueAnimator.ofPropertyValuesHolder(pvhColor).setDuration(20000); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mTextViewContainer.findViewById(R.id.textview_container_inner).getBackground() .setAlpha((Integer) animation.getAnimatedValue()); } }); animator.setInterpolator(new LinearInterpolator()); animator.setCurrentPlayTime(mLastPlayTime); mAnimators.add(animator); // Setup mPanelContainer background fade animation Keyframe kfBgAlpha0 = Keyframe.ofInt(0f, 0); Keyframe kfBgAlpha1 = Keyframe.ofInt(0.5f, 0); Keyframe kfBgAlpha2 = Keyframe.ofInt(1f, 255); PropertyValuesHolder pvhBgAlpha = PropertyValuesHolder.ofKeyframe("alpha", kfBgAlpha0, kfBgAlpha1, kfBgAlpha2); animator = ObjectAnimator.ofPropertyValuesHolder(mPanelContainer.getBackground(), pvhBgAlpha) .setDuration(20000); animator.setInterpolator(new LinearInterpolator()); animator.setCurrentPlayTime(mLastPlayTime); mAnimators.add(animator); setupStationContainerAnimation(); } }); }
From source file:org.zywx.wbpalmstar.plugin.ueximage.ImagePreviewView.java
private void initAnimation() { final int duration = 300; LinearInterpolator interpolator = new LinearInterpolator(); fadeInAnim = new AlphaAnimation(0, 1); fadeInAnim.setDuration(duration);// www. j a va 2 s . c o m fadeInAnim.setInterpolator(interpolator); fadeOutAnim = new AlphaAnimation(1, 0); fadeOutAnim.setDuration(duration); fadeOutAnim.setInterpolator(interpolator); }
From source file:org.tomahawk.tomahawk_android.utils.AdapterUtils.java
private static RotateAnimation constructRotateAnimation() { final RotateAnimation animation = new RotateAnimation(0.0f, 360.0f, RotateAnimation.RELATIVE_TO_SELF, 0.49f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1500);/*from w w w. j av a 2 s.c o m*/ animation.setInterpolator(new LinearInterpolator()); animation.setRepeatCount(RotateAnimation.INFINITE); return animation; }
From source file:com.usertaxi.TaxiOntheWay_Activity.java
private void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); Projection proj = map.getProjection(); Point startPoint = proj.toScreenLocation(marker.getPosition()); final LatLng startLatLng = proj.fromScreenLocation(startPoint);//marker1.getPosition(); final long duration = 600; final Interpolator interpolator = new LinearInterpolator(); handler.post(new Runnable() { @Override//from ww w . j a va2s .c o m public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude; double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude; marker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { // Post again 16ms later. handler.postDelayed(this, 16); } else { if (hideMarker) { marker.setVisible(false); } else { marker.setVisible(true); } } // map.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lng))); } }); AppPreferences.setPreviouslat(getApplicationContext(), AppPreferences.getCurrentlat(getApplicationContext())); AppPreferences.setPreviouslong(getApplicationContext(), AppPreferences.getCurrentlong(getApplicationContext())); }