ConfirmationSwipeBar.java revision 4daaf3ed5fb272fb8a6850af6b81c0ef1b983a52
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
*/
/**
* UI element which is a bar which can be swiped from left to right. When the right side is reached,
* and the user releases their finger, the action is complete. A listener can be set which will
* receive an event when this happens. The bar can be reset by calling unselect().
*/
public class ConfirmationSwipeBar extends SeekBar {
private ConfirmationSwipeBarListener listener;
private boolean isTrackingTouch;
private boolean selectionComplete = false;
setup();
}
setup();
}
super(context);
setup();
}
private void setup() {
isTrackingTouch = false;
}
}
isTrackingTouch = true;
}
boolean fromUser) {
} else {
}
}
});
}
private void completeSelection() {
selectionComplete = true;
}
}
return super.onTouchEvent(event);
}
return false;
}
if(!isTrackingTouch && !selectionComplete) {
}
}
/**
* Reset the bar to its default state (thumb at far left)
*/
public void unselect() {
setProgress(0);
selectionComplete = false;
}
/**
* Sets up the listener which can receive the onConfirm event.
* @param listener The listener to use. Only one listener can be set.
*/
}
/**
* Listener class which waits for the onConfirm() function to be called.
*/
public static abstract class ConfirmationSwipeBarListener {
/**
* Called when the swipe bar is wiped all the way to the right.
*/
public abstract void onConfirm();
}
}