Android Open Source - vitdroid-android Time Text View

From Project

Back to project page vitdroid-android.


The source code is released under:

Apache License

If you think the Android project vitdroid-android 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

//  w  w w .j  ava 2 s.  co m
import android.content.Context;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.TextView;


 * This is a simple implementation of a TimeView which is implemented
 * as a TextView. It is aware of whether or not it is the center view
 * in the ScrollLayout so that it can alter its appearance to indicate
 * that it is currently selected.
public class TimeTextView extends TextView implements TimeView {
    protected long endTime, startTime;
    protected boolean isOutOfBounds = false;

     * constructor
     * @param context
     * @param isCenterView true if the element is the centered view in the ScrollLayout
     * @param textSize text size in dps
    public TimeTextView(Context context, boolean isCenterView, int textSize) {
        setupView(isCenterView, textSize);

     * this method should be overwritten by inheriting classes to define its own look and feel
     * @param isCenterView true if the element is in the center of the scrollLayout
     * @param textSize textSize in dps
    protected void setupView(boolean isCenterView, int textSize) {
        setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
        if (isCenterView) {
        } else {

    public void setVals(TimeObject to) {
        this.startTime = to.startTime;
        this.endTime = to.endTime;

    public void setVals(TimeView other) {
        startTime = other.getStartTime();
        endTime = other.getEndTime();
    public long getStartTime() {
        return this.startTime;

    public long getEndTime() {
        return this.endTime;

    public String getTimeText() {
        return getText().toString();

  public boolean isOutOfBounds() {
    return isOutOfBounds;

  public void setOutOfBounds(boolean outOfBounds) {
    if (outOfBounds && !isOutOfBounds) {
    else if (!outOfBounds && isOutOfBounds) {
    isOutOfBounds = outOfBounds;


Java Source Code List