feat : 提测

This commit is contained in:
eggmanQQQ
2024-11-22 19:40:15 +08:00
parent cc591c4c3b
commit 1123b26e88
52 changed files with 1426 additions and 702 deletions

View File

@@ -586,29 +586,36 @@ public class DrawableTextView extends AppCompatTextView {
* 颜色示例 : R.color.color_F4F3FB.getColor()
*/
public void setGradientDrawable(int startColor, int centerColor, int endColor,int angle, float radius) {
this.startColor = startColor;
if (centerColor > -1) this.centerColor = centerColor;
this.endColor = endColor;
if (radius > -1) this.radius = radius;
if (angle > -1) this.angle = angle;
if (startColor != -1) this.startColor = startColor;
if (centerColor != -1) this.centerColor = centerColor;
if (endColor != -1) this.endColor = endColor;
if (radius != -1) this.radius = radius;
if (angle != -1) this.angle = angle;
GradientDrawable gradient = null;
if (startColor != -1 && endColor != -1) {
if (this.startColor != -1 && this.endColor != -1) {
GradientDrawable.Orientation orientation = getGradientOrientation();
if (centerColor != -1) {
gradient = new GradientDrawable(orientation, new int[]{startColor, centerColor, endColor});
if (this.centerColor != -1) {
gradient = new GradientDrawable(orientation, new int[]{this.startColor, this.centerColor, this.endColor});
} else {
gradient = new GradientDrawable(orientation, new int[]{startColor, endColor});
gradient = new GradientDrawable(orientation, new int[]{this.startColor, this.endColor});
}
}
if (gradient != null && radius > 0) {
gradient.setCornerRadius(radius);
if (gradient != null && this.radius != -1) {
gradient.setCornerRadius(this.radius);
}
if (gradient != null) {
setBackground(gradient);
}
}
public void changeGradientColor(int startColor, int centerColor, int endColor) {
if (startColor != -1) this.startColor = startColor;
if (centerColor != -1) this.centerColor = centerColor;
if (endColor != -1) this.endColor = endColor;
initDrawable(getContext());
}
/**
* 改变shape的背景颜色 需传入ARGB八位 例如#FFFFFFFF
*

View File

@@ -1,5 +1,6 @@
package com.chwl.library.common.util
import android.graphics.Color
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
@@ -81,6 +82,10 @@ fun String?.isVerify() : Boolean {
return this?.isBlank() == false
}
fun String.toColor() : Int {
return Color.parseColor(this)
}
fun String?.isSvgaUrl() : Boolean {
if (this.isVerify()) {
return this?.endsWith(".svga") == true || this?.endsWith(".SVGA") == true
@@ -111,4 +116,35 @@ fun List<Any>?.isVerify() : Boolean{
return this?.isEmpty() == false
}
fun Int.isVerify(list : List<Any>?) : Boolean{
if (list.isVerify()) {
if (list!!.getOrNull(this) != null) {
return true
}
}
return false
}
fun Double?.toNumString(byte:Int = 2) : String {
if (this == null) {
return "0"
} else {
val intNum = this.toInt()
val floatNum = this - intNum
if (floatNum == 0.0) {
return intNum.toString()
} else {
val format = String.format("%.${byte}f", this)
if (format.endsWith(".00")){
return intNum.toString()
}else if (format.contains(".") && format.endsWith("0")){
return format.removeSuffix("0")
}else {
return format
}
}
}
}