Merge "Code cleanup: recycle typed arrays when they are no longer needed" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f0233c53d3
@@ -20,6 +20,7 @@ import static com.android.quickstep.util.BorderAnimator.DEFAULT_BORDER_COLOR;
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
@@ -67,6 +68,9 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
int defStyleAttr,
|
||||
int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
TypedArray ta = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.TaskView, defStyleAttr, defStyleRes);
|
||||
|
||||
setWillNotDraw(false);
|
||||
Resources resources = context.getResources();
|
||||
mBorderAnimator = new BorderAnimator(
|
||||
@@ -75,17 +79,8 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
R.dimen.keyboard_quick_switch_border_width),
|
||||
/* borderRadiusPx= */ resources.getDimensionPixelSize(
|
||||
R.dimen.keyboard_quick_switch_task_view_radius),
|
||||
/* borderColor= */ attrs == null
|
||||
? DEFAULT_BORDER_COLOR
|
||||
: context.getTheme()
|
||||
.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.TaskView,
|
||||
defStyleAttr,
|
||||
defStyleRes)
|
||||
.getColor(
|
||||
R.styleable.TaskView_borderColor,
|
||||
DEFAULT_BORDER_COLOR),
|
||||
/* borderColor= */ ta.getColor(
|
||||
R.styleable.TaskView_borderColor, DEFAULT_BORDER_COLOR),
|
||||
/* invalidateViewCallback= */ KeyboardQuickSwitchTaskView.this::invalidate,
|
||||
/* viewScaleTargetProvider= */ new BorderAnimator.ViewScaleTargetProvider() {
|
||||
@NonNull
|
||||
@@ -100,6 +95,7 @@ public class KeyboardQuickSwitchTaskView extends ConstraintLayout {
|
||||
return mContent;
|
||||
}
|
||||
});
|
||||
ta.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -195,6 +195,9 @@ public class KeyboardQuickSwitchViewController {
|
||||
// focus a less recent app or loop back to the opposite end
|
||||
: ((mCurrentFocusIndex + 1) % taskCount));
|
||||
|
||||
if (mCurrentFocusIndex == toIndex) {
|
||||
return true;
|
||||
}
|
||||
mKeyboardQuickSwitchView.animateFocusMove(mCurrentFocusIndex, toIndex);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -45,6 +45,7 @@ import android.app.ActivityOptions;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
@@ -438,6 +439,9 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
|
||||
setWillNotDraw(!keyboardFocusHighlightEnabled);
|
||||
|
||||
TypedArray ta = context.obtainStyledAttributes(
|
||||
attrs, R.styleable.TaskView, defStyleAttr, defStyleRes);
|
||||
|
||||
mBorderAnimator = !keyboardFocusHighlightEnabled
|
||||
? null
|
||||
: new BorderAnimator(
|
||||
@@ -445,18 +449,10 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
/* borderWidthPx= */ context.getResources().getDimensionPixelSize(
|
||||
R.dimen.keyboard_quick_switch_border_width),
|
||||
/* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,
|
||||
/* borderColor= */ attrs == null
|
||||
? DEFAULT_BORDER_COLOR
|
||||
: context.getTheme()
|
||||
.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.TaskView,
|
||||
defStyleAttr,
|
||||
defStyleRes)
|
||||
.getColor(
|
||||
R.styleable.TaskView_borderColor,
|
||||
DEFAULT_BORDER_COLOR),
|
||||
/* borderColor= */ ta.getColor(
|
||||
R.styleable.TaskView_borderColor, DEFAULT_BORDER_COLOR),
|
||||
/* invalidateViewCallback= */ TaskView.this::invalidate);
|
||||
ta.recycle();
|
||||
}
|
||||
|
||||
protected void updateBorderBounds(Rect bounds) {
|
||||
|
||||
Reference in New Issue
Block a user