Skip to content

Commit 2639d6e

Browse files
committed
Fixed constructor using style from xml definned style #9
1 parent d1db175 commit 2639d6e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ android {
2424

2525
dependencies {
2626
compile fileTree(dir: 'libs', include: ['*.jar'])
27-
compile 'com.android.support:appcompat-v7:21.0.3'
27+
compile 'com.android.support:appcompat-v7:22.1.1'
2828
compile project(':library')
2929
// compile 'com.github.dmytrodanylyk.shadow-layout:library:1.0.0-SNAPSHOT@aar'
3030
}

library/src/main/java/com/dd/ShadowLayout.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@ public class ShadowLayout extends FrameLayout {
2626

2727
public ShadowLayout(Context context) {
2828
super(context);
29-
initView(context, null);
29+
initView(context, null, 0);
3030
}
3131

3232
public ShadowLayout(Context context, AttributeSet attrs) {
3333
super(context, attrs);
34-
initView(context, attrs);
34+
initView(context, attrs, 0);
3535
}
3636

3737
public ShadowLayout(Context context, AttributeSet attrs, int defStyleAttr) {
3838
super(context, attrs, defStyleAttr);
39-
initView(context, attrs);
39+
initView(context, attrs, defStyleAttr);
4040
}
4141

4242
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
4343
public ShadowLayout(final Context context, final AttributeSet attrs, final int defStyleAttr,
4444
final int defStyleRes) {
4545
super(context, attrs, defStyleAttr, defStyleRes);
46-
initView(context, attrs);
46+
initView(context, attrs, defStyleRes);
4747
}
4848

4949
@Override
@@ -84,8 +84,8 @@ public void invalidateShadow() {
8484
invalidate();
8585
}
8686

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);
8989

9090
final int xPadding = (int) (mShadowRadius + Math.abs(mDx));
9191
final int yPadding = (int) (mShadowRadius + Math.abs(mDy));
@@ -105,11 +105,11 @@ private void setBackgroundCompat(int w, int h) {
105105
}
106106

107107

108-
private void initAttributes(@NonNull Context context, @Nullable AttributeSet attrs) {
108+
private void initAttributes(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleRes) {
109109
if (attrs == null) {
110110
return;
111111
}
112-
final TypedArray attr = getTypedArray(context, attrs, R.styleable.ShadowLayout);
112+
final TypedArray attr = getTypedArray(context, attrs, R.styleable.ShadowLayout, defStyleRes);
113113

114114
try {
115115
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
124124

125125
@NonNull
126126
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);
129129
}
130130

131131
@NonNull

0 commit comments

Comments
 (0)