Java Code Examples for android.view.animation.Animation

The following are top voted examples for showing how to use android.view.animation.Animation. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ExpandButton   File: ExpandButtonLayout.java   Source Code and License 7 votes vote down vote up
public void open() {

        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(duration);
        animationSet.setAnimationListener(this);
        animationSet.setFillAfter(true);

        RotateAnimation rotateAnimation = new RotateAnimation(270, 360,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(rotateAnimation);
        Animation scaleAnimation = new ScaleAnimation(1.25f, 1f, 1.25f, 1f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        animationSet.addAnimation(scaleAnimation);
        imageView.startAnimation(animationSet);


        AnimatorSet animatorSet = new AnimatorSet();
        ObjectAnimator animator1 = ObjectAnimator.ofInt(mLinearLayout, "width", 0, mLinearLayoutWidth);
        ObjectAnimator animator2 = ObjectAnimator.ofInt(mLinearLayout, "paddingLeft", 0, savePaddingLeft);
        ObjectAnimator animator3 = ObjectAnimator.ofInt(mLinearLayout, "paddingRight", 0, savePaddingRight);
        ObjectAnimator animator4 = ObjectAnimator.ofInt(mLinearLayout, "marginLeft", 0, saveMarginLeft);
        ObjectAnimator animator5 = ObjectAnimator.ofInt(mLinearLayout, "marginRight", 0, saveMarginRight);
        animatorSet.playTogether(animator1, animator2, animator3, animator4, animator5);
        animatorSet.setDuration(duration).start();

    }
 
Example 2
Project: Hamburger-Button   File: HBButton.java   Source Code and License 6 votes vote down vote up
private Animation generateLineRTLAnimation(final RectF rectF, long offset) {

		final float currentLeft = rectF.left;
		final float currentRight = rectF.right;

		Animation animation = new Animation() {
			@Override
			protected void applyTransformation(float interpolatedTime, Transformation t) {
				super.applyTransformation(interpolatedTime, t);
				if (getCurrentState() == HBButtonState.NORMAL) {
					rectF.set(currentLeft + (currentRight - currentLeft) / 2 * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
				} else {
					rectF.set(currentLeft - (currentRight - currentLeft) * interpolatedTime, rectF.top, rectF.right, rectF.bottom);
				}
				invalidate();
			}
		};
		animation.setDuration(getAnimationDuration());
		animation.setStartOffset(offset);
		return animation;
	}
 
Example 3
Project: RLibrary   File: UILayoutImpl.java   Source Code and License 6 votes vote down vote up
/**
 * 销毁对话框的动画
 */
private void finishDialogAnim(final ViewPattern dialogPattern, final Animation animation, final Runnable end) {
      /*是否变暗*/
    if (dialogPattern.mIView.isDimBehind()) {
        AnimUtil.startArgb(dialogPattern.mIView.getDialogDimView(),
                dialogPattern.mIView.getDimColor(), Color.TRANSPARENT, DEFAULT_ANIM_TIME);
    }

    final View animView = dialogPattern.mIView.getAnimView();

    final Runnable endRunnable = new Runnable() {
        @Override
        public void run() {
            dialogPattern.mView.setAlpha(0);
            dialogPattern.mView.setVisibility(INVISIBLE);
            end.run();
        }
    };

    safeStartAnim(animView, animation, endRunnable, true);
}
 
Example 4
Project: AppLocker   File: LockActivity.java   Source Code and License 6 votes vote down vote up
protected void onPasscodeError() {
	Encryptor.snackPeak(mActivity,getString(R.string.passcode_wrong));

	Thread thread = new Thread() {
		public void run() {
			Animation animation = AnimationUtils.loadAnimation(
					LockActivity.this, R.anim.shake);
			findViewById(R.id.ll_applock).startAnimation(animation);
			codeField1.setText("");
			codeField2.setText("");
			codeField3.setText("");
			codeField4.setText("");
			codeField1.requestFocus();
		}
	};
	runOnUiThread(thread);
}
 
Example 5
Project: boohee_v5.6   File: ExpandableLayout.java   Source Code and License 6 votes vote down vote up
private void expand(final View v) {
    v.measure(-1, -2);
    final int targetHeight = v.getMeasuredHeight();
    v.getLayoutParams().height = 0;
    v.setVisibility(0);
    this.animation = new Animation() {
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            if (interpolatedTime == 1.0f) {
                ExpandableLayout.this.isOpened = Boolean.valueOf(true);
            }
            v.getLayoutParams().height = interpolatedTime == 1.0f ? -2 : (int) (((float)
                    targetHeight) * interpolatedTime);
            v.requestLayout();
        }

        public boolean willChangeBounds() {
            return true;
        }
    };
    this.animation.setDuration((long) this.duration.intValue());
    v.startAnimation(this.animation);
}
 
Example 6
Project: AndroidBackendlessChat   File: ChatSDKMessagesListAdapter.java   Source Code and License 6 votes vote down vote up
/**
 * Animating the sides of the row, For example animating the user profile image and the message date.
 * */
private void animateSides(View view, boolean fromLeft, Animation.AnimationListener animationListener){
    if (!isScrolling)
        return;

    if (fromLeft)
        view.setAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.expand_slide_form_left));
    else view.setAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.expand_slide_form_right));

    view.getAnimation().setAnimationListener(animationListener);
    view.animate();
}
 
Example 7
Project: boohee_v5.6   File: FloatingActionButtonEclairMr1.java   Source Code and License 6 votes vote down vote up
void show(@Nullable final InternalVisibilityChangedListener listener, boolean fromUser) {
    if (this.mView.getVisibility() != 0 || this.mIsHiding) {
        this.mView.clearAnimation();
        this.mView.internalSetVisibility(0, fromUser);
        Animation anim = AnimationUtils.loadAnimation(this.mView.getContext(), R.anim.design_fab_in);
        anim.setDuration(200);
        anim.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
        anim.setAnimationListener(new AnimationListenerAdapter() {
            public void onAnimationEnd(Animation animation) {
                if (listener != null) {
                    listener.onShown();
                }
            }
        });
        this.mView.startAnimation(anim);
    } else if (listener != null) {
        listener.onShown();
    }
}
 
Example 8
Project: BrotherWeather   File: CustomRefreshLayout2.java   Source Code and License 6 votes vote down vote up
private void startLoadingAnimation(ImageView imageView) {
  RotateAnimation loadingAnimation =
      new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
          0.5f);
  loadingAnimation.setDuration(1000);
  loadingAnimation.setRepeatCount(-1);
  loadingAnimation.setInterpolator(new LinearInterpolator());
  imageView.setAnimation(loadingAnimation);
  loadingAnimation.start();
}
 
Example 9
Project: GeekZone   File: SwipeRefreshLayout.java   Source Code and License 6 votes vote down vote up
private void startScaleUpAnimation(AnimationListener listener) {
    mCircleView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        // Pre API 11, alpha is used in place of scale up to show the
        // progress circle appearing.
        // Don't adjust the alpha during appearance otherwise.
        mProgress.setAlpha(MAX_ALPHA);
    }
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mCircleView.setAnimationListener(listener);
    }
    mCircleView.clearAnimation();
    mCircleView.startAnimation(mScaleAnimation);
}
 
Example 10
Project: ywApplication   File: RotateLoadingLayout.java   Source Code and License 6 votes vote down vote up
public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true);

	mHeaderImage.setScaleType(ScaleType.MATRIX);
	mHeaderImageMatrix = new Matrix();
	mHeaderImage.setImageMatrix(mHeaderImageMatrix);

	mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setRepeatCount(Animation.INFINITE);
	mRotateAnimation.setRepeatMode(Animation.RESTART);
}
 
Example 11
Project: Aurora   File: ExpandTextView.java   Source Code and License 6 votes vote down vote up
public void expand() {
    if (!isExpand) {
        isExpand = true;
        mText.setTextColor(Color.TRANSPARENT);
        mExpandText.setTextColor(mTextColor);
        Animation animation = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                ViewGroup.LayoutParams params = ExpandTextView.this.getLayoutParams();
                params.height = mStart + (int) ((mEnd - mStart) * interpolatedTime);
                setLayoutParams(params);
            }
        };
        animation.setDuration(500);
        startAnimation(animation);
    }

}
 
Example 12
Project: iReading   File: RefreshViewHeader.java   Source Code and License 6 votes vote down vote up
private void initView(Context context) {
    mContent = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.rfv_header, this);
    imgDirectionArrow = (ImageView) findViewById(R.id.imgDirectionArrow);
    tvRefreshState = (TextView) findViewById(R.id.tvRefreshState);
    tvLastRefreshTime = (TextView) findViewById(R.id.tvLastRefreshTime);
    mProgressBar = (ProgressBar) findViewById(R.id.rfv_header_progressbar);

    mRotateUpAnim = new RotateAnimation(0.0f, -180.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateUpAnim.setFillAfter(true);
    mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
    mRotateDownAnim.setFillAfter(true);
}
 
Example 13
Project: Pocket-Plays-for-Twitch   File: WelcomeActivity.java   Source Code and License 6 votes vote down vote up
private AnimationSet startShowContinueIconAnimations() {
	Animation mScaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
	Animation mRotateAnimation = new RotateAnimation(
				0, 360,
				Animation.RELATIVE_TO_SELF, 0.5f,
				Animation.RELATIVE_TO_SELF, 0.5f
	);
	mRotateAnimation.setRepeatCount(0);

	AnimationSet mAnimations = new AnimationSet(true);
	mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
	mAnimations.setFillAfter(true);
	mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
	mAnimations.addAnimation(mScaleAnimation);
	mAnimations.addAnimation(mRotateAnimation);

	mContinueIcon.startAnimation(mAnimations);
	return mAnimations;
}
 
Example 14
Project: PlusGram   File: View10.java   Source Code and License 6 votes vote down vote up
public static View10 wrap(View view) {
    View10 proxy = PROXIES.get(view);
    Animation animation = view.getAnimation();
    if (proxy == null || proxy != animation && animation != null) {
        proxy = new View10(view);
        PROXIES.put(view, proxy);
    } else if (animation == null) {
        view.setAnimation(proxy);
    }
    return proxy;
}
 
Example 15
Project: betterHotels   File: Utils.java   Source Code and License 6 votes vote down vote up
public static void animationIn(final View view, final int animation, int delayTime, final Context context) {
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            Animation inAnimation = AnimationUtils.loadAnimation(
                    context.getApplicationContext(), animation);
            view.setAnimation(inAnimation);
            view.setVisibility(View.VISIBLE);
        }
    }, delayTime);
}
 
Example 16
Project: AndroidOpen   File: SwipeToRefreshLayout.java   Source Code and License 6 votes vote down vote up
private void startScaleUpAnimation(Animation.AnimationListener listener) {
    mLoadingView.setVisibility(View.VISIBLE);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        mProgress.setAlpha(255);
    }
    Animation mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    if (listener != null) {
        mLoadingView.setAnimationListener(listener);
    }
    mLoadingView.clearAnimation();
    mLoadingView.startAnimation(mScaleAnimation);
}
 
Example 17
Project: secretknock   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	ButterKnife.bind(this);

	sharedPreferences = getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
	editor = sharedPreferences.edit();

	an = new RotateAnimation(0.0f,
			360.0f,Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF,
			0.5f);

	// Set the animation's parameters
	an.setInterpolator(new LinearInterpolator());
	an.setDuration(7000);               // duration in ms
	an.setRepeatCount(-1);                // -1 = infinite repeated
}
 
Example 18
Project: QMUI_Android   File: QMUIBottomSheet.java   Source Code and License 6 votes vote down vote up
/**
 * BottomSheet升起动画
 */
private void animateUp() {
    if (mContentView == null) {
        return;
    }
    TranslateAnimation translate = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f
    );
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(translate);
    set.addAnimation(alpha);
    set.setInterpolator(new DecelerateInterpolator());
    set.setDuration(mAnimationDuration);
    set.setFillAfter(true);
    mContentView.startAnimation(set);
}
 
Example 19
Project: qmui   File: QMUIBottomSheet.java   Source Code and License 6 votes vote down vote up
/**
 * BottomSheet升起动画
 */
private void animateUp() {
    if (mContentView == null) {
        return;
    }
    TranslateAnimation translate = new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f
    );
    AlphaAnimation alpha = new AlphaAnimation(0, 1);
    AnimationSet set = new AnimationSet(true);
    set.addAnimation(translate);
    set.addAnimation(alpha);
    set.setInterpolator(new DecelerateInterpolator());
    set.setDuration(mAnimationDuration);
    set.setFillAfter(true);
    mContentView.startAnimation(set);
}
 
Example 20
Project: android-source-codes   File: SwipeRefreshLayout.java   Source Code and License 6 votes vote down vote up
@Override
public void onAnimationEnd(Animation animation) {
    if (mRefreshing) {
        // Make sure the progress view is fully visible
        mProgress.setAlpha(MAX_ALPHA);
        mProgress.start();
        if (mNotify) {
            if (mListener != null) {
                mListener.onRefresh();
            }
        }
        mCurrentTargetOffsetTop = mCircleView.getTop();
    } else {
        reset();
    }
}
 
Example 21
Project: XinFramework   File: TransactionDelegate.java   Source Code and License 6 votes vote down vote up
private void mockStartWithPopAnim(ISupportFragment from, ISupportFragment to, final Animation exitAnim) {
    Fragment fromF = (Fragment) from;
    final ViewGroup container = findContainerById(fromF, from.getSupportDelegate().mContainerId);
    if (container == null) return;

    from.getSupportDelegate().mLockAnim = true;
    View fromView = fromF.getView();
    container.removeViewInLayout(fromView);

    final ViewGroup mock = addMockView(fromView, container);

    to.getSupportDelegate().mEnterAnimListener = new SupportFragmentDelegate.EnterAnimListener() {
        @Override
        public void onEnterAnimStart() {
            mock.startAnimation(exitAnim);

            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    container.removeView(mock);
                }
            }, exitAnim.getDuration() + BUFFER_TIME);
        }
    };
}
 
Example 22
Project: LuaViewPlayground   File: SuperSwipeRefreshLayout.java   Source Code and License 5 votes vote down vote up
private void startScaleUpAnimation(AnimationListener listener) {
    mScaleAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime,
                                        Transformation t) {
            setAnimationProgress(interpolatedTime);
        }
    };
    mScaleAnimation.setDuration(mMediumAnimationDuration);
    if (listener != null) {
        mHeadViewContainer.setAnimationListener(listener);
    }
    mHeadViewContainer.clearAnimation();
    mHeadViewContainer.startAnimation(mScaleAnimation);
}
 
Example 23
Project: SunmiUI   File: CodeDialog.java   Source Code and License 5 votes vote down vote up
public void showLoad() {
    isReq = true;
    load.setVisibility(View.VISIBLE);
    clear.setVisibility(View.GONE);
    Animation operatingAnim = AnimationUtils.loadAnimation(dialog.getContext(), R.anim.loading_anim);
    LinearInterpolator lin = new LinearInterpolator();
    operatingAnim.setInterpolator(lin);
    load.setAnimation(operatingAnim);
    load.startAnimation(operatingAnim);
}
 
Example 24
Project: FLFloatingButton   File: RayLayout.java   Source Code and License 5 votes vote down vote up
private static Animation createExpandAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
		long startOffset, long duration, Interpolator interpolator) {
	Animation animation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 0, 720);
	animation.setStartOffset(startOffset);
	animation.setDuration(duration);
	animation.setInterpolator(interpolator);
	animation.setFillAfter(true);

	return animation;
}
 
Example 25
Project: ForeverLibrary   File: ActionSheet.java   Source Code and License 5 votes vote down vote up
private Animation createTranslationOutAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 0, type, 1);
    an.setDuration(TRANSLATE_DURATION);
    an.setFillAfter(true);
    return an;
}
 
Example 26
Project: RLibrary   File: AnimUtil.java   Source Code and License 5 votes vote down vote up
/**
 * 应用一个布局动画
 */
public static void applyLayoutAnimation(final ViewGroup viewGroup) {
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1f,
            Animation.RELATIVE_TO_PARENT, 0f,
            Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f);
    translateAnimation.setDuration(300);
    applyLayoutAnimation(viewGroup, translateAnimation);
}
 
Example 27
Project: android-mvvm-architecture   File: ViewAnimationUtils.java   Source Code and License 5 votes vote down vote up
public static void scaleAnimateView(View view) {
    ScaleAnimation animation =
            new ScaleAnimation(
                    1.15f, 1, 1.15f, 1,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);

    view.setAnimation(animation);
    animation.setDuration(100);
    animation.start();
}
 
Example 28
Project: iBeaconReader   File: MainActivity.java   Source Code and License 5 votes vote down vote up
public void Evt(long number) {
    Animation Animation = AnimationUtils.loadAnimation(this, R.anim.shake);

    imageView.startAnimation(Animation);

    Intent goToApp = new Intent(MainActivity.this, BeaconActivity.class);

    // Create the AlertDialog for failed authentication
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setMessage(R.string.fail)
            .setNegativeButton(R.string.retry, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                }
            });
    Dialog auth_error = builder.create();

    // Check if Izly card is authorized and passing tech id as parameter
    boolean go = true;

    if (number == -1971634176) {
        goToApp.putExtra("tech", 1);
    } else if (number == -2106576896) {
        goToApp.putExtra("tech", 2);
    } else {
        go = false;
    }

    // Launch iBeacon activity or show error dialog
    if(go){
        startActivity(goToApp);
    } else {
        auth_error.show();
    }

}
 
Example 29
Project: gesture-refresh-layout   File: GestureRefreshLayout.java   Source Code and License 5 votes vote down vote up
private void startScaleDownAnimation(Animation.AnimationListener listener) {
    mScaleDownAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mScaleDownAnimation.setAnimationListener(listener);
    mRefreshView.clearAnimation();
    mRefreshView.startAnimation(mScaleDownAnimation);
}
 
Example 30
Project: FireFiles   File: MaterialProgressDrawable.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isRunning() {
    final ArrayList<Animation> animators = mAnimators;
    final int N = animators.size();
    for (int i = 0; i < N; i++) {
        final Animation animator = animators.get(i);
        if (animator.hasStarted() && !animator.hasEnded()) {
            return true;
        }
    }
    return false;
}
 
Example 31
Project: rongyunDemo   File: ClearWriteEditText.java   Source Code and License 5 votes vote down vote up
/**
 * 晃动动画
 * @param counts 半秒钟晃动多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
 
Example 32
Project: OSchina_resources_android   File: KJAnimations.java   Source Code and License 5 votes vote down vote up
/**
 * 旋转 Rotate
 */
public static Animation getRotateAnimation(float fromDegrees,
                                           float toDegrees, long durationMillis) {
    RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    rotate.setDuration(durationMillis);
    rotate.setFillAfter(true);
    return rotate;
}
 
Example 33
Project: CustomListView   File: IndicatorLayout.java   Source Code and License 5 votes vote down vote up
@Override
public void onAnimationEnd(Animation animation) {
	if (animation == mOutAnim) {
		mArrowImageView.clearAnimation();
		setVisibility(View.GONE);
	} else if (animation == mInAnim) {
		setVisibility(View.VISIBLE);
	}

	clearAnimation();
}
 
Example 34
Project: AnimatedPullToRefresh-master   File: AnimationHelper.java   Source Code and License 5 votes vote down vote up
private void addTextRotateAnimations(AnimationSet set) {
    RotateAnimation mRotateUpAnim = new RotateAnimation(0.0f, ROTATION_ANGLE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateUpAnim.setDuration(CHARACTER_ANIM_DURATION);
    set.addAnimation(mRotateUpAnim);
    RotateAnimation mRotateDownAnim = new RotateAnimation(ROTATION_ANGLE, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateDownAnim.setDuration(CHARACTER_ANIM_DURATION);
    mRotateDownAnim.setStartOffset(CHARACTER_ANIM_DURATION + 20);
    mRotateDownAnim.setFillAfter(true);
    set.addAnimation(mRotateDownAnim);
    set.setInterpolator(interpolator);
}
 
Example 35
Project: android-mvp-interactor-architecture   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void reloadQuestionnaire(List<Question> questionList) {
    refreshQuestionnaire(questionList);
    ScaleAnimation animation =
            new ScaleAnimation(
                    1.15f, 1, 1.15f, 1,
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);

    mCardsContainerView.setAnimation(animation);
    animation.setDuration(100);
    animation.start();
}
 
Example 36
Project: Programmers   File: AnimUtils.java   Source Code and License 5 votes vote down vote up
public static Animation blink() {

        Animation animation = new AlphaAnimation(1, 0);
        animation.setDuration(550);
        animation.setInterpolator(new LinearInterpolator());
        animation.setRepeatCount(10);
        animation.setRepeatMode(Animation.REVERSE);
        return animation;
    }
 
Example 37
Project: QMark   File: WelcomeSnowActy.java   Source Code and License 5 votes vote down vote up
private RotateAnimation randomRotate(int duration) {
	RotateAnimation rotate = new RotateAnimation(0, (float) ((Math.random() > 0.5f ? 1 : -1) * 360 / (Math.random() * 20000 + 1000) * duration),
			Animation.RELATIVE_TO_SELF, (float) (Math.random() * 0.5f), Animation.RELATIVE_TO_SELF, (float) (Math.random() * 0.5f));
	rotate.setRepeatCount(Animation.INFINITE);
	rotate.setRepeatMode(Animation.RESTART);
	rotate.setStartOffset(0);
	rotate.setDuration(duration);
	return rotate;
}
 
Example 38
Project: RLibrary   File: AnimUtil.java   Source Code and License 5 votes vote down vote up
/**
 * 启动时的动画  从底部平移到顶部
 */
public static Animation translateAlphaStartAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f);
    AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
    setDefaultConfig(translateAnimation, false);
    setDefaultConfig(alphaAnimation, false);

    AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    return animationSet;
}
 
Example 39
Project: Cable-Android   File: InputPanel.java   Source Code and License 5 votes vote down vote up
public void moveTo(float x) {
  float     offset    = getOffset(x);
  Animation animation = new TranslateAnimation(Animation.ABSOLUTE, offset,
                                               Animation.ABSOLUTE, offset,
                                               Animation.RELATIVE_TO_SELF, 0,
                                               Animation.RELATIVE_TO_SELF, 0);

  animation.setDuration(0);
  animation.setFillAfter(true);
  animation.setFillBefore(true);

  slideToCancelView.startAnimation(animation);
}
 
Example 40
Project: MusicX-music-player   File: Helper.java   Source Code and License 5 votes vote down vote up
/**
 * Rotate ImageView
 *
 * @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);
}
 
Example 41
Project: JD-Test   File: MaterialProgressDrawable.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isRunning() {
    final ArrayList<Animation> animators = mAnimators;
    final int N = animators.size();
    for (int i = 0; i < N; i++) {
        final Animation animator = animators.get(i);
        if (animator.hasStarted() && !animator.hasEnded()) {
            return true;
        }
    }
    return false;
}
 
Example 42
Project: betterHotels   File: Utils.java   Source Code and License 5 votes vote down vote up
public static void animationOut(final View view, final int animation, int delayTime, final boolean isViewGone, final Context context) {
    view.setVisibility(View.VISIBLE);
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            Animation outAnimation = AnimationUtils.loadAnimation(
                    context.getApplicationContext(), animation);
            view.setAnimation(outAnimation);
            if (isViewGone)
                view.setVisibility(View.GONE);
            else
                view.setVisibility(View.INVISIBLE);
        }
    }, delayTime);
}
 
Example 43
Project: QRCodeScanner   File: ProgressView.java   Source Code and License 5 votes vote down vote up
public void startAnimation(final int frameCount, final int duration) {
        Animation a = AnimationUtils.loadAnimation(getContext(), R.anim.progress_anim);
        a.setDuration(duration);
        a.setInterpolator(new Interpolator() {
            @Override
            public float getInterpolation(float input) {
//                return (float) Math.floor(input * frameCount) / frameCount;
                return input;
            }
        });
        startAnimation(a);
    }
 
Example 44
Project: Fatigue-Detection   File: AnimationUtils.java   Source Code and License 5 votes vote down vote up
public static void displayAnim(View view, Context context, int animId, int targetVisibility){
    view.clearAnimation();
    Animation anim =
            android.view.animation.AnimationUtils.loadAnimation(context, animId);
    view.setVisibility(targetVisibility);
    view.startAnimation(anim);
}
 
Example 45
Project: CustomAndroidOneSheeld   File: DefaultIndicatorLayout.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public final boolean isVisible() {
	Animation currentAnim = getAnimation();
	if (null != currentAnim) {
		return mInAnim == currentAnim;
	}

	return getVisibility() == View.VISIBLE;
}
 
Example 46
Project: Mire   File: AnimUtils.java   Source Code and License 5 votes vote down vote up
public static void _alphaAnimationEnd(@NonNull Context context, @NonNull View view)
{
	Animation alpha = AnimationUtils.loadAnimation(context, R.anim.alpha_anim_gone);

	view.startAnimation(alpha);
	view.setVisibility(View.GONE);
}
 
Example 47
Project: RandomLayout   File: StellarMap.java   Source Code and License 5 votes vote down vote up
/** 给下一个Group设置进出动画 */
private void switchGroup(int newGroupIndex, boolean playAnimation, Animation inAnim, Animation outAnim) {
	if (newGroupIndex < 0 || newGroupIndex >= mGroupCount) {
		return;
	}
	// 把当前显示Group角标设置为隐藏的
	mHidenGroupIndex = mShownGroupIndex;
	// 把下一个Group角标设置为显示的
	mShownGroupIndex = newGroupIndex;
	// 交换两个Group
	RandomLayout temp = mShownGroup;
	mShownGroup = mHidenGroup;
	mShownGroup.setAdapter(mShownGroupAdapter);
	mHidenGroup = temp;
	mHidenGroup.setAdapter(mHidenGroupAdapter);
	// 刷新显示的Group
	mShownGroup.refresh();
	// 显示Group
	mShownGroup.setVisibility(View.VISIBLE);

	// 启动动画
	if (playAnimation) {
		if (mShownGroup.hasLayouted()) {
			mShownGroup.startAnimation(inAnim);
		}
		mHidenGroup.startAnimation(outAnim);
	} else {
		mHidenGroup.setVisibility(View.GONE);
	}
}
 
Example 48
Project: Pocket-Plays-for-Twitch   File: AnimationService.java   Source Code and License 5 votes vote down vote up
/**
 * Hides every view in a RecyclerView to simulate clearing the RecyclerView
 * returns how long the animation takes to complete.
 * Returns -1 if there is nothing to animate
 */
public static int animateFakeClearing(int lastVisibleItemPosition, int firstVisibleItemPosition, AutoSpanRecyclerView aRecyclerView, Animation.AnimationListener animationListener, boolean includeTranslation) {
	final int DELAY_BETWEEN = 50;
	int clearingDuration = 0;

	int startPositionCol = getColumnPosFromIndex(firstVisibleItemPosition, aRecyclerView);
	int startPositionRow = getRowPosFromIndex(firstVisibleItemPosition, aRecyclerView);

	for(int i = lastVisibleItemPosition; i >= firstVisibleItemPosition; i--) {
		final View VIEW = aRecyclerView.getChildAt(lastVisibleItemPosition - i);

		int positionColumnDistance = Math.abs(getColumnPosFromIndex(i, aRecyclerView) - startPositionCol);
		int positionRowDistance = Math.abs(getRowPosFromIndex(i, aRecyclerView) - startPositionRow);
		int delay = (positionColumnDistance + positionRowDistance) * DELAY_BETWEEN + 1;

		AnimationSet mHideAnimations = AnimationService.startAlphaHideAnimation(delay, VIEW, includeTranslation);
		if (mHideAnimations == null) {
			return -1;
		}
		int hideAnimationDuration = (int) mHideAnimations.getDuration();

		if (hideAnimationDuration + delay > clearingDuration) {
			clearingDuration = hideAnimationDuration + delay;
		}

		// If the view is the last to animate, then start the intent when the animation finishes.
		if(i == lastVisibleItemPosition && animationListener != null) {
			mHideAnimations.setAnimationListener(animationListener);
		}
	}

	return clearingDuration;
}
 
Example 49
Project: PowerfulEditText   File: PowerfulEditText.java   Source Code and License 5 votes vote down vote up
/**
 * 晃动动画
 * @param counts 0.5秒钟晃动多少下
 * @return
 */
private Animation shakeAnimation(int counts){
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
 
Example 50
Project: CFAlertDialog   File: CFAlertDialog.java   Source Code and License 5 votes vote down vote up
private Animation getDismissAnimation(CFAlertStyle style) {
    switch (style) {
        case NOTIFICATION:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_top);
        case ALERT:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_center);
        case BOTTOM_SHEET:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_bottom);
        default:
            return AnimationUtils.loadAnimation(params.context, R.anim.dialog_dismiss_center);
    }
}
 
Example 51
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: Splash.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    tv = (TextView) findViewById(R.id.tv);
    iv = (ImageView) findViewById(R.id.iv);


    Animation myanim = AnimationUtils.loadAnimation(this, R.anim.mytrasition);
    tv.startAnimation(myanim);
    iv.startAnimation(myanim);
    final Intent i = new Intent(this, Activity_login.class);
    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(5000);}
            catch (Exception e){
                System.out.println(e.getMessage());
                e.printStackTrace();
            }finally {
                startActivity(i);
                finish();
            }
        }
    };
          timer.start();
}
 
Example 52
Project: Nimbus   File: GalleryView.java   Source Code and License 5 votes vote down vote up
public  void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int)(targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
Example 53
Project: Mire   File: AnimUtils.java   Source Code and License 5 votes vote down vote up
public static void _alphaAnimationEnter(@NonNull Context context, @NonNull View view)
{
	Animation alpha = AnimationUtils.loadAnimation(context, R.anim.alpha_anim_visible);
	
	view.startAnimation(alpha);
	view.setVisibility(View.VISIBLE);
}
 
Example 54
Project: TestChat   File: RegisterActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void initData() {
        new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                        Animation animation = AnimationUtils.loadAnimation(RegisterActivity.this, R.anim.translate_anim);
                        bg.startAnimation(animation);
                }
        }, 200);
        ToolBarOption toolBarOption = new ToolBarOption();
        toolBarOption.setTitle("注册");
        setToolBar(toolBarOption);
        RandomData.initAllRanDomData();
}
 
Example 55
Project: Sanxing   File: NavigationHelpFragment.java   Source Code and License 5 votes vote down vote up
void showAnimation() {
    Animation slideDown = AnimationUtils.loadAnimation(this.getContext(), R.anim.slide_down);
    Animation slideRight = AnimationUtils.loadAnimation(this.getContext(), R.anim.slide_right);
    imageView1.startAnimation(slideDown);
    imageView2.startAnimation(slideDown);
    imageView3.startAnimation(slideDown);
    navigationCard.startAnimation(slideRight);
}
 
Example 56
Project: QMark   File: WelcomeSnowActy.java   Source Code and License 4 votes vote down vote up
private ScaleAnimation randomScale() {
	float scaleTo = (float) (0.3f + Math.random() * 0.5f);
	ScaleAnimation scale = new ScaleAnimation(1, scaleTo, 1, scaleTo, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
	scale.setRepeatCount(Animation.INFINITE);
	scale.setRepeatMode(Animation.REVERSE);
	scale.setStartOffset(1000);
	scale.setDuration((int) (Math.random() * 3000) + 1000);
	return scale;
}
 
Example 57
Project: Pocket-Plays-for-Twitch   File: ChannelsAdapter.java   Source Code and License 4 votes vote down vote up
@Override
void handleElementOnClick(final View view) {
	int itemPosition = getRecyclerView().getChildAdapterPosition(view);
	final ChannelInfo item = getElements().get(itemPosition);
	final StreamerInfoViewHolder vh = (StreamerInfoViewHolder) getRecyclerView().getChildViewHolder(view);
	final PreviewTarget previewTarget = getTargets().get(vh.getTargetsKey());

	// Create intent for opening StreamerInfo activity. Send the StreamerInfo object with
	// the intent, and flag it to make sure it creates a new task on the history stack
	final Intent intent = new Intent(getContext(), ChannelActivity.class);
	intent.putExtra(getContext().getResources().getString(R.string.channel_info_intent_object), item);
	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		View sharedView = view.findViewById(R.id.profileLogoImageView);
		sharedView.setTransitionName(getContext().getString(R.string.streamerInfo_transition));
		final ActivityOptionsCompat options = ActivityOptionsCompat.
				makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.streamerInfo_transition));

		activity.setExitSharedElementCallback(new SharedElementCallback() {
			@SuppressLint("NewApi")
			@Override
			public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
				super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

				if (!sharedElements.isEmpty() && sharedElements.get(0) != null && previewTarget != null) {
					View element = sharedElements.get(0);
					Animation anim = new RoundImageAnimation(element.getWidth()/2, 0, (ImageView) element, previewTarget.getPreview());
					anim.setDuration(200);
					anim.setInterpolator(new DecelerateInterpolator());
					view.startAnimation(anim);
				}
				activity.setExitSharedElementCallback(null);
			}
		});
		activity.startActivity(intent, options.toBundle());
	} else {
		getContext().startActivity(intent);
		if(activity != null) {
			activity.overridePendingTransition(R.anim.slide_in_right_anim, R.anim.fade_out_semi_anim);
		}
	}
}
 
Example 58
Project: SunmiUI   File: DownUpActivity.java   Source Code and License 4 votes vote down vote up
/**
 * 初始化向下隐藏的动画(最下面菜单的)
 */
private void initHideAnimation() {
    mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, 0, -1.0f, Animation.RELATIVE_TO_SELF, 1.0f);
    mHiddenAction.setDuration(1000);
}
 
Example 59
Project: RippleValidatorEditText   File: RippleValidatorEditText.java   Source Code and License 4 votes vote down vote up
/**
 * Enter Error helper text With Animation
 */
private void showEntranceAnimation() {
  Animation viewAnimation= AnimationUtils.loadAnimation(getContext(),mHelperAnimation);
  mHelperTextView.startAnimation(viewAnimation);
}
 
Example 60
Project: decoy   File: SuperSwipeRefreshLayout.java   Source Code and License 4 votes vote down vote up
@Override
public void onAnimationRepeat(Animation animation) {
}