aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 9e8ec29c..577d40d3 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -72,10 +72,11 @@ import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
public class SubsonicFragment extends SherlockFragment {
private static final String TAG = SubsonicFragment.class.getSimpleName();
- private static int internalID = Integer.MAX_VALUE;
+ private static final AtomicInteger nextGeneratedId = new AtomicInteger(1);
private static int TAG_INC = 10;
private int tag;
@@ -282,8 +283,15 @@ public class SubsonicFragment extends SherlockFragment {
}
protected int getNewId() {
- internalID--;
- return internalID;
+ for (;;) {
+ final int result = nextGeneratedId.get();
+ // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
+ int newValue = result + 1;
+ if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
+ if (nextGeneratedId.compareAndSet(result, newValue)) {
+ return result;
+ }
+ }
}
public int getRootId() {
return rootView.getId();