Java Code Examples for com.nineoldandroids.animation.ObjectAnimator#addListener()
The following examples show how to use
com.nineoldandroids.animation.ObjectAnimator#addListener() .
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: AnimUtils.java From PaymentKit-Droid with Apache License 2.0 | 6 votes |
/** * @param shouldResetTextColor if true make sure you end the previous animation before starting this one. */ public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) { final int textColor = textView.getCurrentTextColor(); textView.setTextColor(Color.RED); ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16); shakeAnim.setDuration(SHAKE_DURATION); shakeAnim.setInterpolator(new CycleInterpolator(2.0f)); shakeAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator anim) { if (shouldResetTextColor) { textView.setTextColor(textColor); } } }); return shakeAnim; }
Example 2
Source File: ViewAnimationUtils.java From fab-toolbar with MIT License | 6 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view))); if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); } ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout)); return new SupportAnimatorPreL(reveal, revealLayout); }
Example 3
Source File: ViewAnimationUtils.java From fab-transformation with MIT License | 6 votes |
/** * Returns an Animator which can animate a clipping circle. * <p/> * Any shadow cast by the View will respect the circular clip from this animator. * <p/> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link View#setClipToOutline(boolean) View Outline clipping}. * <p/> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if (!(view.getParent() instanceof RevealAnimator)) { throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view))); if (LOLLIPOP_PLUS) { return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); } ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout)); return new SupportAnimatorPreL(reveal, revealLayout); }
Example 4
Source File: Delegate.java From AndroidSweetSheet with Apache License 2.0 | 6 votes |
/** * 隐藏模糊背景 */ protected void dismissShowdown() { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 1, 0); objectAnimator.setDuration(400); objectAnimator.start(); objectAnimator.addListener(new SimpleAnimationListener() { @Override public void onAnimationEnd(Animator animation) { mParentVG.removeView(mBg); } }); }
Example 5
Source File: Delegate.java From MousePaint with MIT License | 6 votes |
/** * 隐藏模糊背景 */ protected void dismissShowdown() { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mBg, "alpha", 1, 0); objectAnimator.setDuration(400); objectAnimator.start(); objectAnimator.addListener(new SimpleAnimationListener() { @Override public void onAnimationEnd(Animator animation) { mParentVG.removeView(mBg); } }); }
Example 6
Source File: ViewAnimationUtils.java From RecyclerView-Animation-Demo with Apache License 2.0 | 6 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view))); if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); } ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout)); return new SupportAnimatorPreL(reveal, revealLayout); }
Example 7
Source File: ViewAnimationUtils.java From material-sheet-fab with MIT License | 6 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.attachRevealInfo(new RevealInfo(centerX, centerY, startRadius, endRadius, new WeakReference<>(view))); if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius), revealLayout); } ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, CLIP_RADIUS, startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout)); return new SupportAnimatorPreL(reveal, revealLayout); }
Example 8
Source File: ScrollAnimator.java From ButtonMenu with Apache License 2.0 | 5 votes |
/** * Show the animated view using a "translationY" animation and configure an AnimatorListener to be notified during * the animation. */ public void showWithAnimationWithListener(Animator.AnimatorListener animatorListener) { scrollDirection = SCROLL_TO_TOP; ObjectAnimator objectAnimator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, HIDDEN_Y_POSITION); if (animatorListener != null) { objectAnimator.addListener(animatorListener); } objectAnimator.setDuration(durationInMillis); objectAnimator.start(); }
Example 9
Source File: DetailActivity.java From google-io-2014-compat with Apache License 2.0 | 5 votes |
private void createShrinkAnimation(final SpotlightView spotlight) { mapContainer.setVisibility(View.INVISIBLE); spotlight.setVisibility(View.VISIBLE); hero.setVisibility(View.VISIBLE); spotlight.setMaskScale(maskScale); ObjectAnimator superShrink = ObjectAnimator.ofFloat(spotlight, "maskScale", maskScale, 0.5f); superShrink.addListener(new AnimatorListener() { @Override public void onAnimationEnd(Animator animation) { spotlight.setVisibility(View.GONE); } }); superShrink.start(); }
Example 10
Source File: DetailActivity.java From google-io-2014-compat with Apache License 2.0 | 5 votes |
private void createScaleAnimation(final SpotlightView spotlight) { spotlight.setVisibility(View.VISIBLE); ObjectAnimator superScale = ObjectAnimator.ofFloat(spotlight, "maskScale", maskScale); superScale.addListener(new AnimatorListener() { @Override public void onAnimationEnd(Animator animation) { hero.setVisibility(View.INVISIBLE); mapContainer.setVisibility(View.VISIBLE); spotlight.setVisibility(View.GONE); } }); superScale.start(); }
Example 11
Source File: Ripple.java From Mover with Apache License 2.0 | 5 votes |
private void exitSoftware(int radiusDuration, int opacityDuration) { final ObjectAnimator radiusAnim = ObjectAnimator.ofFloat(this, "radiusGravity", 1); radiusAnim.setAutoCancel(true); radiusAnim.setDuration(radiusDuration); radiusAnim.setInterpolator(DECEL_INTERPOLATOR); final ObjectAnimator xAnim = ObjectAnimator.ofFloat(this, "xGravity", 1); xAnim.setAutoCancel(true); xAnim.setDuration(radiusDuration); xAnim.setInterpolator(DECEL_INTERPOLATOR); final ObjectAnimator yAnim = ObjectAnimator.ofFloat(this, "yGravity", 1); yAnim.setAutoCancel(true); yAnim.setDuration(radiusDuration); yAnim.setInterpolator(DECEL_INTERPOLATOR); final ObjectAnimator opacityAnim = ObjectAnimator.ofFloat(this, "opacity", 0); opacityAnim.setAutoCancel(true); opacityAnim.setDuration(opacityDuration); opacityAnim.setInterpolator(LINEAR_INTERPOLATOR); opacityAnim.addListener(mAnimationListener); mAnimRadius = radiusAnim; mAnimOpacity = opacityAnim; mAnimX = xAnim; mAnimY = yAnim; radiusAnim.start(); opacityAnim.start(); xAnim.start(); yAnim.start(); }
Example 12
Source File: ViewAnimationUtils.java From Mover with Apache License 2.0 | 5 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static codetail.animation.Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(codetail.animation.Animator.LOLLIPOP){ return new codetail.animation.Animator(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius)); } if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside dreamers.widget.RevealLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.setTarget(view); revealLayout.setCenter(centerX, centerY); Rect bounds = new Rect(); view.getHitRect(bounds); ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius); reveal.addListener(new RevealAnimator.RevealFinished(revealLayout, bounds)); return new codetail.animation.Animator(reveal); }
Example 13
Source File: ViewAnimationUtils.java From ExpressHelper with GNU General Public License v3.0 | 5 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius)); } if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.setTarget(view); revealLayout.setCenter(centerX, centerY); Rect bounds = new Rect(); view.getHitRect(bounds); ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout, bounds)); return new SupportAnimatorPreL(reveal); }
Example 14
Source File: ViewAnimationUtils.java From NHentai-android with GNU General Public License v3.0 | 5 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius)); } if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.setTarget(view); revealLayout.setCenter(centerX, centerY); Rect bounds = new Rect(); view.getHitRect(bounds); ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout, bounds)); return new SupportAnimatorPreL(reveal); }
Example 15
Source File: ViewAnimationUtils.java From WeGit with Apache License 2.0 | 5 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius)); } if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.setTarget(view); revealLayout.setCenter(centerX, centerY); Rect bounds = new Rect(); view.getHitRect(bounds); ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout, bounds)); return new SupportAnimatorPreL(reveal); }
Example 16
Source File: ViewAnimationUtils.java From Jide-Note with MIT License | 5 votes |
/** * Returns an Animator which can animate a clipping circle. * <p> * Any shadow cast by the View will respect the circular clip from this animator. * <p> * Only a single non-rectangular clip can be applied on a View at any time. * Views clipped by a circular reveal animation take priority over * {@link android.view.View#setClipToOutline(boolean) View Outline clipping}. * <p> * Note that the animation returned here is a one-shot animation. It cannot * be re-used, and once started it cannot be paused or resumed. * * @param view The View will be clipped to the animating circle. * @param centerX The x coordinate of the center of the animating circle. * @param centerY The y coordinate of the center of the animating circle. * @param startRadius The starting radius of the animating circle. * @param endRadius The ending radius of the animating circle. */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static SupportAnimator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius) { if(LOLLIPOP_PLUS){ return new SupportAnimatorLollipop(android.view.ViewAnimationUtils .createCircularReveal(view, centerX, centerY, startRadius, endRadius)); } if(!(view.getParent() instanceof RevealAnimator)){ throw new IllegalArgumentException("View must be inside RevealFrameLayout or RevealLinearLayout."); } RevealAnimator revealLayout = (RevealAnimator) view.getParent(); revealLayout.setTarget(view); revealLayout.setCenter(centerX, centerY); Rect bounds = new Rect(); view.getHitRect(bounds); ObjectAnimator reveal = ObjectAnimator.ofFloat(revealLayout, "revealRadius", startRadius, endRadius); reveal.addListener(getRevealFinishListener(revealLayout, bounds)); return new SupportAnimatorPreL(reveal); }
Example 17
Source File: MemoFragment.java From MaterialCalendar with Apache License 2.0 | 5 votes |
void release() { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(mBluePair, "bottom", mBluePair.getBottom(), startBluePairBottom); objectAnimator.addListener(new SimpleListener() { @Override public void onAnimationEnd(Animator animator) { disappearBluePair(); } }); objectAnimator.setInterpolator(ACCELERATE_DECELERATE); objectAnimator.start(); }
Example 18
Source File: ScrollAnimator.java From ButtonMenu with Apache License 2.0 | 5 votes |
/** * Hide the animated view using a "translationY" animation and configure an AnimatorListener to be notified * during the animation. */ public void hideWithAnimationWithListener(Animator.AnimatorListener animatorListener) { scrollDirection = SCROLL_TO_BOTTOM; ObjectAnimator objectAnimator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, animatedView.getHeight()); if (animatorListener != null) { objectAnimator.addListener(animatorListener); } objectAnimator.setDuration(durationInMillis); objectAnimator.start(); }
Example 19
Source File: FloatingActionItemImageView.java From android-floating-action-menu with Apache License 2.0 | 4 votes |
public FloatingActionItemImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mShowListener = new Animator.AnimatorListener() { boolean isCancelled; @Override public void onAnimationStart(final Animator animation) { isCancelled = false; FloatingActionItemImageView.this.onAnimationStart(ANIMATION_SHOW); } @Override public void onAnimationEnd(final Animator animation) { if (!isCancelled) { FloatingActionItemImageView.this.onAnimationEnd(ANIMATION_SHOW); } } @Override public void onAnimationCancel(final Animator animation) { isCancelled = true; } @Override public void onAnimationRepeat(final Animator animation) {} }; mHideListener = new Animator.AnimatorListener() { boolean isCancelled; @Override public void onAnimationStart(final Animator animation) { isCancelled = false; FloatingActionItemImageView.this.onAnimationStart(ANIMATION_HIDE); } @Override public void onAnimationEnd(final Animator animation) { if (!isCancelled) { FloatingActionItemImageView.this.onAnimationEnd(ANIMATION_HIDE); } } @Override public void onAnimationCancel(final Animator animation) { isCancelled = true; } @Override public void onAnimationRepeat(final Animator animation) {} }; mShowAnimator = new ObjectAnimator(); mShowAnimator.setTarget(this); if (null != mShowListener) { mShowAnimator.addListener(mShowListener); } mHideAnimator = new ObjectAnimator(); mHideAnimator.setTarget(this); if (null != mHideListener) { mHideAnimator.addListener(mHideListener); } }
Example 20
Source File: SplashActivity.java From MyHearts with Apache License 2.0 | 4 votes |
@Override public void initView() { /*set it to be no title*/ // requestWindowFeature(Window.FEATURE_NO_TITLE); /*set it to be full screen*/ /*全屏显示*/ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //mReBg = (RelativeLayout) findViewById(R.id.activity_splash); View target = findViewById(R.id.activity_splash); //请求数据 OkGo.post(splash_img_url) .execute(new BitmapCallback(){ @Override public void onSuccess(Bitmap bitmap, Call call, Response response) { target.setBackgroundDrawable(new BitmapDrawable(bitmap)); } }); requestBitmap(); ObjectAnimator animator = ObjectAnimator.ofFloat(target,"alpha",0.0f,1.0f); animator.setDuration(2000);//动画执行的时间 animator.start(); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { SharedPreferences sp = getPreferences(MODE_PRIVATE); boolean isFirst = sp.getBoolean(Contants.IS_FIRST_RUNNING, true); String username = PreferencesUtils.getString(SplashActivity.this , Contants.USER_NAME); String password = PreferencesUtils.getString(SplashActivity.this, Contants.USER_PASSWORD); //感觉不是最好的办法,Bmob官网说有个getCurrentUser()方法 //来判断是否之前登录过,但是我尝试了,获取到的User对象都是为空,就想到这个方法进行弥补 //这个方法也是可以进行登录的,但是貌似对其他登录有点影响,这个后期遇到更好的办法就在去优化 BmobUser.loginByAccount(username, password, new LogInListener<MyUser>() { @Override public void done(MyUser user, BmobException e) { if(user!=null){ Log.i("smile","用户登陆成功"); EventBus.getDefault().post(new LoginEvent(user)); PreferencesUtils.putBoolean(SplashActivity.this ,Contants.IS_LOGIN,true); } } }); Intent intent = new Intent(); if (isFirst) { sp.edit().putBoolean(Contants.IS_FIRST_RUNNING, false).commit(); intent.setClass(SplashActivity.this, GuideActivity.class); } else { intent.setClass(SplashActivity.this, MainActivityDrawerLayout.class); } startActivity(intent); finish(); } }); }