[dev_arch_opt_3.0] 代码逻辑优化

This commit is contained in:
renwj
2023-03-14 23:12:09 +08:00
parent d60a7c3429
commit 4fdbe43cae
6 changed files with 36 additions and 49 deletions

View File

@@ -1,38 +0,0 @@
package com.mogo.launcher.lancet;
import androidx.annotation.Keep;
import com.knightboost.lancet.api.Scope;
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;
@Weaver
@Group("object_hashcode")
@Keep
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)")
@TargetClass(value = "java.lang.Object",scope = Scope.SELF)
@TargetMethod(methodName = "hashCode")
@ReplaceInvoke
public static int hashCodeProxy(Object r) {
Class<?> clazz = r.getClass();
String className = clazz.getName();
if (hashCodes.containsKey(className)) {
Integer value = hashCodes.get(className);
if (value != null) {
return value;
}
}
int hashCode = System.identityHashCode(r);
hashCodes.put(className, hashCode);
return hashCode;
}
}

View File

@@ -3,7 +3,6 @@ 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;
@@ -13,7 +12,7 @@ import com.knightboost.lancet.api.annotations.TargetMethod;
import com.knightboost.lancet.api.annotations.Weaver;
@Weaver
@Group("TextView_setTextProxy")
@Group("textview_opt")
public class TextViewSetTextOpt {
@NameRegex("(com\\.mogo|com\\.zhidao|com\\.elegant|com\\.zhidaoauto|com\\.zhjt).*")
@@ -31,6 +30,7 @@ public class TextViewSetTextOpt {
sb.setLength(sb.length() - 1);
}
Log.e("ALERT", sb.toString());
return;
}
CharSequence old = view.getText();
if (old != null && !old.equals(text)) {