@@ -26,24 +26,24 @@ public class ShadowLayout extends FrameLayout {
26
26
27
27
public ShadowLayout (Context context ) {
28
28
super (context );
29
- initView (context , null );
29
+ initView (context , null , 0 );
30
30
}
31
31
32
32
public ShadowLayout (Context context , AttributeSet attrs ) {
33
33
super (context , attrs );
34
- initView (context , attrs );
34
+ initView (context , attrs , 0 );
35
35
}
36
36
37
37
public ShadowLayout (Context context , AttributeSet attrs , int defStyleAttr ) {
38
38
super (context , attrs , defStyleAttr );
39
- initView (context , attrs );
39
+ initView (context , attrs , defStyleAttr );
40
40
}
41
41
42
42
@ TargetApi (Build .VERSION_CODES .LOLLIPOP )
43
43
public ShadowLayout (final Context context , final AttributeSet attrs , final int defStyleAttr ,
44
44
final int defStyleRes ) {
45
45
super (context , attrs , defStyleAttr , defStyleRes );
46
- initView (context , attrs );
46
+ initView (context , attrs , defStyleRes );
47
47
}
48
48
49
49
@ Override
@@ -84,8 +84,8 @@ public void invalidateShadow() {
84
84
invalidate ();
85
85
}
86
86
87
- private void initView (@ NonNull Context context , @ Nullable AttributeSet attrs ) {
88
- initAttributes (context , attrs );
87
+ private void initView (@ NonNull Context context , @ Nullable AttributeSet attrs , int defStyledRes ) {
88
+ initAttributes (context , attrs , defStyledRes );
89
89
90
90
final int xPadding = (int ) (mShadowRadius + Math .abs (mDx ));
91
91
final int yPadding = (int ) (mShadowRadius + Math .abs (mDy ));
@@ -105,11 +105,11 @@ private void setBackgroundCompat(int w, int h) {
105
105
}
106
106
107
107
108
- private void initAttributes (@ NonNull Context context , @ Nullable AttributeSet attrs ) {
108
+ private void initAttributes (@ NonNull Context context , @ Nullable AttributeSet attrs , int defStyleRes ) {
109
109
if (attrs == null ) {
110
110
return ;
111
111
}
112
- final TypedArray attr = getTypedArray (context , attrs , R .styleable .ShadowLayout );
112
+ final TypedArray attr = getTypedArray (context , attrs , R .styleable .ShadowLayout , defStyleRes );
113
113
114
114
try {
115
115
mCornerRadius = attr .getDimension (R .styleable .ShadowLayout_sl_cornerRadius , getResources ().getDimension (R .dimen .default_corner_radius ));
@@ -124,8 +124,8 @@ private void initAttributes(@NonNull Context context, @Nullable AttributeSet att
124
124
125
125
@ NonNull
126
126
private TypedArray getTypedArray (@ NonNull Context context , @ NonNull AttributeSet attributeSet ,
127
- @ NonNull int [] attr ) {
128
- return context .obtainStyledAttributes (attributeSet , attr , 0 , 0 );
127
+ @ NonNull int [] attr , int defStyleRes ) {
128
+ return context .obtainStyledAttributes (attributeSet , attr , 0 , defStyleRes );
129
129
}
130
130
131
131
@ NonNull
0 commit comments