41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
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);
|
|
}
|
|
}
|
|
}
|