private void parseAttributes ( TypedArray a ) { // We transform the default values from DIP to pixels DisplayMetrics metrics = getContext ( ) . getResources ( ) . getDisplayMetrics ( ) ; barWidth = ( int ) TypedValue . applyDimension ( TypedValue . COMPLEX_UNIT_DIP , barWidth , metrics ) ; rimWidth = ( int ) TypedValue . applyDimension ( TypedValue . COMPLEX_UNIT_DIP , rimWidth , metrics ) ; circleRadius = ( int ) TypedValue . applyDimension ( TypedValue . COMPLEX_UNIT_DIP , circleRadius , metrics ) ; circleRadius = ( int ) a . getDimension ( R . styleable . ProgressWheel_matProg_circleRadius , circleRadius ) ; fillRadius = a . getBoolean ( R . styleable . ProgressWheel_matProg_fillRadius , false ) ; barWidth = ( int ) a . getDimension ( R . styleable . ProgressWheel_matProg_barWidth , barWidth ) ; rimWidth = ( int ) a . getDimension ( R . styleable . ProgressWheel_matProg_rimWidth , rimWidth ) ; float baseSpinSpeed = a . getFloat ( R . styleable . ProgressWheel_matProg_spinSpeed , spinSpeed / 360.0f ) ; spinSpeed = baseSpinSpeed * 360 ; barSpinCycleTime = a . getInt ( R . styleable . ProgressWheel_matProg_barSpinCycleTime , ( int ) barSpinCycleTime ) ; barColor = a . getColor ( R . styleable . ProgressWheel_matProg_barColor , barColor ) ; rimColor = a . getColor ( R . styleable . ProgressWheel_matProg_rimColor , rimColor ) ; linearProgress = a . getBoolean ( R . styleable . ProgressWheel_matProg_linearProgress , false ) ; if ( a . getBoolean ( R . styleable . ProgressWheel_matProg_progressIndeterminate , false ) ) { spin ( ) ; } // Recycle a . recycle ( ) ; }
Parse the attributes passed to the view from the XML