Initial commit
This commit is contained in:
43
sources/com/ubt/jimu/controller/util/AdsorbUtils.java
Normal file
43
sources/com/ubt/jimu/controller/util/AdsorbUtils.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Size;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AdsorbUtils {
|
||||
public static PointF a(float f, float f2, float f3) {
|
||||
int round = Math.round(f2 / f);
|
||||
int round2 = Math.round(f3 / f);
|
||||
float f4 = round * f;
|
||||
float f5 = round2 * f;
|
||||
XLog.a("Controller", "row: %d, column: %d (%.3f, %.3f) -> (%.3f, %.3f)", Integer.valueOf(round), Integer.valueOf(round2), Float.valueOf(f2), Float.valueOf(f3), Float.valueOf(f4), Float.valueOf(f5));
|
||||
return new PointF(f4, f5);
|
||||
}
|
||||
|
||||
public static PointF a(float f, Size size, float f2, float f3, RectF rectF) {
|
||||
if (rectF != null) {
|
||||
int round = Math.round(f2 / f);
|
||||
int round2 = Math.round(f3 / f);
|
||||
float f4 = round * f;
|
||||
float width = rectF.width() / 2.0f;
|
||||
if (f4 + width > size.getWidth()) {
|
||||
f4 = ((float) (round - Math.ceil((r5 - size.getWidth()) / f))) * f;
|
||||
} else if (f4 - width < 0.0f) {
|
||||
f4 = width;
|
||||
}
|
||||
float f5 = round2 * f;
|
||||
if ((rectF.height() / 2.0f) + f5 > size.getHeight()) {
|
||||
f5 = ((float) (round2 - Math.ceil((r11 - size.getHeight()) / f))) * f;
|
||||
}
|
||||
XLog.a("Controller", "(%.3f, %.3f) adsorb to -> (%.3f, %.3f)", Float.valueOf(f2), Float.valueOf(f3), Float.valueOf(f4), Float.valueOf(f5));
|
||||
return new PointF(f4, f5);
|
||||
}
|
||||
return new PointF(f2, f3);
|
||||
}
|
||||
|
||||
public static boolean a(RectF rectF, RectF rectF2) {
|
||||
return ((int) rectF.left) < ((int) rectF2.right) && ((int) rectF2.left) < ((int) rectF.right) && ((int) rectF.top) < ((int) rectF2.bottom) && ((int) rectF2.top) < ((int) rectF.bottom);
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FieldDefaultProvider extends PureJavaReflectionProvider {
|
||||
@Override // com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider, com.thoughtworks.xstream.converters.reflection.ReflectionProvider
|
||||
public void writeField(Object obj, String str, Object obj2, Class cls) {
|
||||
super.writeField(obj, str, obj2, cls);
|
||||
Field field = this.fieldDictionary.field(obj.getClass(), str, cls);
|
||||
validateFieldAccess(field);
|
||||
if (!(obj2 instanceof String)) {
|
||||
Fields.write(field, obj, obj2);
|
||||
return;
|
||||
}
|
||||
String trim = ((String) obj2).trim();
|
||||
if (trim.length() > 0) {
|
||||
Fields.write(field, obj, trim);
|
||||
}
|
||||
}
|
||||
}
|
8
sources/com/ubt/jimu/controller/util/IDGenerator.java
Normal file
8
sources/com/ubt/jimu/controller/util/IDGenerator.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class IDGenerator {
|
||||
public static String a(long j) {
|
||||
return System.currentTimeMillis() + "" + ((int) (Math.random() * 1000.0d));
|
||||
}
|
||||
}
|
37
sources/com/ubt/jimu/controller/util/PermissionUtils.java
Normal file
37
sources/com/ubt/jimu/controller/util/PermissionUtils.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PermissionUtils {
|
||||
public static boolean a(Activity activity, String[] strArr, int i) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return true;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (String str : strArr) {
|
||||
if (ContextCompat.a(activity, str) != 0) {
|
||||
arrayList.add(str);
|
||||
}
|
||||
}
|
||||
if (arrayList.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
ActivityCompat.a(activity, (String[]) arrayList.toArray(new String[arrayList.size()]), i);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean a(String[] strArr, int[] iArr) {
|
||||
boolean z = true;
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
if (iArr[i] != 0) {
|
||||
z = false;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
}
|
44
sources/com/ubt/jimu/controller/util/ScreenUtil.java
Normal file
44
sources/com/ubt/jimu/controller/util/ScreenUtil.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Size;
|
||||
import android.view.Display;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ScreenUtil {
|
||||
public static int a(Context context) {
|
||||
Display defaultDisplay = ((Activity) context).getWindowManager().getDefaultDisplay();
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
try {
|
||||
Class.forName("android.view.Display").getMethod("getRealMetrics", DisplayMetrics.class).invoke(defaultDisplay, displayMetrics);
|
||||
return displayMetrics.widthPixels;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int b(Context context) {
|
||||
return context.getResources().getDisplayMetrics().heightPixels;
|
||||
}
|
||||
|
||||
public static Size c(Context context) {
|
||||
int d = d(context);
|
||||
int b = b(context);
|
||||
if (d >= b) {
|
||||
d = b;
|
||||
b = d;
|
||||
}
|
||||
return new Size(b, d);
|
||||
}
|
||||
|
||||
public static int d(Context context) {
|
||||
return context.getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
|
||||
public static int a(Context context, int i) {
|
||||
return (int) ((i * context.getResources().getDisplayMetrics().scaledDensity) + 0.5f);
|
||||
}
|
||||
}
|
36
sources/com/ubt/jimu/controller/util/SvgUtils.java
Normal file
36
sources/com/ubt/jimu/controller/util/SvgUtils.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SvgUtils {
|
||||
private static SvgUtils b;
|
||||
private Context a;
|
||||
|
||||
private SvgUtils(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
public static SvgUtils a(Context context) {
|
||||
if (b == null) {
|
||||
b = new SvgUtils(context);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public Drawable a(int i) {
|
||||
return this.a.getResources().getDrawable(i, this.a.getTheme());
|
||||
}
|
||||
|
||||
public Bitmap a(int i, int i2, int i3) {
|
||||
Drawable drawable = this.a.getResources().getDrawable(i, this.a.getTheme());
|
||||
Bitmap createBitmap = Bitmap.createBitmap(i2, i3, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(createBitmap);
|
||||
drawable.setBounds(0, 0, i2, i3);
|
||||
drawable.draw(canvas);
|
||||
return createBitmap;
|
||||
}
|
||||
}
|
52
sources/com/ubt/jimu/controller/util/XmlUtils.java
Normal file
52
sources/com/ubt/jimu/controller/util/XmlUtils.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.ubt.jimu.controller.util;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.naming.NoNameCoder;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XmlUtils {
|
||||
public static Object a(Class cls, String str) {
|
||||
File file = new File(str);
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
XStream xStream = new XStream(new FieldDefaultProvider());
|
||||
xStream.ignoreUnknownElements();
|
||||
xStream.processAnnotations(cls);
|
||||
try {
|
||||
return xStream.fromXML(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
XLog.b("XmlUtils", "xml parse exception msg: %s", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void a(Object obj, String str) {
|
||||
ALog.a("XmlUtils").d("saveXml");
|
||||
File file = new File(str);
|
||||
File parentFile = file.getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
try {
|
||||
XStream xStream = new XStream(new DomDriver("UTF-8", new NoNameCoder()));
|
||||
xStream.processAnnotations(obj.getClass());
|
||||
xStream.setMode(1001);
|
||||
xStream.toXML(obj, fileOutputStream);
|
||||
fileOutputStream.close();
|
||||
} finally {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user