Remove codes for pre-21

This commit is contained in:
NekoInverter committed 2020-03-23 22:58:37 +08:00
1 parent 910c05b5a6
commit d75e2e78bf
30 files changed
+84 -805

No files matched your search

@@ -32,9 +32,6 @@ import com.hippo.yorozuya.LayoutUtils;
public class ShadowLinearLayout extends LinearLayout {
private final Rect mShadowPaddings = new Rect();
private NinePatchDrawable mShadow;
public ShadowLinearLayout(Context context) {
super(context);
init(context);
@@ -51,47 +48,8 @@ public class ShadowLinearLayout extends LinearLayout {
}
private void init(Context context) {
// TODO not only 2dp
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setOutlineProvider(ViewOutlineProvider.BOUNDS);
setElevation(LayoutUtils.dp2pix(context, 2));
} else {
setShadow((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_2dp)); // TODO draktheme
}
setOutlineProvider(ViewOutlineProvider.BOUNDS);
setElevation(LayoutUtils.dp2pix(context, 2));
}
private void setShadow(NinePatchDrawable shadow) {
mShadow = shadow;
mShadow.getPadding(mShadowPaddings);
updateShadowBounds();
setWillNotDraw(false);
}
private void updateShadowBounds() {
NinePatchDrawable shadow = mShadow;
if (shadow == null) {
return;
}
int width = getWidth();
int height = getHeight();
Rect paddings = mShadowPaddings;
if (width != 0 && height != 0) {
shadow.setBounds(-paddings.left, -paddings.top, width + paddings.right, height + paddings.bottom);
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
updateShadowBounds();
}
@Override
public void draw(@NonNull Canvas canvas) {
if (mShadow != null) {
mShadow.draw(canvas);
}
super.draw(canvas);
}
}