Remove the OnLayoutChangeListener once the set radius to preview card
Test: Manually
Bug: 155354505
Change-Id: Ia631d3afd940157decc1ce362935200de6b79c7a
diff --git a/src/com/android/customization/picker/BasePreviewAdapter.java b/src/com/android/customization/picker/BasePreviewAdapter.java
index 7789221..a02cb7e 100644
--- a/src/com/android/customization/picker/BasePreviewAdapter.java
+++ b/src/com/android/customization/picker/BasePreviewAdapter.java
@@ -113,11 +113,17 @@
}
public void setCard(CardView card) {
- this.card = card;
- this.card.addOnLayoutChangeListener(
- (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
+ card.addOnLayoutChangeListener(
+ new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
card.setRadius(TileSizeCalculator.getPreviewCornerRadius(
- mActivity, card.getMeasuredWidth())));
+ mActivity, card.getMeasuredWidth()));
+ card.removeOnLayoutChangeListener(this);
+ }
+ });
+ this.card = card;
}
public abstract void bindPreviewContent();