Android Open Source - vitdroid-android Labeler






From Project

Back to project page vitdroid-android.

License

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

package com.googlecode.android.widgets.DateSlider.labeler;
//from   w  w w  .ja va 2 s  .  c  o  m
import java.util.Calendar;

import android.content.Context;

import com.googlecode.android.widgets.DateSlider.TimeObject;
import com.googlecode.android.widgets.DateSlider.timeview.TimeTextView;
import com.googlecode.android.widgets.DateSlider.timeview.TimeView;

/**
 * This is an abstract class whose job is create TimeViews that can be used
 * to populate a ScrollLayout, and to generate TimeObjects from times that
 * can be used to populate the TimeViews.
 */
public abstract class Labeler {
    /**
     * The default width of views that this labeler generates, in dp
     */
    private final int viewWidthDP;
    /**
     * The default height of views that this labeler generates, in dp
     */
    private final int viewHeightDP;
    
    protected int minuteInterval=1;

    /**
     * @param viewWidthDB The default width of views labeled by this labeler in dp
     * @param viewHeightDB The default height of views labeled by this labeler in dp
     */
    public Labeler(int viewWidthDP, int viewHeightDP) {
        this.viewWidthDP = viewWidthDP;
        this.viewHeightDP = viewHeightDP;
    }

    /**
     * Converts from a time to a TimeObject according to the rules of this labeler.
     *
     * @param time The time to display
     * @return the TimeObject representing "time" suitable for populating TimeViews
     * returned from {@link #createView(Context, boolean)}
     */
    public TimeObject getElem(long time) {
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(time);
        return timeObjectfromCalendar(c);
    }

    /**
     * Returns a new TimeView instance appropriate for population using TimeObjects
     * retrieved from {@link #getElem(long)}.
     *
     * @param context
     * @param isCenterView is true when the view is the central view
     * @return The new unpopulated TimeView object
     */
    public TimeView createView(Context context, boolean isCenterView) {
        return new TimeTextView(context, isCenterView, 25);
    }

    /**
     * This method adds "val" time units (where a time unit is the amount of time that
     * separates one TimeView generated by this labeler from the next -- e.g. if this
     * labeler is producing TimeViews each representing a day, then a time unit would
     * be a single day) to the specified time and returns a TimeObject representing
     * the result.
     *
     * This method will be called constantly, whenever new date information is required.
     *
     * @param time The time
     * @param val The number of units to add to the time
     * @return The resulting TimeObject
     */
    public abstract TimeObject add(long time, int val);
    /**
     * This method converts from a calendar to a TimeObject -- it does the actual
     * work of turning a point time into the range and display string that componse
     * a TimeObject.
     *
     * @param c The time to convert
     * @return The resulting TimeObject
     */
    protected abstract TimeObject timeObjectfromCalendar(Calendar c);

    /**
     * This method return the preferred width of TimeViews labeled by this labeler.
     *
     * @param context
     * @return The preferred width, in pixels
     */
    public int getPreferredViewWidth(Context context) {
        return (int)(viewWidthDP * context.getResources().getDisplayMetrics().density);
    }

    /**
     * This method return the preferred width of TimeViews labeled by this labeler.
     *
     * @param context
     * @return The preferred width, in pixels
     */
    public int getPreferredViewHeight(Context context) {
        return (int)(viewHeightDP * context.getResources().getDisplayMetrics().density);
    }
    
    /**
     * This method sets a minute interval to only show multiples of this number in any
     * minute slider 
     * 
     * @param minInterval
     */
    public void setMinuteInterval(int minInterval) {
      this.minuteInterval = minInterval;
    }
}




Java Source Code List

com.googlecode.android.widgets.DateSlider.AlternativeDateSlider.java
com.googlecode.android.widgets.DateSlider.Attendance.java
com.googlecode.android.widgets.DateSlider.Attendanceboth.java
com.googlecode.android.widgets.DateSlider.BackGroundDialogs.java
com.googlecode.android.widgets.DateSlider.Base64.java
com.googlecode.android.widgets.DateSlider.CustomDateSlider.java
com.googlecode.android.widgets.DateSlider.DBAdapter2.java
com.googlecode.android.widgets.DateSlider.DBAdapter3.java
com.googlecode.android.widgets.DateSlider.DBAdapter5.java
com.googlecode.android.widgets.DateSlider.DBAdapter6.java
com.googlecode.android.widgets.DateSlider.DBAdapter.java
com.googlecode.android.widgets.DateSlider.DBAdaptergrades.java
com.googlecode.android.widgets.DateSlider.DBAdapterlinks.java
com.googlecode.android.widgets.DateSlider.DateSlider.java
com.googlecode.android.widgets.DateSlider.DateTimeSlider.java
com.googlecode.android.widgets.DateSlider.DefaultDateSlider.java
com.googlecode.android.widgets.DateSlider.Demo.java
com.googlecode.android.widgets.DateSlider.FacultyCabin.java
com.googlecode.android.widgets.DateSlider.Faculty.java
com.googlecode.android.widgets.DateSlider.GAttendance.java
com.googlecode.android.widgets.DateSlider.GDBAdapter5.java
com.googlecode.android.widgets.DateSlider.GDBAdapter6.java
com.googlecode.android.widgets.DateSlider.GDBAdapter.java
com.googlecode.android.widgets.DateSlider.GFaculty.java
com.googlecode.android.widgets.DateSlider.GMarks.java
com.googlecode.android.widgets.DateSlider.GStudent.java
com.googlecode.android.widgets.DateSlider.GuestLogin.java
com.googlecode.android.widgets.DateSlider.GuestMainscreen.java
com.googlecode.android.widgets.DateSlider.Login.java
com.googlecode.android.widgets.DateSlider.Mainscreen.java
com.googlecode.android.widgets.DateSlider.MarkAttendance.java
com.googlecode.android.widgets.DateSlider.Marks.java
com.googlecode.android.widgets.DateSlider.MinimalDemo.java
com.googlecode.android.widgets.DateSlider.MonthYearDateSlider.java
com.googlecode.android.widgets.DateSlider.MyService2.java
com.googlecode.android.widgets.DateSlider.MyService4.java
com.googlecode.android.widgets.DateSlider.MyService5.java
com.googlecode.android.widgets.DateSlider.MyService.java
com.googlecode.android.widgets.DateSlider.ObservableScrollView2.java
com.googlecode.android.widgets.DateSlider.ObservableScrollView.java
com.googlecode.android.widgets.DateSlider.QuizRem3.java
com.googlecode.android.widgets.DateSlider.QuizRem4.java
com.googlecode.android.widgets.DateSlider.Quiz.java
com.googlecode.android.widgets.DateSlider.Refresh.java
com.googlecode.android.widgets.DateSlider.SMainScreen.java
com.googlecode.android.widgets.DateSlider.ScrollLayout.java
com.googlecode.android.widgets.DateSlider.ScrollViewListener2.java
com.googlecode.android.widgets.DateSlider.ScrollViewListener.java
com.googlecode.android.widgets.DateSlider.ServiceManager.java
com.googlecode.android.widgets.DateSlider.Settings.java
com.googlecode.android.widgets.DateSlider.SimpleGestureFilter.java
com.googlecode.android.widgets.DateSlider.SliderContainer.java
com.googlecode.android.widgets.DateSlider.Student.java
com.googlecode.android.widgets.DateSlider.TimeObject.java
com.googlecode.android.widgets.DateSlider.TimeSlider.java
com.googlecode.android.widgets.DateSlider.ViewflipActivity.java
com.googlecode.android.widgets.DateSlider.labeler.DayDateLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.DayLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.HourLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.Labeler.java
com.googlecode.android.widgets.DateSlider.labeler.MinuteLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.MonthLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.MonthYearLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.TimeLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.Util.java
com.googlecode.android.widgets.DateSlider.labeler.WeekLabeler.java
com.googlecode.android.widgets.DateSlider.labeler.YearLabeler.java
com.googlecode.android.widgets.DateSlider.timeview.DayTimeLayoutView.java
com.googlecode.android.widgets.DateSlider.timeview.TimeLayoutView.java
com.googlecode.android.widgets.DateSlider.timeview.TimeTextView.java
com.googlecode.android.widgets.DateSlider.timeview.TimeView.java
com.googlecode.android.widgets.DateSlider.global.java
com.googlecode.android.widgets.DateSlider.grades.java
com.googlecode.android.widgets.DateSlider.notif2.java
com.googlecode.android.widgets.DateSlider.notif.java
com.googlecode.android.widgets.DateSlider.pbl.java
com.googlecode.android.widgets.DateSlider.sample.java
in.ac.vit.vitdroid.DBAdaptergrades.java
in.ac.vit.vitdroid.DBAdapterlinks.java