Search in sources :

Example 1 with ReflectionException

use of com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException in project mobile-android by photo.

the class AdjustImageViewFreeRotation method initImageView.

/**
	 * Inits the image view.
	 */
private void initImageView() {
    mMatrix = new Matrix();
    mScaleType = ScaleType.FIT_CENTER;
    Context context = getContext();
    int highlight_color = context.getResources().getColor(R.color.feather_rotate_highlight_stroke_color);
    int highlight_stroke_internal_color = context.getResources().getColor(R.color.feather_rotate_highlight_grid_stroke_color);
    int highlight_stroke_internal_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_grid_stroke_width);
    int highlight_outside_color = context.getResources().getColor(R.color.feather_rotate_highlight_outside);
    int highlight_stroke_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_stroke_width);
    mOutlinePaint.setStrokeWidth(highlight_stroke_width);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);
    mOutlinePaint.setColor(highlight_color);
    mOutlineFill.setStyle(Paint.Style.FILL);
    mOutlineFill.setAntiAlias(false);
    mOutlineFill.setColor(highlight_outside_color);
    mOutlineFill.setDither(false);
    try {
        ReflectionUtils.invokeMethod(mOutlineFill, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaint.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaint.setAntiAlias(false);
    mLinesPaint.setDither(false);
    mLinesPaint.setStyle(Paint.Style.STROKE);
    mLinesPaint.setColor(highlight_stroke_internal_color);
    try {
        ReflectionUtils.invokeMethod(mLinesPaint, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaintShadow.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaintShadow.setAntiAlias(true);
    mLinesPaintShadow.setColor(Color.BLACK);
    mLinesPaintShadow.setStyle(Paint.Style.STROKE);
    mLinesPaintShadow.setMaskFilter(new BlurMaskFilter(2, Blur.NORMAL));
    mOutlineFillAlpha = mOutlineFill.getAlpha();
    mOutlinePaintAlpha = mOutlinePaint.getAlpha();
    mLinesAlpha = mLinesPaint.getAlpha();
    mLinesShadowAlpha = mLinesPaintShadow.getAlpha();
    mOutlinePaint.setAlpha(0);
    mOutlineFill.setAlpha(0);
    mLinesPaint.setAlpha(0);
    mLinesPaintShadow.setAlpha(0);
    android.content.res.Resources resources = getContext().getResources();
    mResizeDrawable = resources.getDrawable(R.drawable.feather_highlight_crop_handle);
    double w = mResizeDrawable.getIntrinsicWidth();
    double h = mResizeDrawable.getIntrinsicHeight();
    handleWidth = (int) Math.ceil(w / 2.0);
    handleHeight = (int) Math.ceil(h / 2.0);
}
Also used : Context(android.content.Context) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) Matrix(android.graphics.Matrix) BlurMaskFilter(android.graphics.BlurMaskFilter) Paint(android.graphics.Paint) Resources(android.content.res.Resources)

Example 2 with ReflectionException

use of com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException in project mobile-android by photo.

the class AdjustImageView method initImageView.

/**
	 * Inits the image view.
	 */
private void initImageView() {
    mMatrix = new Matrix();
    mScaleType = ScaleType.FIT_CENTER;
    Context context = getContext();
    int highlight_color = context.getResources().getColor(R.color.feather_rotate_highlight_stroke_color);
    int highlight_stroke_internal_color = context.getResources().getColor(R.color.feather_rotate_highlight_grid_stroke_color);
    int highlight_stroke_internal_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_grid_stroke_width);
    int highlight_outside_color = context.getResources().getColor(R.color.feather_rotate_highlight_outside);
    int highlight_stroke_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_stroke_width);
    mOutlinePaint.setStrokeWidth(highlight_stroke_width);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);
    mOutlinePaint.setColor(highlight_color);
    mOutlineFill.setStyle(Paint.Style.FILL);
    mOutlineFill.setAntiAlias(false);
    mOutlineFill.setColor(highlight_outside_color);
    mOutlineFill.setDither(false);
    try {
        ReflectionUtils.invokeMethod(mOutlineFill, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaint.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaint.setAntiAlias(false);
    mLinesPaint.setDither(false);
    mLinesPaint.setStyle(Paint.Style.STROKE);
    mLinesPaint.setColor(highlight_stroke_internal_color);
    try {
        ReflectionUtils.invokeMethod(mLinesPaint, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaintShadow.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaintShadow.setAntiAlias(true);
    mLinesPaintShadow.setColor(Color.BLACK);
    mLinesPaintShadow.setStyle(Paint.Style.STROKE);
    mLinesPaintShadow.setMaskFilter(new BlurMaskFilter(2, Blur.NORMAL));
    mOutlineFillAlpha = mOutlineFill.getAlpha();
    mOutlinePaintAlpha = mOutlinePaint.getAlpha();
    mLinesAlpha = mLinesPaint.getAlpha();
    mLinesShadowAlpha = mLinesPaintShadow.getAlpha();
    mOutlinePaint.setAlpha(0);
    mOutlineFill.setAlpha(0);
    mLinesPaint.setAlpha(0);
    mLinesPaintShadow.setAlpha(0);
    android.content.res.Resources resources = getContext().getResources();
    mStraightenDrawable = resources.getDrawable(R.drawable.feather_straighten_knob);
    double w = mStraightenDrawable.getIntrinsicWidth();
    double h = mStraightenDrawable.getIntrinsicHeight();
    handleWidth = (int) Math.ceil(w / 2.0);
    handleHeight = (int) Math.ceil(h / 2.0);
}
Also used : Context(android.content.Context) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) Matrix(android.graphics.Matrix) BlurMaskFilter(android.graphics.BlurMaskFilter) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) Resources(android.content.res.Resources)

Example 3 with ReflectionException

use of com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException 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 4 with ReflectionException

use of com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException in project mobile-android by photo.

the class HorizontalFixedListView method initView.

/**
	 * Inits the view.
	 */
private synchronized void initView() {
    if (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);
    }
    mLeftViewIndex = -1;
    mRightViewIndex = 0;
    mMaxX = 0;
    mMinX = 0;
    mChildWidth = 0;
    mChildHeight = 0;
    mRightEdge = 0;
    mLeftEdge = 0;
    mGesture = new GestureDetector(getContext(), mGestureListener);
    mGesture.setIsLongpressEnabled(true);
    setFocusable(true);
    setFocusableInTouchMode(true);
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mDragTolerance = mTouchSlop;
    mOverscrollDistance = 10;
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
}
Also used : ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) ViewConfiguration(android.view.ViewConfiguration) GestureDetector(android.view.GestureDetector)

Example 5 with ReflectionException

use of com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException in project mobile-android by photo.

the class HighlightView method setup.

/**
	 * Setup.
	 * 
	 * @param m
	 *           the m
	 * @param imageRect
	 *           the image rect
	 * @param cropRect
	 *           the crop rect
	 * @param maintainAspectRatio
	 *           the maintain aspect ratio
	 */
public void setup(Matrix m, Rect imageRect, RectF cropRect, boolean maintainAspectRatio) {
    mMatrix = new Matrix(m);
    mCropRect = cropRect;
    mImageRect = new RectF(imageRect);
    mMaintainAspectRatio = maintainAspectRatio;
    double ratio = (double) mCropRect.width() / (double) mCropRect.height();
    mInitialAspectRatio = Math.round(ratio * 1000.0) / 1000.0;
    // Log.i( LOG_TAG, "aspect ratio: " + mInitialAspectRatio );
    computeLayout(true, mDrawRect);
    mOutlinePaint.setStrokeWidth(stroke_width);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(false);
    try {
        ReflectionUtils.invokeMethod(mOutlinePaint, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mOutlinePaint2.setStrokeWidth(internal_stroke_width);
    mOutlinePaint2.setStyle(Paint.Style.STROKE);
    mOutlinePaint2.setAntiAlias(false);
    mOutlinePaint2.setColor(highlight_internal_color);
    try {
        ReflectionUtils.invokeMethod(mOutlinePaint2, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mOutlineFill.setColor(highlight_outside_color);
    mOutlineFill.setStyle(Paint.Style.FILL);
    mOutlineFill.setAntiAlias(false);
    try {
        ReflectionUtils.invokeMethod(mOutlineFill, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaintShadow.setStrokeWidth(internal_stroke_width);
    mLinesPaintShadow.setAntiAlias(true);
    mLinesPaintShadow.setColor(Color.BLACK);
    mLinesPaintShadow.setStyle(Paint.Style.STROKE);
    mLinesPaintShadow.setMaskFilter(new BlurMaskFilter(2, Blur.NORMAL));
    setMode(Mode.None);
    init();
}
Also used : RectF(android.graphics.RectF) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) Matrix(android.graphics.Matrix) BlurMaskFilter(android.graphics.BlurMaskFilter)

Aggregations

ReflectionException (com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException)6 BlurMaskFilter (android.graphics.BlurMaskFilter)3 Matrix (android.graphics.Matrix)3 Paint (android.graphics.Paint)3 GestureDetector (android.view.GestureDetector)3 Context (android.content.Context)2 Resources (android.content.res.Resources)2 ViewConfiguration (android.view.ViewConfiguration)2 SuppressLint (android.annotation.SuppressLint)1 TypedArray (android.content.res.TypedArray)1 PaintFlagsDrawFilter (android.graphics.PaintFlagsDrawFilter)1 RectF (android.graphics.RectF)1 DisplayMetrics (android.util.DisplayMetrics)1 LinearGradientDrawable (com.aviary.android.feather.graphics.LinearGradientDrawable)1