Android Open Source - Llama Unique View Id Creator






From Project

Back to project page Llama.

License

The source code is released under:

MIT License

If you think the Android project Llama listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package io.github.nick11roberts.llamaspawningbuttonthing;
//ww  w .j a  v  a  2s .  c o m
import java.util.concurrent.atomic.AtomicInteger;
import android.annotation.SuppressLint;
import android.os.Build;
import android.view.View;

public class UniqueViewIdCreator {
    private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
    public static int createViewId() {
        if (Build.VERSION.SDK_INT < 17) {
            for (;;) {
                final int result = sNextGeneratedId.get();
                int newValue = result + 1;
                if (newValue > 0x00FFFFFF)
                    newValue = 1; // Roll over to 1, not 0.
                if (sNextGeneratedId.compareAndSet(result, newValue)) {
                    return result;
                }
            }
        } else {
            return View.generateViewId();
        }
    }
}




Java Source Code List

io.github.nick11roberts.llamaspawningbuttonthing.AnuRandom.java
io.github.nick11roberts.llamaspawningbuttonthing.ApplicationTest.java
io.github.nick11roberts.llamaspawningbuttonthing.AsyncTaskParams.java
io.github.nick11roberts.llamaspawningbuttonthing.CustomTypefaceSpan.java
io.github.nick11roberts.llamaspawningbuttonthing.CustomTypefaceTextView.java
io.github.nick11roberts.llamaspawningbuttonthing.ListenerService.java
io.github.nick11roberts.llamaspawningbuttonthing.LlamaActivity.java
io.github.nick11roberts.llamaspawningbuttonthing.LlamaWearActivity.java
io.github.nick11roberts.llamaspawningbuttonthing.RandomLlamaAttributes.java
io.github.nick11roberts.llamaspawningbuttonthing.RetrieveQRandResponse.java
io.github.nick11roberts.llamaspawningbuttonthing.RetrieveQRandTask.java
io.github.nick11roberts.llamaspawningbuttonthing.SendToDataLayerThread.java
io.github.nick11roberts.llamaspawningbuttonthing.UniqueViewIdCreator.java