Java Code Examples for android.view.animation.AnimationUtils.loadInterpolator()

The following are Jave code examples for showing how to use loadInterpolator() of the android.view.animation.AnimationUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: OpenWithX   File: ResolverDrawerLayout.java   Source Code and License Vote up 6 votes
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout,
            defStyleAttr, 0);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth, -1);
    mMaxCollapsedHeight = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0);
    mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
            R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,
            mMaxCollapsedHeight);
    a.recycle();

    mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);

    mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
            android.R.interpolator.decelerate_quint));
    mVelocityTracker = VelocityTracker.obtain();

    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();

    setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
 
Example 2
Project: RollSquareView   File: RollSquareView.java   Source Code and License Vote up 6 votes
private void initAttrs(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RollSquareView);
    mLineCount = typedArray.getInteger(R.styleable.RollSquareView_line_count, 3);
    mRollRoundCornor = typedArray.getFloat(R.styleable.RollSquareView_roll_round_cornor, 10);
    mFixRoundCornor = typedArray.getFloat(R.styleable.RollSquareView_fix_round_cornor, 10);
    int rollInterpolatorResId = typedArray.getResourceId(R.styleable.RollSquareView_roll_interpolator,
            android.R.anim.linear_interpolator);
    mRollInterpolator = AnimationUtils.loadInterpolator(context, rollInterpolatorResId);
    int defaultColor = context.getResources().getColor(R.color.default_color);
    mSquareColor = typedArray.getColor(R.styleable.RollSquareView_square_color, defaultColor);
    mSpeed = typedArray.getInteger(R.styleable.RollSquareView_roll_speed, 250);
    if (mLineCount < 2) {
        mLineCount = 2;//至少要四个方块
    }
    mHalfSquareWidth = typedArray.getDimension(R.styleable.RollSquareView_half_rect_width, 30);
    mDividerWidth = typedArray.getDimension(R.styleable.RollSquareView_rect_divier_width, 10);
    mIsClockwise = typedArray.getBoolean(R.styleable.RollSquareView_is_clockwise, true);
    mStartEmptyPosition = typedArray.getInteger(R.styleable.RollSquareView_start_empty_position, 0);
    if (isInsideTheRect(mStartEmptyPosition, mLineCount)) {
        mStartEmptyPosition = 0;
    }
    mCurrEmptyPosition = mStartEmptyPosition;
    typedArray.recycle();
}
 
Example 3
Project: PatternLockView   File: PatternLockView.java   Source Code and License Vote up 6 votes
private void initView() {
    setClickable(true);

    mPathPaint = new Paint();
    mPathPaint.setAntiAlias(true);
    mPathPaint.setDither(true);
    mPathPaint.setColor(mNormalStateColor);
    mPathPaint.setStyle(Paint.Style.STROKE);
    mPathPaint.setStrokeJoin(Paint.Join.ROUND);
    mPathPaint.setStrokeCap(Paint.Cap.ROUND);
    mPathPaint.setStrokeWidth(mPathWidth);

    mDotPaint = new Paint();
    mDotPaint.setAntiAlias(true);
    mDotPaint.setDither(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
            && !isInEditMode()) {
        mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(
                getContext(), android.R.interpolator.fast_out_slow_in);
        mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(
                getContext(), android.R.interpolator.linear_out_slow_in);
    }
}
 
Example 4
Project: Huahui-Android   File: QueryActivity.java   Source Code and License Vote up 5 votes
/**
 * 使用方式二:调用setupSharedEelementTransitions2方法
 * 使用这种方式的话需要的类是 MorphDrawable, MorphTransition
 */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void setupSharedEelementTransitions2() {
    ArcMotion arcMotion = new ArcMotion();
    arcMotion.setMinimumHorizontalAngle(50f);
    arcMotion.setMinimumVerticalAngle(50f);

    Interpolator easeInOut = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);

    //hujiawei 100是随意给的一个数字,可以修改,需要注意的是这里调用container.getHeight()结果为0
    MorphTransition sharedEnter = new MorphTransition(ContextCompat.getColor(this, R.color.colorPrimary),
            ContextCompat.getColor(this, R.color.white), 100, getResources().getDimensionPixelSize(R.dimen.dialog_corners), true);
    sharedEnter.setPathMotion(arcMotion);
    sharedEnter.setInterpolator(easeInOut);

    MorphTransition sharedReturn = new MorphTransition(ContextCompat.getColor(this, R.color.colorPrimary),
            ContextCompat.getColor(this, R.color.white), getResources().getDimensionPixelSize(R.dimen.dialog_corners), 100, false);
    sharedReturn.setPathMotion(arcMotion);
    sharedReturn.setInterpolator(easeInOut);

    if (container != null) {
        sharedEnter.addTarget(container);
        sharedReturn.addTarget(container);
    }
    getWindow().setSharedElementEnterTransition(sharedEnter);
    getWindow().setSharedElementReturnTransition(sharedReturn);
}
 
Example 5
Project: AmenEye   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static Interpolator getFastOutSlowInInterpolator(Context context) {
    if (fastOutSlowIn == null) {
        fastOutSlowIn = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_slow_in);
    }
    return fastOutSlowIn;
}
 
Example 6
Project: android_ui   File: SearchView.java   Source Code and License Vote up 5 votes
/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
@SuppressWarnings("ResourceType")
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	this.mContext = context;
	setOrientation(LinearLayout.HORIZONTAL);
	setGravity(Gravity.CENTER_VERTICAL);
	this.inflateHierarchy(context, R.layout.ui_search_view);
	this.mProgressBarAnimator = createProgressBarAnimator();
	this.mDefaultRevealAnimationHandler = createRevealAnimationHandler();
	ColorStateList tintList = null;
	PorterDuff.Mode tintMode = PorterDuff.Mode.SRC_IN;

	final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Ui_SearchView, defStyleAttr, defStyleRes);
	for (int i = 0; i < attributes.getIndexCount(); i++) {
		final int index = attributes.getIndex(i);
		if (index == R.styleable.Ui_SearchView_android_queryHint) {
			setQueryHint(attributes.getText(index));
		} else if (index == R.styleable.Ui_SearchView_uiTint) {
			tintList = attributes.getColorStateList(index);
		} else if (index == R.styleable.Ui_SearchView_uiTintMode) {
			tintMode = TintManager.parseTintMode(
					attributes.getInt(R.styleable.Ui_SearchView_uiTintMode, 0),
					tintList != null ? PorterDuff.Mode.SRC_IN : null
			);
		} else if (index == R.styleable.Ui_SearchView_uiRevealDuration) {
			mDefaultRevealAnimationHandler.revealDuration = attributes.getInt(index, 0);
		} else if (index == R.styleable.Ui_SearchView_uiConcealDuration) {
			mDefaultRevealAnimationHandler.concealDuration = attributes.getInt(index, 0);
		} else if (index == R.styleable.Ui_SearchView_uiRevealInterpolator) {
			final int resId = attributes.getResourceId(index, 0);
			if (resId != 0) {
				mDefaultRevealAnimationHandler.interpolator = AnimationUtils.loadInterpolator(context, resId);
			}
		}
	}
	attributes.recycle();

	if (tintList != null || tintMode != null) {
		this.mTintInfo = new SearchTintInfo();
		this.mTintInfo.tintList = tintList;
		this.mTintInfo.hasTintList = tintList != null;
		this.mTintInfo.tintMode = tintMode;
		this.mTintInfo.hasTintMode = tintMode != null;
	}
	final Resources.Theme theme = context.getTheme();
	final TypedValue typedValue = new TypedValue();
	if (theme.resolveAttribute(R.attr.uiSearchSelectHandleColor, typedValue, true)) {
		if (mTintInfo == null) {
			this.mTintInfo = new SearchTintInfo();
		}
		if (typedValue.resourceId > 0) {
			mTintInfo.textSelectHandleTintList = ResourceUtils.getColorStateList(
					getResources(),
					typedValue.resourceId,
					theme
			);
		} else {
			mTintInfo.textSelectHandleTintList = ColorStateList.valueOf(typedValue.data);
		}
		mTintInfo.hasTextSelectHandleTintList = mTintInfo.textSelectHandleTintList != null;
	}
	this.applyTint();
	this.mRevealAnimationHandler = mDefaultRevealAnimationHandler;
}
 
Example 7
Project: garras   File: AnimUtils.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Interpolator getFastOutSlowInInterpolator(Context context) {
    if (fastOutSlowIn == null) {
        fastOutSlowIn = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_slow_in);
    }
    return fastOutSlowIn;
}
 
Example 8
Project: YiZhi   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static Interpolator getFastOutSlowInInterpolator(Context context) {
    if (fastOutSlowIn == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            fastOutSlowIn = AnimationUtils.loadInterpolator(context,
                    android.R.interpolator.fast_out_slow_in);
        }
    }
    return fastOutSlowIn;
}
 
Example 9
Project: YiZhi   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static Interpolator getFastOutLinearInInterpolator(Context context) {
    if (fastOutLinearIn == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            fastOutLinearIn = AnimationUtils.loadInterpolator(context,
                    android.R.interpolator.fast_out_linear_in);
        }
    }
    return fastOutLinearIn;
}
 
Example 10
Project: AmenEye   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static Interpolator getLinearOutSlowInInterpolator(Context context) {
    if (linearOutSlowIn == null) {
        linearOutSlowIn = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.linear_out_slow_in);
    }
    return linearOutSlowIn;
}
 
Example 11
Project: firefox-tv   File: AnimatedProgressBar.java   Source Code and License Vote up 5 votes
private Drawable buildWrapDrawable(Drawable original, boolean isWrap, int duration, int resID) {
    if (isWrap) {
        final Interpolator interpolator = (resID > 0)
                ? AnimationUtils.loadInterpolator(getContext(), resID)
                : null;
        final ShiftDrawable wrappedDrawable = new ShiftDrawable(original, duration, interpolator);
        return wrappedDrawable;
    } else {
        return original;
    }
}
 
Example 12
Project: Mire   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static Interpolator getFastOutSlowInInterpolator(Context context) 
{
       if (fastOutSlowIn == null) 
	{
           fastOutSlowIn = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in);
       }
       return fastOutSlowIn;
   }
 
Example 13
Project: xifan   File: FloatLabelLayout.java   Source Code and License Vote up 5 votes
public FloatLabelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setOrientation(VERTICAL);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding =
            a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
                    dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding =
            a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
                    dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding =
            a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
                    dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    mLabel.setTextAppearance(context,
            a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
                    android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                    ? android.R.interpolator.fast_out_slow_in
                    : android.R.anim.decelerate_interpolator);
}
 
Example 14
Project: AmenEye   File: AnimUtils.java   Source Code and License Vote up 5 votes
public static Interpolator getFastOutLinearInInterpolator(Context context) {
    if (fastOutLinearIn == null) {
        fastOutLinearIn = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_linear_in);
    }
    return fastOutLinearIn;
}
 
Example 15
Project: GitHub   File: InfiniteCycleManager.java   Source Code and License Vote up 4 votes
public void processAttributeSet(final AttributeSet attributeSet) {
    if (attributeSet == null) return;
    final TypedArray typedArray = mContext.obtainStyledAttributes(
            attributeSet, mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager :
                    R.styleable.HorizontalInfiniteCycleViewPager
    );
    try {
        setMinPageScaleOffset(
                typedArray.getDimension(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_min_page_scale_offset :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_min_page_scale_offset,
                        DEFAULT_MIN_PAGE_SCALE_OFFSET
                )
        );
        setCenterPageScaleOffset(
                typedArray.getDimension(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_center_page_scale_offset :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_center_page_scale_offset,
                        DEFAULT_CENTER_PAGE_SCALE_OFFSET
                )
        );
        setMinPageScale(
                typedArray.getFloat(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_min_page_scale :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_min_page_scale,
                        DEFAULT_MIN_SCALE
                )
        );
        setMaxPageScale(
                typedArray.getFloat(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_max_page_scale :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_max_page_scale,
                        DEFAULT_MAX_SCALE
                )
        );
        setMediumScaled(
                typedArray.getBoolean(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_medium_scaled :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_medium_scaled,
                        DEFAULT_IS_MEDIUM_SCALED
                )
        );
        setScrollDuration(
                typedArray.getInteger(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_scroll_duration :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_scroll_duration,
                        DEFAULT_SCROLL_DURATION
                )
        );
        setPageDuration(
                typedArray.getInteger(
                        mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_page_duration :
                                R.styleable.HorizontalInfiniteCycleViewPager_icvp_page_duration,
                        DEFAULT_SCROLL_DURATION
                )
        );

        // Retrieve interpolator
        Interpolator interpolator = null;
        try {
            final int interpolatorId = typedArray.getResourceId(
                    mIsVertical ? R.styleable.VerticalInfiniteCycleViewPager_icvp_interpolator :
                            R.styleable.HorizontalInfiniteCycleViewPager_icvp_interpolator, 0
            );
            interpolator = interpolatorId == 0 ? null :
                    AnimationUtils.loadInterpolator(mContext, interpolatorId);
        } catch (Resources.NotFoundException exception) {
            interpolator = null;
            exception.printStackTrace();
        } finally {
            setInterpolator(interpolator);
        }
    } finally {
        typedArray.recycle();
    }
}
 
Example 16
Project: MakiLite   File: Fab.java   Source Code and License Vote up 4 votes
private Interpolator getInterpolator() {
    return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator);
}
 
Example 17
Project: AndroidOpen   File: RevealActivity.java   Source Code and License Vote up 4 votes
private void setupWindowAnimations() {
    interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in);
    setupEnterAnimations();
    setupExitAnimations();
}
 
Example 18
Project: AstronomyTourPadova   File: AtFab.java   Source Code and License Vote up 4 votes
private Interpolator getInterpolator() {
    return AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.accelerate_decelerate);
}
 
Example 19
Project: FindX   File: Fab.java   Source Code and License Vote up 4 votes
private Interpolator getInterpolator() {
    return AnimationUtils.loadInterpolator(getContext(), R.interpolator.msf_interpolator);
}
 
Example 20
Project: Kawaii_LoadingView   File: Utils.java   Source Code and License Vote up 4 votes
/**
 * 步骤1:初始化动画的属性
 */
private void initAttrs(Context context, AttributeSet attrs) {

    // 控件资源名称
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Kawaii_LoadingView);

    // 方块行数量(最少3行)
    lineNumber = typedArray.getInteger(R.styleable.Kawaii_LoadingView_lineNumber, 3);
    if (lineNumber < 3) {
        lineNumber = 3;
    }

    // 半个方块的宽度(dp)
    half_BlockWidth = typedArray.getDimension(R.styleable.Kawaii_LoadingView_half_BlockWidth, 30);
    // 方块间隔宽度(dp)
    blockInterval = typedArray.getDimension(R.styleable.Kawaii_LoadingView_blockInterval, 10);

    // 移动方块的圆角半径
    moveBlock_Angle = typedArray.getFloat(R.styleable.Kawaii_LoadingView_moveBlock_Angle, 10);
    // 固定方块的圆角半径
    fixBlock_Angle = typedArray.getFloat(R.styleable.Kawaii_LoadingView_fixBlock_Angle, 30);
    // 通过设置两个方块的圆角半径使得二者不同可以得到更好的动画效果哦

    // 方块颜色(使用十六进制代码,如#333、#8e8e8e)
    int defaultColor = context.getResources().getColor(R.color.colorAccent); // 默认颜色
    blockColor = typedArray.getColor(R.styleable.Kawaii_LoadingView_blockColor, defaultColor);

    // 移动方块的初始位置(即空白位置)
    initPosition = typedArray.getInteger(R.styleable.Kawaii_LoadingView_initPosition, 0);

    // 由于移动方块只能是外部方块,所以这里需要判断方块是否属于外部方块 -->关注1
    if (isInsideTheRect(initPosition, lineNumber)) {
        initPosition = 0;
    }
    // 动画方向是否 = 顺时针旋转
    isClock_Wise = typedArray.getBoolean(R.styleable.Kawaii_LoadingView_isClock_Wise, true);

    // 移动方块的移动速度
    // 注:不建议使用者将速度调得过快
    // 因为会导致ValueAnimator动画对象频繁重复的创建,存在内存抖动
    moveSpeed = typedArray.getInteger(R.styleable.Kawaii_LoadingView_moveSpeed, 250);

    // 设置移动方块动画的插值器
    int move_InterpolatorResId = typedArray.getResourceId(R.styleable.Kawaii_LoadingView_move_Interpolator,
            android.R.anim.linear_interpolator);
    move_Interpolator = AnimationUtils.loadInterpolator(context, move_InterpolatorResId);

    // 当方块移动后,需要实时更新的空白方块的位置
    mCurrEmptyPosition = initPosition;

    // 释放资源
    typedArray.recycle();
}