[2.15.0] 优化代码逻辑
This commit is contained in:
@@ -24,6 +24,9 @@ class ANRFix {
|
||||
@TargetMethod(methodName = "post")
|
||||
@ReplaceInvoke
|
||||
fun handlerPostProxy(handler: Handler, action: Runnable): Boolean {
|
||||
if (Looper.getMainLooper() != handler.looper) {
|
||||
return handler.post(action)
|
||||
}
|
||||
val what = ObjectHashCodeUtils.getHashCodeIfNeed(action)
|
||||
handler.removeMessages(what)
|
||||
val msg = Message.obtain(handler, action)
|
||||
@@ -36,6 +39,9 @@ class ANRFix {
|
||||
@TargetMethod(methodName = "postDelayed")
|
||||
@ReplaceInvoke
|
||||
fun handlerPostDelayProxy(handler: Handler, action: Runnable, delayMillis: Long): Boolean {
|
||||
if (Looper.getMainLooper() != handler.looper) {
|
||||
return handler.postDelayed(action, delayMillis)
|
||||
}
|
||||
val what = ObjectHashCodeUtils.getHashCodeIfNeed(action)
|
||||
handler.removeMessages(what)
|
||||
val msg = Message.obtain(handler, action)
|
||||
|
||||
Reference in New Issue
Block a user