private void init ( final Context context , final AttributeSet attrs ) { if ( isInEditMode ( ) ) return ; final TypedArray typedArray = context . obtainStyledAttributes ( attrs , R . styleable . RippleView ) ; rippleColor = typedArray . getColor ( R . styleable . RippleView_rv_color , getResources ( ) . getColor ( R . color . rippelColor ) ) ; rippleType = typedArray . getInt ( R . styleable . RippleView_rv_type , 0 ) ; hasToZoom = typedArray . getBoolean ( R . styleable . RippleView_rv_zoom , false ) ; isCentered = typedArray . getBoolean ( R . styleable . RippleView_rv_centered , false ) ; rippleDuration = typedArray . getInteger ( R . styleable . RippleView_rv_rippleDuration , rippleDuration ) ; frameRate = typedArray . getInteger ( R . styleable . RippleView_rv_framerate , frameRate ) ; rippleAlpha = typedArray . getInteger ( R . styleable . RippleView_rv_alpha , rippleAlpha ) ; ripplePadding = typedArray . getDimensionPixelSize ( R . styleable . RippleView_rv_ripplePadding , 0 ) ; canvasHandler = new Handler ( ) ; zoomScale = typedArray . getFloat ( R . styleable . RippleView_rv_zoomScale , 1.03f ) ; zoomDuration = typedArray . getInt ( R . styleable . RippleView_rv_zoomDuration , 200 ) ; typedArray . recycle ( ) ; paint = new Paint ( ) ; paint . setAntiAlias ( true ) ; paint . setStyle ( Paint . Style . FILL ) ; paint . setColor ( rippleColor ) ; paint . setAlpha ( rippleAlpha ) ; this . setWillNotDraw ( false ) ; gestureDetector = new GestureDetector ( context , new GestureDetector . SimpleOnGestureListener ( ) { @ Override public void onLongPress ( MotionEvent event ) { super . onLongPress ( event ) ; animateRipple ( event ) ; sendClickEvent ( true ) ; } @ Override public boolean onSingleTapConfirmed ( MotionEvent e ) { return true ; } @ Override public boolean onSingleTapUp ( MotionEvent e ) { return true ; } } ) ; this . setDrawingCacheEnabled ( true ) ; this . setClickable ( true ) ; }
Method that initializes all fields and sets listeners