Android Open Source - vitdroid-android Time Labeler

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

/*from ww  w.  j  av a2  s  .  c  o m*/
import java.util.Calendar;

import android.util.Log;


 * A Labeler that displays times in increments of {@value #MINUTEINTERVAL} minutes.
public class TimeLabeler extends Labeler {
    public static int MINUTEINTERVAL = 15;

    private final String mFormatString;

    public TimeLabeler(String formatString) {
        super(80, 60);
        mFormatString = formatString;

    public TimeObject add(long time, int val) {
        return timeObjectfromCalendar(Util.addMinutes(time, val*MINUTEINTERVAL));

     * override this method to set the inital TimeObject to a multiple of MINUTEINTERVAL
    public TimeObject getElem(long time) {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.MINUTE, c.get(Calendar.MINUTE)/MINUTEINTERVAL*MINUTEINTERVAL);
        Log.v("GETELEM","getelem: "+c.get(Calendar.MINUTE));
        return timeObjectfromCalendar(c);

    protected TimeObject timeObjectfromCalendar(Calendar c) {
        return Util.getTime(c, mFormatString, MINUTEINTERVAL);

Java Source Code List