更新CameraX至v1.2.1

This commit is contained in:
Jenly
2023-03-04 20:54:37 +08:00
parent b2fa6aaec0
commit a85d793149
53 changed files with 1566 additions and 884 deletions

View File

@@ -16,9 +16,10 @@
*/
package com.king.zxing.util;
import android.util.Log;
import java.util.Locale;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@@ -28,10 +29,14 @@ public class LogUtils {
public static final String VERTICAL = "|";
/** 是否显示Log日志 */
/**
* 是否显示Log日志
*/
private static boolean isShowLog = true;
/** Log日志优先权 */
/**
* Log日志优先权
*/
private static int priority = 1;
/**
@@ -71,7 +76,7 @@ public class LogUtils {
public static final String TAG_FORMAT = "%s.%s(%s:%d)";
private LogUtils(){
private LogUtils() {
throw new AssertionError();
}
@@ -97,24 +102,25 @@ public class LogUtils {
/**
* 根据堆栈生成TAG
*
* @return TAG|className.methodName(fileName:lineNumber)
*/
private static String generateTag(StackTraceElement caller) {
String tag = TAG_FORMAT;
String callerClazzName = caller.getClassName();
callerClazzName = callerClazzName.substring(callerClazzName.lastIndexOf(".") + 1);
tag = String.format(tag,callerClazzName, caller.getMethodName(),caller.getFileName(),caller.getLineNumber());
tag = String.format(Locale.getDefault(), tag, callerClazzName, caller.getMethodName(), caller.getFileName(), caller.getLineNumber());
return new StringBuilder().append(TAG).append(VERTICAL).append(tag).toString();
}
/**
* 获取堆栈
* @param n
* n=0 VMStack
* n=1 Thread
* n=3 CurrentStack
* n=4 CallerStack
* ...
*
* @param n n=0 VMStack
* n=1 Thread
* n=3 CurrentStack
* n=4 CallerStack
* ...
* @return
*/
public static StackTraceElement getStackTraceElement(int n) {
@@ -123,18 +129,18 @@ public class LogUtils {
/**
* 获取调用方的堆栈TAG
*
* @return
*/
private static String getCallerStackLogTag(){
private static String getCallerStackLogTag() {
return generateTag(getStackTraceElement(5));
}
/**
*
* @param t
* @return
*/
private static String getStackTraceString(Throwable t){
private static String getStackTraceString(Throwable t) {
return Log.getStackTraceString(t);
}
@@ -142,6 +148,7 @@ public class LogUtils {
/**
* Log.v
*
* @param msg
*/
public static void v(String msg) {
@@ -155,7 +162,7 @@ public class LogUtils {
Log.v(getCallerStackLogTag(), getStackTraceString(t));
}
public static void v(String msg,Throwable t) {
public static void v(String msg, Throwable t) {
if (isShowLog && priority <= VERBOSE)
Log.v(getCallerStackLogTag(), String.valueOf(msg), t);
}
@@ -164,6 +171,7 @@ public class LogUtils {
/**
* Log.d
*
* @param msg
*/
public static void d(String msg) {
@@ -176,7 +184,7 @@ public class LogUtils {
Log.d(getCallerStackLogTag(), getStackTraceString(t));
}
public static void d(String msg,Throwable t) {
public static void d(String msg, Throwable t) {
if (isShowLog && priority <= DEBUG)
Log.d(getCallerStackLogTag(), String.valueOf(msg), t);
}
@@ -185,6 +193,7 @@ public class LogUtils {
/**
* Log.i
*
* @param msg
*/
public static void i(String msg) {
@@ -197,7 +206,7 @@ public class LogUtils {
Log.i(getCallerStackLogTag(), getStackTraceString(t));
}
public static void i(String msg,Throwable t) {
public static void i(String msg, Throwable t) {
if (isShowLog && priority <= INFO)
Log.i(getCallerStackLogTag(), String.valueOf(msg), t);
}
@@ -206,6 +215,7 @@ public class LogUtils {
/**
* Log.w
*
* @param msg
*/
public static void w(String msg) {
@@ -218,7 +228,7 @@ public class LogUtils {
Log.w(getCallerStackLogTag(), getStackTraceString(t));
}
public static void w(String msg,Throwable t) {
public static void w(String msg, Throwable t) {
if (isShowLog && priority <= WARN)
Log.w(getCallerStackLogTag(), String.valueOf(msg), t);
}
@@ -227,6 +237,7 @@ public class LogUtils {
/**
* Log.e
*
* @param msg
*/
public static void e(String msg) {
@@ -239,7 +250,7 @@ public class LogUtils {
Log.e(getCallerStackLogTag(), getStackTraceString(t));
}
public static void e(String msg,Throwable t) {
public static void e(String msg, Throwable t) {
if (isShowLog && priority <= ERROR)
Log.e(getCallerStackLogTag(), String.valueOf(msg), t);
}
@@ -248,6 +259,7 @@ public class LogUtils {
/**
* Log.wtf
*
* @param msg
*/
public static void wtf(String msg) {
@@ -260,7 +272,7 @@ public class LogUtils {
Log.wtf(getCallerStackLogTag(), getStackTraceString(t));
}
public static void wtf(String msg,Throwable t) {
public static void wtf(String msg, Throwable t) {
if (isShowLog && priority <= ASSERT)
Log.wtf(getCallerStackLogTag(), String.valueOf(msg), t);
}
@@ -312,3 +324,4 @@ public class LogUtils {
}
}