@@ -0,0 +1,2677 @@
+package nordpol.android;%0A%0Aimport android.nfc.Tag;%0A%0Aimport nordpol.android.OnDiscoveredTagListener;%0A%0A/**%0A * The TagArbiter is a tool to help handle tags between activities and%0A * fragments in your Android app. You need to create a single instance%0A * of this class to be shared between the activities and fragments%0A * requiring tag instances. This could be done using a singleton or by%0A * providig a reference to the instance to every activity/fragment.%0A *%0A * The basic flow is to create an instance of the TagDispatcher in all%0A * activities, but rather than registering the activity directly to%0A * the TagDispatcher, one would register the tag arbiter instead. This%0A * way an activity that finds a tag can use it whenever it needs it or%0A * it can be used by any other activity that needs it. As long as%0A * TagArbiter.tagErrored is not called, the tag found will be kept and%0A * can be safely reused among several activities.%0A%0A * From an end user perspective, this class enables the end user to%0A * present their device to the phone once and keep it there while%0A * switching between different activities.%0A */%0A%0Apublic class TagArbiter implements OnDiscoveredTagListener %7B%0A    private OnDiscoveredTagListener onDiscoveredTagListener = null;%0A    private Tag lastTag = null;%0A%0A    /**%0A     * Set a listener to receive a tag found by any activity%0A     *%0A     * This method either registers the listener for later dispatch%0A     * when a tag arrives pr calls it immediately on the same thread%0A     * if a tag has already been found.  Only a single listener is%0A     * allowed so this method overwrites any existing listener%0A     * claiming the event for itself.%0A     * @param onDiscoveredTagListener The listener that requires a tag%0A     */%0A    public void setListener(OnDiscoveredTagListener onDiscoveredTagListener) %7B%0A        this.onDiscoveredTagListener = onDiscoveredTagListener;%0A        if(lastTag != null && this.onDiscoveredTagListener != null) %7B%0A            this.onDiscoveredTagListener.tagDiscovered(lastTag);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Removes the current listener from the arbiter%0A     */%0A    public void unsetListener() %7B%0A        onDiscoveredTagListener = null;%0A    %7D%0A%0A    @Override%0A    public void tagDiscovered(Tag tag) %7B%0A        if(onDiscoveredTagListener != null) %7B%0A            onDiscoveredTagListener.tagDiscovered(tag);%0A        %7D%0A        lastTag = tag;%0A    %7D%0A%0A    /**%0A     * Reset a tag previously found e.g. if it erred%0A     *%0A     * If the tag provided equals the current lastTag, forget about it%0A     * by nulling it.%0A     * @param tag The tag that erred%0A     */%0A    public void tagErrored(Tag tag) %7B%0A        if(lastTag == tag)%0A            lastTag = null;%0A    %7D%0A%7D%0A

Add TagArbiter class