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

The following examples show how to use android.view.animation.RotateAnimation#setInterpolator() . 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: PullToRefreshView.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * init
 *
 * @param
 * @description
 */
private void init() {
    // Load all of the animations we need in code rather than through XML
    mFlipAnimation = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    mInflater = LayoutInflater.from(getContext());
    // header view 在此添加,保证是第一个添加到linearlayout的最上端
    addHeaderView();
}
 
Example 3
Source File: FlipLoadingLayout.java    From Social 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 4
Source File: FlipLoadingLayout.java    From RefreashTabView 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: FlipLoadingLayout.java    From bmob-android-demo-paging with GNU General Public License v3.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 6
Source File: FlipLoadingLayout.java    From MagicHeaderViewPager with Apache License 2.0 6 votes vote down vote up
public FlipLoadingLayout(Context context, final PullToRefreshBase.Mode mode, final PullToRefreshBase.Orientation scrollDirection, TypedArray attrs, int layoutId) {
    super(context, mode, scrollDirection, attrs, layoutId);

    final int rotateAngle=mode == PullToRefreshBase.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 7
Source File: RotateLoadingLayout.java    From sctalk 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 8
Source File: CircleProgressBar.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
private void initView(Context context, AttributeSet attrs) {
    CircleProgressDrawable drawable = new CircleProgressDrawable();
    if (null != attrs) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, 0, 0);
        int arcColor = a.getColor(R.styleable.CircleProgressBar_color_arc, 0);
        int bgColor = a.getColor(R.styleable.CircleProgressBar_color_background, 0);
        float strokeWidth = a.getDimension(R.styleable.CircleProgressBar_stroke_width, 5.f);
        drawable.setStrokeWidth(strokeWidth);
        drawable.setArcColor(arcColor);
        drawable.setBackgroundColor(bgColor);
        a.recycle();
    }
    setImageDrawable(drawable);
    mAnimation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimation.setDuration(800);
    mAnimation.setInterpolator(new LinearInterpolator());
    mAnimation.setRepeatCount(-1);
    mAnimation.setRepeatMode(RotateAnimation.RESTART);
    startAnimation(mAnimation);
}
 
Example 9
Source File: AnimationUtils.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public static RotateAnimation initRotateAnimation(boolean isClockWise, long duration,
        boolean isFillAfter, int repeatCount) {
    int endAngle;
    if (isClockWise) {
        endAngle = 360;
    } else {
        endAngle = -360;
    }
    RotateAnimation mLoadingRotateAnimation = new RotateAnimation(0, endAngle,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    LinearInterpolator lirInterpolator = new LinearInterpolator();
    mLoadingRotateAnimation.setInterpolator(lirInterpolator);
    mLoadingRotateAnimation.setDuration(duration);
    mLoadingRotateAnimation.setFillAfter(isFillAfter);
    mLoadingRotateAnimation.setRepeatCount(repeatCount);
    mLoadingRotateAnimation.setRepeatMode(Animation.RESTART);
    return mLoadingRotateAnimation;
}
 
Example 10
Source File: MonsterFaceRecyclerAdapter.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
/**
 * 显示进度动画
 */
public void showProgressAnimation(ImageView view) {
    if (view == null) return;

    view.setVisibility(View.VISIBLE);
    RotateAnimation rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    LinearInterpolator lin = new LinearInterpolator();
    rotate.setInterpolator(lin);
    rotate.setDuration(2000);
    rotate.setRepeatCount(-1);
    rotate.setFillAfter(true);

    view.setAnimation(rotate);

}
 
Example 11
Source File: FlipLoadingLayout.java    From FacebookNewsfeedSample-Android 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 12
Source File: RefreshActionItem.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
public void startProgress(){
    if (mRefreshButton.getAnimation() != null)
        return;
    RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(500);
    rotateAnimation.setFillAfter(false);
    rotateAnimation.setRepeatCount(-1);
    rotateAnimation.setRepeatMode(Animation.RESTART);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    mRefreshButton.startAnimation(rotateAnimation);
}
 
Example 13
Source File: EverydayFragment.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
private void initAnimation() {
    bindingView.llLoading.setVisibility(View.VISIBLE);
    animation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(3000);//设置动画持续时间
    animation.setInterpolator(new LinearInterpolator());//不停顿
    animation.setRepeatMode(ValueAnimator.RESTART);//重新从头执行
    animation.setRepeatCount(ValueAnimator.INFINITE);//设置重复次数
    bindingView.ivLoading.setAnimation(animation);
    animation.startNow();
}
 
Example 14
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 15
Source File: RotateImageView.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * 设置动画效果
 */
private void setRotateAnimation() {
    if (mIsHasAnimation == false && getWidth() > 0 && getVisibility() == View.VISIBLE) {
        mIsHasAnimation = true;
        mAnimation = new RotateAnimation(0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        mAnimation.setDuration(1000L);
        mAnimation.setInterpolator(new LinearInterpolator());
        mAnimation.setRepeatCount(-1);
        mAnimation.setRepeatMode(Animation.RESTART);
        setAnimation(mAnimation);
    }
}
 
Example 16
Source File: ExpandIconStateHelper.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
public static void animateSetExpanded(View view, boolean expanded) {
    view.setRotation(expanded ? 180.f : 0.f);
    int toDegrees = (expanded ? 0 : 360);
    RotateAnimation rotate = new RotateAnimation(180, toDegrees,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(250);
    rotate.setInterpolator(new AccelerateDecelerateInterpolator());
    view.startAnimation(rotate);
}
 
Example 17
Source File: PullToRefreshListView.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void init(Context context) {
    // Load all of the animations we need in code rather than through XML
    mFlipAnimation = new RotateAnimation(0, 180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(180, 360,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);

    LayoutInflater mInflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    mRefreshView = (LinearLayout) mInflater.inflate(
            R.layout.widget_pull_to_refresh_header, null);

    mRefreshViewText =
        (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
    mRefreshViewImage =
        (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
    mRefreshViewProgress =
        (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
    mRefreshViewLastUpdated =
        (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at);

    Theme theme = new Theme(context);
    mRefreshViewText.setTextColor(theme.getColor("content"));
    
    mRefreshViewImage.setMinimumHeight(50);
    mRefreshView.setOnClickListener(new OnClickRefreshListener());
    mRefreshOriginalTopPadding = mRefreshView.getPaddingTop();

    mRefreshState = TAP_TO_REFRESH;

    addHeaderView(mRefreshView);

    super.setOnScrollListener(this);

    measureView(mRefreshView);
    mRefreshViewHeight = mRefreshView.getMeasuredHeight();
}
 
Example 18
Source File: EBounceViewHeader.java    From appcan-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
public EBounceViewHeader(Context context, int type) {
    super(context);
    setWillNotDraw(true);
    setBackgroundColor(0);
    setFocusable(false);
    ESystemInfo intence = ESystemInfo.getIntence();
    int height = intence.mDefaultBounceHeight;
    RelativeLayout wapper = new RelativeLayout(context);
    wapper.setWillNotDraw(true);
    wapper.setBackgroundColor(0);
    wapper.setFocusable(false);
    RelativeLayout.LayoutParams wParm = new LayoutParams(-1, height);
    if (type == EViewEntry.F_BOUNCE_TYPE_TOP) {
        wParm.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    } else {
        wParm.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    }
    wapper.setLayoutParams(wParm);
    addView(wapper);

    wap = new RelativeLayout(context);
    wap.setId(F_WAP_ID);
    RelativeLayout.LayoutParams wm = new LayoutParams(-2, height);
    wm.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    wm.leftMargin = 30;
    wap.setLayoutParams(wm);

    mContent = new TextView(context);
    mContent.setId(F_CONTENT_ID);
    RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
    parmMsg.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mContent.setLayoutParams(parmMsg);
    mContent.setTextColor(textColor);
    mContent.setText(pullToReloadText);
    mContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize));
    mContent.setVisibility(GONE);
    wap.addView(mContent);

    mLevelContent = new TextView(context);
    RelativeLayout.LayoutParams parml = new LayoutParams(-2, -2);
    parml.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    parml.addRule(RelativeLayout.BELOW, F_CONTENT_ID);
    mLevelContent.setLayoutParams(parml);
    mLevelContent.setTextColor(textColor);
    mLevelContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize * 0.6));
    mLevelContent.setVisibility(GONE);
    wap.addView(mLevelContent);

    wapper.addView(wap);

    mProgress = new ProgressBar(context);
    mProgress.setIndeterminate(true);
    int use = height - 12;
    RelativeLayout.LayoutParams parmPro = new LayoutParams(use, use);
    parmPro.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmPro.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mProgress.setLayoutParams(parmPro);
    mProgress.setVisibility(GONE);
    wapper.addView(mProgress);

    mYAxisProgress = new YAxisImageView(context);
    int useY = height - 12;
    RelativeLayout.LayoutParams parmProY = new LayoutParams(useY, useY);
    parmProY.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmProY.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mYAxisProgress.setLayoutParams(parmProY);
    mYAxisProgress.setVisibility(GONE);
    wapper.addView(mYAxisProgress);

    mArrowImage = new ImageView(context);
    int useA = height - 12;
    RelativeLayout.LayoutParams parmImage = new LayoutParams(useA, useA);
    parmImage.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmImage.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mArrowImage.setLayoutParams(parmImage);
    Drawable icon = context.getResources().getDrawable(EResources.platform_myspace_pulltorefresh_arrow);
    mArrowImage.setImageDrawable(icon);
    mArrowImage.setVisibility(GONE);
    wapper.addView(mArrowImage);

    mAnimationUp = new RotateAnimation(-180, 0,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimationUp.setInterpolator(new AccelerateInterpolator());
    mAnimationUp.setDuration(250);
    mAnimationUp.setFillAfter(true);

    mAnimationDown = new RotateAnimation(0, -180,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mAnimationDown.setInterpolator(new AccelerateInterpolator());
    mAnimationDown.setDuration(250);
    mAnimationDown.setFillAfter(true);
}
 
Example 19
Source File: IndicatorLayout.java    From Social with Apache License 2.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: IndicatorLayout.java    From SwipeMenuAndRefresh with Apache License 2.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);

}