Skip to content

Commit

Permalink
1.更新部分代码
Browse files Browse the repository at this point in the history
Former-commit-id: 8a117d5
Former-commit-id: 656d30d
  • Loading branch information
afkT committed Jan 22, 2022
1 parent e76c800 commit 38a0b7d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 29 deletions.
21 changes: 15 additions & 6 deletions lib/DevAssist/src/main/java/dev/base/DevVariableExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public interface Creator<K, V, P> {

/**
* 创建存储值
* @param param 额外参数
* @param key 存储 key
* @param param 额外参数
* @return 存储值
*/
V create(
P param,
K key
K key,
P param
);
}

Expand Down Expand Up @@ -67,20 +67,29 @@ public DevVariable<K, V> getVariable() {
return mVariable;
}

/**
* 通过 key 获取 value
* @param key Key
* @return Value
*/
public V getVariableValue(final K key) {
return getVariableValue(key, null);
}

/**
* 通过 key 获取 value
* @param key Key
* @param param 额外参数
* @return Value
*/
public V getVariableValue(
final P param,
final K key
final K key,
final P param
) {
V value = mVariable.getVariableValue(key);
if (value != null) return value;
if (mCreator != null) {
value = mCreator.create(param, key);
value = mCreator.create(key, param);
if (value != null) {
mVariable.putVariable(key, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ private void initAttrs(
attrs, R.styleable.DevWidget, defStyleAttr, defStyleRes
);

mPaddingTop = a.getDimension(R.styleable.DevWidget_dev_paddingTop, SizeUtils.dp2px(10));
mPaddingTop = a.getDimension(R.styleable.DevWidget_dev_paddingTop, SizeUtils.dp2px(getContext(), 10));
mPaddingCenter = a.getDimension(R.styleable.DevWidget_dev_paddingCenter, 0);
mPaddingBottom = a.getDimension(R.styleable.DevWidget_dev_paddingBottom, SizeUtils.dp2px(3));
mPaddingBottom = a.getDimension(R.styleable.DevWidget_dev_paddingBottom, SizeUtils.dp2px(getContext(), 3));

mText1.text = a.getString(R.styleable.DevWidget_dev_text1);
mText1.textColor = a.getColor(R.styleable.DevWidget_dev_textColor1, 0xffffffff);
mText1.textHeight = a.getDimension(R.styleable.DevWidget_dev_textHeight1, SizeUtils.dp2px(12));
mText1.textHeight = a.getDimension(R.styleable.DevWidget_dev_textHeight1, SizeUtils.dp2px(getContext(), 12));
mText1.textBold = a.getBoolean(R.styleable.DevWidget_dev_textBold1, false);
mText1.initialize();

mText2.text = a.getString(R.styleable.DevWidget_dev_text2);
mText2.textColor = a.getColor(R.styleable.DevWidget_dev_textColor2, 0x66ffffff);
mText2.textHeight = a.getDimension(R.styleable.DevWidget_dev_textHeight2, SizeUtils.dp2px(8));
mText2.textHeight = a.getDimension(R.styleable.DevWidget_dev_textHeight2, SizeUtils.dp2px(getContext(), 8));
mText2.textBold = a.getBoolean(R.styleable.DevWidget_dev_textBold2, false);
mText2.initialize();

Expand Down
10 changes: 5 additions & 5 deletions lib/DevWidget/src/main/java/dev/widget/ui/LoadProgressBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private LoadProgressBar initialize() {
// 设置外环颜色
mOuterRingColor = Color.argb(30, 255, 255, 255);
// 设置外环进度条的宽度
mOuterRingWidth = SizeUtils.dp2px(4.0f);
mOuterRingWidth = SizeUtils.dp2px(getContext(), 4.0f);
// 设置绘制的数字颜色
mNumberTextColor = Color.BLACK;
// 初始化处理
Expand Down Expand Up @@ -310,7 +310,7 @@ protected void onDraw(Canvas canvas) {
// 计算字体大小
mNumberTextSize = TextViewUtils.reckonTextSizeByWidth(
tempWidth, mTextPaint,
SizeUtils.px2sp(tempWidth), "100%"
SizeUtils.px2sp(getContext(), tempWidth), "100%"
);
}
// 绘制进度文本
Expand All @@ -332,7 +332,7 @@ protected void onDraw(Canvas canvas) {
// 计算字体大小
mNumberTextSize = TextViewUtils.reckonTextSizeByWidth(
tempWidth, mTextPaint,
SizeUtils.px2sp(tempWidth), "100%"
SizeUtils.px2sp(getContext(), tempWidth), "100%"
);
}
// 绘制进度文本
Expand All @@ -350,14 +350,14 @@ protected void onDraw(Canvas canvas) {
// 计算字体大小
mNumberTextSize = TextViewUtils.reckonTextSizeByWidth(
tempWidth, mTextPaint,
SizeUtils.px2sp(tempWidth), "100%"
SizeUtils.px2sp(getContext(), tempWidth), "100%"
);
} else {
int tempWidth = (int) mInsideCircleWidth / 3 * 2;
// 计算字体大小
mNumberTextSize = TextViewUtils.reckonTextSizeByWidth(
tempWidth, mTextPaint,
SizeUtils.px2sp(tempWidth), "100%"
SizeUtils.px2sp(getContext(), tempWidth), "100%"
);
}
}
Expand Down
28 changes: 14 additions & 14 deletions lib/DevWidget/src/main/java/dev/widget/ui/ScanShapeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,18 +262,18 @@ public ScanShapeView(
* 初始化处理
*/
private void initialize() {
mDFCommonDP = SizeUtils.dp2px(5);
mBorderWidth = SizeUtils.dp2px(2);
mBorderWidthToSquare = SizeUtils.dp2px(1);
mTriAngleLength = SizeUtils.dp2pxf(20);
mDFCommonDP = SizeUtils.dp2px(getContext(), 5);
mBorderWidth = SizeUtils.dp2px(getContext(), 2);
mBorderWidthToSquare = SizeUtils.dp2px(getContext(), 1);
mTriAngleLength = SizeUtils.dp2pxf(getContext(), 20);

mAnnulusWidths[0] = SizeUtils.dp2px(3);
mAnnulusWidths[1] = SizeUtils.dp2px(7);
mAnnulusWidths[2] = SizeUtils.dp2px(7);
mAnnulusWidths[0] = SizeUtils.dp2px(getContext(), 3);
mAnnulusWidths[1] = SizeUtils.dp2px(getContext(), 7);
mAnnulusWidths[2] = SizeUtils.dp2px(getContext(), 7);

mAnnulusMargins[0] = SizeUtils.dp2px(7);
mAnnulusMargins[1] = SizeUtils.dp2px(7);
mAnnulusMargins[2] = SizeUtils.dp2px(7);
mAnnulusMargins[0] = SizeUtils.dp2px(getContext(), 7);
mAnnulusMargins[1] = SizeUtils.dp2px(getContext(), 7);
mAnnulusMargins[2] = SizeUtils.dp2px(getContext(), 7);

// 设置背景颜色 ( 黑色 百分之 40 透明度 ) #66000000
mBackgroundPaint.setColor(Color.argb(102, 0, 0, 0));
Expand Down Expand Up @@ -1180,9 +1180,9 @@ public float[] getAnnulusWidths() {
public ScanShapeView setAnnulusWidths(float... annulusWidths) {
if (annulusWidths == null) {
annulusWidths = new float[3];
annulusWidths[0] = SizeUtils.dp2px(3);
annulusWidths[1] = SizeUtils.dp2px(7);
annulusWidths[2] = SizeUtils.dp2px(7);
annulusWidths[0] = SizeUtils.dp2px(getContext(), 3);
annulusWidths[1] = SizeUtils.dp2px(getContext(), 7);
annulusWidths[2] = SizeUtils.dp2px(getContext(), 7);
}
// 设置临时数据
float[] temp = Arrays.copyOf(annulusWidths, 3);
Expand Down Expand Up @@ -1214,7 +1214,7 @@ public float[] getAnnulusMargins() {
*/
public ScanShapeView setAnnulusMargins(float... annulusMargins) {
if (annulusMargins == null) {
int dp = SizeUtils.dp2px(7);
int dp = SizeUtils.dp2px(getContext(), 7);
annulusMargins = new float[]{dp, dp, dp};
}
// 设置临时数据
Expand Down

0 comments on commit 38a0b7d

Please sign in to comment.