Merge branch 'dev_arch_opt_3.0' into 'dev_robobus-m1-p-app-module_1.1.0_230112_1.1.0'
[dev_arch_opt_3.0] 优化TextView频繁调用setText导致的频繁绘制问题; 优化状态栏上工控机相关状态的处理逻辑 See merge request zhjt/AndroidApp/MoGoEagleEye!675
This commit is contained in:
@@ -6,6 +6,7 @@ import com.knightboost.lancet.api.annotations.Group;
|
||||
import com.knightboost.lancet.api.annotations.ImplementedInterface;
|
||||
import com.knightboost.lancet.api.annotations.NameRegex;
|
||||
import com.knightboost.lancet.api.annotations.ReplaceInvoke;
|
||||
import com.knightboost.lancet.api.annotations.TargetClass;
|
||||
import com.knightboost.lancet.api.annotations.TargetMethod;
|
||||
import com.knightboost.lancet.api.annotations.Weaver;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -18,7 +19,7 @@ public class ObjectHashCodeProxy {
|
||||
public static final ConcurrentHashMap<String, Integer> hashCodes = new ConcurrentHashMap<>();
|
||||
|
||||
@NameRegex("(com\\.mogo\\.eagle\\.core\\.utilcode\\.util\\.ThreadUtils|com\\.mogo\\.eagle\\.core\\.utilcode\\.util\\.UiThreadHandler)")
|
||||
@ImplementedInterface(value = "java.lang.Object",scope = Scope.SELF)
|
||||
@TargetClass(value = "java.lang.Object",scope = Scope.SELF)
|
||||
@TargetMethod(methodName = "hashCode")
|
||||
@ReplaceInvoke
|
||||
public static int hashCodeProxy(Object r) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mogo.launcher.lancet;
|
||||
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.knightboost.lancet.api.Scope;
|
||||
import com.knightboost.lancet.api.annotations.Group;
|
||||
import com.knightboost.lancet.api.annotations.NameRegex;
|
||||
import com.knightboost.lancet.api.annotations.ReplaceInvoke;
|
||||
import com.knightboost.lancet.api.annotations.TargetClass;
|
||||
import com.knightboost.lancet.api.annotations.TargetMethod;
|
||||
import com.knightboost.lancet.api.annotations.Weaver;
|
||||
|
||||
@Weaver
|
||||
@Group("TextView_setTextProxy")
|
||||
public class TextViewSetTextOpt {
|
||||
|
||||
@NameRegex("(com\\.mogo|com\\.zhidao|com\\.elegant|com\\.zhidaoauto|com\\.zhjt).*")
|
||||
@TargetClass(value = "android.widget.TextView",scope = Scope.ALL)
|
||||
@TargetMethod(methodName = "setText")
|
||||
@ReplaceInvoke
|
||||
public static void setText(TextView view, CharSequence text) {
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (StackTraceElement trace : stackTrace) {
|
||||
sb.append(trace.getClassName()).append(".").append(trace.getMethodName()).append("(").append(trace.getLineNumber()).append(")").append("\n");
|
||||
}
|
||||
if (sb.length() > 1) {
|
||||
sb.setLength(sb.length() - 1);
|
||||
}
|
||||
Log.e("ALERT", sb.toString());
|
||||
}
|
||||
CharSequence old = view.getText();
|
||||
if (old != null && !old.equals(text)) {
|
||||
view.setText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user