@@ -3,14 +3,14 @@ package com.hjq.demo.other
33import android.content.Context
44import android.content.res.TypedArray
55import android.graphics.Canvas
6- import android.graphics.Color
76import android.graphics.Paint
87import android.graphics.Path
98import android.util.AttributeSet
109import android.widget.ImageView
1110import androidx.annotation.ColorInt
1211import androidx.annotation.ColorRes
1312import androidx.core.content.ContextCompat
13+ import androidx.core.graphics.toColorInt
1414import com.hjq.demo.R
1515import com.hjq.smallest.width.dp2px
1616import com.scwang.smart.refresh.header.material.CircleImageView
@@ -43,7 +43,7 @@ class MaterialHeader @JvmOverloads constructor(context: Context, attrs: Attribut
4343 /* * 刷新球默认样式 */
4444 const val BALL_STYLE_DEFAULT : Int = 1
4545
46- private val CIRCLE_BG_LIGHT : Int = Color .parseColor( " #FAFAFA" )
46+ private val CIRCLE_BG_LIGHT : Int = " #FAFAFA" .toColorInt( )
4747 private const val MAX_PROGRESS_ANGLE : Float = 0.8f
4848 }
4949
@@ -64,11 +64,11 @@ class MaterialHeader @JvmOverloads constructor(context: Context, attrs: Attribut
6464 minimumHeight = dp2px(100 ).toInt()
6565 progressDrawable = MaterialProgressDrawable (this )
6666 progressDrawable.setColorSchemeColors(
67- Color .parseColor( " #0099CC" ),
68- Color .parseColor( " #FF4444" ),
69- Color .parseColor( " #669900" ),
70- Color .parseColor( " #AA66CC" ),
71- Color .parseColor( " #FF8800" ))
67+ " #0099CC" .toColorInt( ),
68+ " #FF4444" .toColorInt( ),
69+ " #669900" .toColorInt( ),
70+ " #AA66CC" .toColorInt( ),
71+ " #FF8800" .toColorInt( ))
7272 circleView = CircleImageView (context, CIRCLE_BG_LIGHT )
7373 circleView.setImageDrawable(progressDrawable)
7474 circleView.alpha = 0f
@@ -81,21 +81,21 @@ class MaterialHeader @JvmOverloads constructor(context: Context, attrs: Attribut
8181 val typedArray: TypedArray = context.obtainStyledAttributes(attrs, R .styleable.MaterialHeader )
8282 showBezierWave = typedArray.getBoolean(R .styleable.MaterialHeader_srlShowBezierWave , showBezierWave)
8383 scrollableWhenRefreshing = typedArray.getBoolean(R .styleable.MaterialHeader_srlScrollableWhenRefreshing , scrollableWhenRefreshing)
84- bezierPaint.color = typedArray.getColor(R .styleable.MaterialHeader_srlPrimaryColor , Color .parseColor( " #11BBFF" ))
84+ bezierPaint.color = typedArray.getColor(R .styleable.MaterialHeader_srlPrimaryColor , " #11BBFF" .toColorInt( ))
8585 if (typedArray.hasValue(R .styleable.MaterialHeader_srlShadowRadius )) {
8686 val radius: Int = typedArray.getDimensionPixelOffset(R .styleable.MaterialHeader_srlShadowRadius , 0 )
87- val color: Int = typedArray.getColor(R .styleable.MaterialHeader_mhShadowColor , Color .parseColor( " #000000" ))
87+ val color: Int = typedArray.getColor(R .styleable.MaterialHeader_mhShadowColor , " #000000" .toColorInt( ))
8888 bezierPaint.setShadowLayer(radius.toFloat(), 0f , 0f , color)
8989 setLayerType(LAYER_TYPE_SOFTWARE , null )
9090 }
9191 showBezierWave = typedArray.getBoolean(R .styleable.MaterialHeader_mhShowBezierWave , showBezierWave)
9292 scrollableWhenRefreshing = typedArray.getBoolean(R .styleable.MaterialHeader_mhScrollableWhenRefreshing , scrollableWhenRefreshing)
9393 if (typedArray.hasValue(R .styleable.MaterialHeader_mhPrimaryColor )) {
94- bezierPaint.color = typedArray.getColor(R .styleable.MaterialHeader_mhPrimaryColor , Color .parseColor( " #11BBFF" ))
94+ bezierPaint.color = typedArray.getColor(R .styleable.MaterialHeader_mhPrimaryColor , " #11BBFF" .toColorInt( ))
9595 }
9696 if (typedArray.hasValue(R .styleable.MaterialHeader_mhShadowRadius )) {
9797 val radius: Int = typedArray.getDimensionPixelOffset(R .styleable.MaterialHeader_mhShadowRadius , 0 )
98- val color: Int = typedArray.getColor(R .styleable.MaterialHeader_mhShadowColor , Color .parseColor( " #000000" ))
98+ val color: Int = typedArray.getColor(R .styleable.MaterialHeader_mhShadowColor , " #000000" .toColorInt( ))
9999 bezierPaint.setShadowLayer(radius.toFloat(), 0f , 0f , color)
100100 setLayerType(LAYER_TYPE_SOFTWARE , null )
101101 }
0 commit comments