File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -24103,6 +24103,7 @@ package android.view {
2410324103 method protected boolean fitSystemWindows(android.graphics.Rect);
2410424104 method public android.view.View focusSearch(int);
2410524105 method public void forceLayout();
24106+ method public static int generateViewId();
2410624107 method public android.view.accessibility.AccessibilityNodeProvider getAccessibilityNodeProvider();
2410724108 method public float getAlpha();
2410824109 method public android.view.animation.Animation getAnimation();
Original file line number Diff line number Diff line change 9090import java.util.Arrays;
9191import java.util.Locale;
9292import java.util.concurrent.CopyOnWriteArrayList;
93+ import java.util.concurrent.atomic.AtomicInteger;
9394
9495/**
9596 * <p>
@@ -3078,6 +3079,8 @@ static class ListenerInfo {
30783079 */
30793080 private boolean mSendingHoverAccessibilityEvents;
30803081
3082+ private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
3083+
30813084 /**
30823085 * Simple constructor to use when creating a view from code.
30833086 *
@@ -16426,6 +16429,24 @@ public void resetResolvedTextAlignment() {
1642616429 public void onResolvedTextAlignmentReset() {
1642716430 }
1642816431
16432+ /**
16433+ * Generate a value suitable for use in {@link #setId(int)}.
16434+ * This value will not collide with ID values generated at build time by aapt for R.id.
16435+ *
16436+ * @return a generated ID value
16437+ */
16438+ public static int generateViewId() {
16439+ for (;;) {
16440+ final int result = sNextGeneratedId.get();
16441+ // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
16442+ int newValue = result + 1;
16443+ if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
16444+ if (sNextGeneratedId.compareAndSet(result, newValue)) {
16445+ return result;
16446+ }
16447+ }
16448+ }
16449+
1642916450 //
1643016451 // Properties
1643116452 //
Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ public void onChildViewAdded(View parent, View child) {
349349 int id = child .getId ();
350350 // generates an id if it's missing
351351 if (id == View .NO_ID ) {
352- id = child . hashCode ();
352+ id = View . generateViewId ();
353353 child .setId (id );
354354 }
355355 ((RadioButton ) child ).setOnCheckedChangeWidgetListener (
You can’t perform that action at this time.
0 commit comments