Java Code Examples for android.view.animation.RotateAnimation#setDuration()

The following examples show how to use android.view.animation.RotateAnimation#setDuration() . 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: FlipLoadingLayout.java    From Alibaba-Android-Certification with MIT License 6 votes vote down vote up
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
Example 2
Source File: RotateLoadingLayout.java    From SweetMusicPlayer with Apache License 2.0 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 3
Source File: MultiListView.java    From WifiChat with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 实例化下拉刷新的箭头的动画效果
 * 
 * @param pAnimDuration
 *            动画运行时长
 * @date 2015年2月14日 上午11:17
 * @change hillfly
 */
private void initPullImageAnimation(final int pAnimDuration) {

    int _Duration;

    if (pAnimDuration > 0) {
        _Duration = pAnimDuration;
    }
    else {
        _Duration = 250;
    }

    Interpolator _Interpolator = new LinearInterpolator();

    mArrowAnim = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mArrowAnim.setInterpolator(_Interpolator);
    mArrowAnim.setDuration(_Duration);
    mArrowAnim.setFillAfter(true);

    mArrowReverseAnim = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mArrowReverseAnim.setInterpolator(_Interpolator);
    mArrowReverseAnim.setDuration(_Duration);
    mArrowReverseAnim.setFillAfter(true);
}
 
Example 4
Source File: FlipLoadingLayout.java    From ONE-Unofficial with Apache License 2.0 6 votes vote down vote up
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
Example 5
Source File: RotateLoadingLayout.java    From android-project-wo2b with Apache License 2.0 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 6
Source File: RotateLoadingLayout.java    From iSCAU-Android with GNU General Public License v3.0 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 7
Source File: FlipLoadingLayout.java    From GifAssistant with Apache License 2.0 6 votes vote down vote up
public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180;

	mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);
}
 
Example 8
Source File: CommonRefreshLayout.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
public RefreshHeader(Context context) {
    super(context);
    View header = LayoutInflater.from(context).inflate(R.layout.header_refresh_joke, this);
    loadView = header.findViewById(R.id.image_load);
    pullView = header.findViewById(R.id.image_down);
    errorView = header.findViewById(R.id.image_error);

    rotateAnim = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnim.setDuration(ROTATE_ANIM_DURATION);
    rotateAnim.setRepeatCount(-1);
    rotateAnim.setInterpolator(new LinearInterpolator());// 设置匀速,无加速度不卡顿
    rotateAnim.setRepeatMode(Animation.RESTART);

    showAnim = new AlphaAnimation(0, 1.0f);
    showAnim.setDuration(ROTATE_ANIM_DURATION);
    showAnim.setFillAfter(true);

    hideAnim = new AlphaAnimation(1.0f, 0);
    hideAnim.setDuration(ROTATE_ANIM_DURATION);
    hideAnim.setFillAfter(true);
}
 
Example 9
Source File: RotateLoadingLayout.java    From SwipeMenuAndRefresh with Apache License 2.0 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 10
Source File: WindmillDrawable.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
public WindmillDrawable(Context context, View parent) {
    resources = context.getResources();
    windmill = BitmapFactory.decodeResource(resources, R.drawable.windmill);

    matrix = new Matrix();

    this.parent = parent;


    animation = new RotateAnimation(360, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(800);
    animation.setRepeatMode(Animation.RESTART);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setFillAfter(true);

}
 
Example 11
Source File: DynamicRotationGuideView.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 右边的动画
 */
private void playRight() {
    //混合动画
    AnimationSet animationSet = new AnimationSet(false);
    RotateAnimation rotateRight = new RotateAnimation(0, 359, Animation.ABSOLUTE, screenW/2-right.getLeft(), Animation.ABSOLUTE, (right.getBottom()-right.getTop())/2);
    RotateAnimation rotateSelf = new RotateAnimation(0, -359, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    //播放时间
    rotateSelf.setDuration(10*1000);
    //播放加速的模式
    rotateSelf.setInterpolator(interpolator);
    //设置无限循环
    rotateSelf.setRepeatCount(-1);
    rotateRight.setDuration(10*1000);
    rotateRight.setRepeatCount(-1);
    rotateRight.setInterpolator(interpolator);
    animationSet.addAnimation(rotateSelf);
    animationSet.addAnimation(rotateRight);
    //播放混合动画
    right.startAnimation(animationSet);
}
 
Example 12
Source File: AnimationUtils.java    From v9porn with MIT License 5 votes vote down vote up
public static void rotateDown(View view) {
    RotateAnimation rotate = new RotateAnimation(180f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    LinearInterpolator lin = new LinearInterpolator();
    rotate.setInterpolator(lin);
    rotate.setDuration(200);
    rotate.setRepeatCount(0);
    rotate.setFillAfter(true);
    rotate.setStartOffset(10);
    view.startAnimation(rotate);
}
 
Example 13
Source File: EmptyLoadingView.java    From android_tv_metro with Apache License 2.0 5 votes vote down vote up
public void viewStartAnimation(ImageView view) {
	mProgressLayout.setVisibility(View.VISIBLE);
	mRotateAnim = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mRotateAnim.setInterpolator(new LinearInterpolator());
	mRotateAnim.setRepeatCount(Animation.INFINITE);
	mRotateAnim.setDuration(800);
	// mRotateAnim.setFillAfter(false);
	view.startAnimation(mRotateAnim);
}
 
Example 14
Source File: HTDefaultVerticalRefreshViewHolder.java    From ht-refreshrecyclerview with MIT License 5 votes vote down vote up
private void initAnimation() {
    mUpAnim = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mUpAnim.setDuration(200);
    mUpAnim.setFillAfter(true);

    mDownAnim = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mDownAnim.setDuration(200);
    mDownAnim.setFillAfter(true);
}
 
Example 15
Source File: EditSpinner.java    From EditSpinner with Apache License 2.0 5 votes vote down vote up
private void initAnimation() {
    mAnimation = new RotateAnimation(0, -90, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mAnimation.setDuration(300);
    mAnimation.setFillAfter(true);
    mResetAnimation = new RotateAnimation(-90, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    mResetAnimation.setDuration(300);
    mResetAnimation.setFillAfter(true);
}
 
Example 16
Source File: RotateLoadingLayout.java    From MagicHeaderViewPager with Apache License 2.0 5 votes vote down vote up
public RotateLoadingLayout(Context context, PullToRefreshBase.Mode mode, PullToRefreshBase.Orientation scrollDirection, TypedArray attrs, int layoutId) {
    super(context, mode, scrollDirection, attrs, layoutId);

    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 17
Source File: MainActivity.java    From AndroidMaryTTS-Client with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
    super.show();
    RotateAnimation anim = new RotateAnimation(0.0f, 360.0f, Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    anim.setInterpolator(new LinearInterpolator());
    anim.setRepeatCount(Animation.INFINITE);
    anim.setDuration(3000);
    iv.setAnimation(anim);
    iv.startAnimation(anim);
}
 
Example 18
Source File: DropDownListView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
/**
 * init drop down style, only init once
 */
private void initDropDownStyle() {
    if (headerLayout != null) {
        if (isDropDownStyle) {
            addHeaderView(headerLayout);
        } else {
            removeHeaderView(headerLayout);
        }
        return;
    }
    if (!isDropDownStyle) {
        return;
    }

    headerReleaseMinDistance = context.getResources().getDimensionPixelSize(
            R.dimen.drop_down_list_header_release_min_distance);
    flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(250);
    flipAnimation.setFillAfter(true);
    reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(250);
    reverseFlipAnimation.setFillAfter(true);

    headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
    headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
    headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
    headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);

    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    headerLayout = (RelativeLayout)inflater.inflate(R.layout.drop_down_list_header, this, false);
    headerText = (TextView)headerLayout.findViewById(R.id.drop_down_list_header_default_text);
    headerImage = (ImageView)headerLayout.findViewById(R.id.drop_down_list_header_image);
    headerProgressBar = (ProgressBar)headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
    headerSecondText = (TextView)headerLayout.findViewById(R.id.drop_down_list_header_second_text);
    headerLayout.setClickable(true);
    headerLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onDropDown();
        }
    });
    headerText.setText(headerDefaultText);
    addHeaderView(headerLayout);

    measureHeaderLayout(headerLayout);
    headerOriginalHeight = headerLayout.getMeasuredHeight();
    headerOriginalTopPadding = headerLayout.getPaddingTop();
    currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
 
Example 19
Source File: IndicatorLayout.java    From NetEasyNews with GNU General Public License v3.0 4 votes vote down vote up
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
	super(context);
	mArrowImageView = new ImageView(context);

	Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
	mArrowImageView.setImageDrawable(arrowD);

	final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
	mArrowImageView.setPadding(padding, padding, padding, padding);
	addView(mArrowImageView);

	int inAnimResId, outAnimResId;
	switch (mode) {
		case PULL_FROM_END:
			inAnimResId = R.anim.slide_in_from_bottom;
			outAnimResId = R.anim.slide_out_to_bottom;
			setBackgroundResource(R.drawable.indicator_bg_bottom);

			// Rotate Arrow so it's pointing the correct way
			mArrowImageView.setScaleType(ScaleType.MATRIX);
			Matrix matrix = new Matrix();
			matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
			mArrowImageView.setImageMatrix(matrix);
			break;
		default:
		case PULL_FROM_START:
			inAnimResId = R.anim.slide_in_from_top;
			outAnimResId = R.anim.slide_out_to_top;
			setBackgroundResource(R.drawable.indicator_bg_top);
			break;
	}

	mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
	mInAnim.setAnimationListener(this);

	mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
	mOutAnim.setAnimationListener(this);

	final Interpolator interpolator = new LinearInterpolator();
	mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(interpolator);
	mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setFillAfter(true);

	mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
			Animation.RELATIVE_TO_SELF, 0.5f);
	mResetRotateAnimation.setInterpolator(interpolator);
	mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
	mResetRotateAnimation.setFillAfter(true);

}
 
Example 20
Source File: JamTrendArrowImpl.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean update(final Double mgdl) {
    final ImageView myArrow = getMyArrow();
    if (mgdl != null) {

        final float newRotation = calculateRotation(mgdl);

        // not initialized
        if (lastRotation == -1000) {
            lastRotation = newRotation;
        }

        final RotateAnimation rotateAnimation = new RotateAnimation(
                lastRotation,
                newRotation,
                Animation.RELATIVE_TO_SELF,
                0.5f,
                Animation.RELATIVE_TO_SELF,
                0.5f);
        rotateAnimation.setDuration(1000);
        rotateAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
        rotateAnimation.setFillAfter(true);

        lastRotation = newRotation;

        myArrow.startAnimation(rotateAnimation);
        final float newScale = calculateScale(mgdl);
        myArrow.setScaleX(newScale * getSourceScaleAdjust());
        myArrow.setScaleY(newScale * getSourceScaleAdjust());
        myArrow.setVisibility(View.VISIBLE);

        myArrow.setColorFilter(colorfilter);

        return false;
    } else {
        myArrow.setVisibility(View.GONE);
        myArrow.setScaleX(0.0001f);
        myArrow.setScaleY(0.0001f);
    }
    return true;
}