Search in sources :

Example 1 with LinearGradientDrawable

use of com.aviary.android.feather.graphics.LinearGradientDrawable in project mobile-android by photo.

the class Wheel method init.

/**
	 * Inits the.
	 * 
	 * @param context
	 *           the context
	 * @param attrs
	 *           the attrs
	 * @param defStyle
	 *           the def style
	 */
private void init(Context context, AttributeSet attrs, int defStyle) {
    if (android.os.Build.VERSION.SDK_INT > 8) {
        try {
            mFlingRunnable = (IFlingRunnable) ReflectionUtils.newInstance("com.aviary.android.feather.widget.Fling9Runnable", new Class<?>[] { FlingRunnableView.class, int.class }, this, mAnimationDuration);
        } catch (ReflectionException e) {
            mFlingRunnable = new Fling8Runnable(this, mAnimationDuration);
        }
    } else {
        mFlingRunnable = new Fling8Runnable(this, mAnimationDuration);
    }
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Wheel, defStyle, 0);
    mTicksCount = a.getInteger(R.styleable.Wheel_ticks, 18);
    mWheelSizeFactor = a.getInteger(R.styleable.Wheel_numRotations, 2);
    a.recycle();
    mFast = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG, 0);
    mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
    mGestureDetector = new GestureDetector(context, this);
    mGestureDetector.setIsLongpressEnabled(false);
    setFocusable(true);
    setFocusableInTouchMode(true);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    TypedValue.complexToDimensionPixelSize(25, metrics);
    try {
        mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    } catch (Exception e) {
        Log.e(LOG_TAG, e.toString());
    }
    if (mVibrator != null) {
        setVibrationEnabled(true);
    }
    setBackgroundDrawable(new LinearGradientDrawable(Orientation.LEFT_RIGHT, mBgColors, mBgPositions));
}
Also used : ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) TypedArray(android.content.res.TypedArray) GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint) PaintFlagsDrawFilter(android.graphics.PaintFlagsDrawFilter) LinearGradientDrawable(com.aviary.android.feather.graphics.LinearGradientDrawable) DisplayMetrics(android.util.DisplayMetrics) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException)

Example 2 with LinearGradientDrawable

use of com.aviary.android.feather.graphics.LinearGradientDrawable in project mobile-android by photo.

the class Wheel method setBackgroundColors.

/**
	 * Change the background gradient colors. the size of the colors array must be the same as the size of the positions array.
	 * 
	 * @param colors
	 * @param positions
	 */
public void setBackgroundColors(int[] colors, float[] positions) {
    if (colors != null && positions != null && colors.length == positions.length) {
        mBgColors = colors;
        mBgPositions = positions;
        setBackgroundDrawable(new LinearGradientDrawable(Orientation.LEFT_RIGHT, mBgColors, mBgPositions));
    }
}
Also used : LinearGradientDrawable(com.aviary.android.feather.graphics.LinearGradientDrawable)

Aggregations

LinearGradientDrawable (com.aviary.android.feather.graphics.LinearGradientDrawable)2 TypedArray (android.content.res.TypedArray)1 Paint (android.graphics.Paint)1 PaintFlagsDrawFilter (android.graphics.PaintFlagsDrawFilter)1 DisplayMetrics (android.util.DisplayMetrics)1 GestureDetector (android.view.GestureDetector)1 ReflectionException (com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException)1