[6.2.6][View点击态] 设置背景增加废弃入口
This commit is contained in:
@@ -153,6 +153,36 @@ public class ViewPressedStateLancet {
|
||||
view.setOnLongClickListener(listener);
|
||||
}
|
||||
|
||||
@TargetClass(value = "android.view.View", scope = Scope.ALL)
|
||||
@TargetMethod(methodName = "setBackgroundDrawable")
|
||||
@ReplaceInvoke
|
||||
public static void setBackgroundDrawable(View view, Drawable drawable) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
if (!view.isLongClickable() && !view.isClickable()) {
|
||||
view.setBackground(drawable);
|
||||
return;
|
||||
}
|
||||
float alpha = getAlpha(view);
|
||||
if (alpha >= 0) {
|
||||
Drawable replaced = checkAndReplaceDrawable(drawable, alpha);
|
||||
if (replaced != null) {
|
||||
view.setTag(R.id.click_pressed_attr_replaced, drawable);
|
||||
int paddingLeft = view.getPaddingLeft();
|
||||
int paddingRight = view.getPaddingRight();
|
||||
int paddingTop = view.getPaddingTop();
|
||||
int paddingBottom = view.getPaddingBottom();
|
||||
view.setBackground(replaced);
|
||||
view.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
||||
} else {
|
||||
view.setBackground(drawable);
|
||||
}
|
||||
} else {
|
||||
view.setBackground(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@TargetClass(value = "android.view.View", scope = Scope.ALL)
|
||||
@TargetMethod(methodName = "setBackground")
|
||||
|
||||
Reference in New Issue
Block a user