Android Open Source - vitdroid-android Demo






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

/*
 * Copyright (C) 2011 Daniel Berndt - Codeus Ltd  -  DateSlider
 *// w  ww  .j a  va 2s . c  o  m
 * This is a small demo application which demonstrates the use of the
 * dateSelector
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.android.widgets.DateSlider;

import java.util.Calendar;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.googlecode.android.widgets.DateSlider.labeler.TimeLabeler;

/**
 * Small Demo activity which demonstrates the use of the DateSlideSelector
 *
 * @author Daniel Berndt - Codeus Ltd
 *
 */
public class Demo extends Activity {

static final int DEFAULTDATESELECTOR_ID = 0;
static final int DEFAULTDATESELECTOR_WITHLIMIT_ID = 6;
static final int ALTERNATIVEDATESELECTOR_ID = 1;
static final int CUSTOMDATESELECTOR_ID = 2;
static final int MONTHYEARDATESELECTOR_ID = 3;
static final int TIMESELECTOR_ID = 4;
static final int TIMESELECTOR_WITHLIMIT_ID = 7;
static final int DATETIMESELECTOR_ID = 5;

    private TextView dateText;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        // load and initialise the Activity
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        dateText = (TextView) this.findViewById(R.id.datetext);
        Button defaultButton = (Button) this.findViewById(R.id.defaultDateSelectButton);
        // set up a listener for when the button is pressed
        defaultButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(DEFAULTDATESELECTOR_ID);
            }
        });
        
        Button defaultLimitButton = (Button) this.findViewById(R.id.defaultDateLimitSelectButton);
        // set up a listener for when the button is pressed
        defaultLimitButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(DEFAULTDATESELECTOR_WITHLIMIT_ID);
            }
        });

        Button alternativeButton = (Button) this.findViewById(R.id.alternativeDateSelectButton);
        // set up a listener for when the button is pressed
        alternativeButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(ALTERNATIVEDATESELECTOR_ID);
            }
        });

        Button customButton = (Button) this.findViewById(R.id.customDateSelectButton);
        // set up a listener for when the button is pressed
        customButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(CUSTOMDATESELECTOR_ID);
            }
        });

        Button monthYearButton = (Button) this.findViewById(R.id.monthYearDateSelectButton);
        // set up a listener for when the button is pressed
        monthYearButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(MONTHYEARDATESELECTOR_ID);
            }
        });

        Button timeButton = (Button) this.findViewById(R.id.timeSelectButton);
        // set up a listener for when the button is pressed
        timeButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(TIMESELECTOR_ID);
            }
        });
        
        Button timeLimitButton = (Button) this.findViewById(R.id.timeLimitSelectButton);
        // set up a listener for when the button is pressed
        timeLimitButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(TIMESELECTOR_WITHLIMIT_ID);
            }
        });

        Button dateTimeButton = (Button) this.findViewById(R.id.dateTimeSelectButton);
        // set up a listener for when the button is pressed
        dateTimeButton.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // call the internal showDialog method using the predefined ID
                showDialog(DATETIMESELECTOR_ID);
            }
        });
    }

    // define the listener which is called once a user selected the date.
    private DateSlider.OnDateSetListener mDateSetListener =
        new DateSlider.OnDateSetListener() {
            public void onDateSet(DateSlider view, Calendar selectedDate) {
                // update the dateText view with the corresponding date
                dateText.setText(String.format("The chosen date:%n%te. %tB %tY", selectedDate, selectedDate, selectedDate));
            }
    };

    private DateSlider.OnDateSetListener mMonthYearSetListener =
        new DateSlider.OnDateSetListener() {
            public void onDateSet(DateSlider view, Calendar selectedDate) {
                // update the dateText view with the corresponding date
                dateText.setText(String.format("The chosen date:%n%tB %tY", selectedDate, selectedDate));
            }
    };

    private DateSlider.OnDateSetListener mTimeSetListener =
        new DateSlider.OnDateSetListener() {
            public void onDateSet(DateSlider view, Calendar selectedDate) {
                // update the dateText view with the corresponding date
                dateText.setText(String.format("The chosen time:%n%tR", selectedDate));
            }
    };

    private DateSlider.OnDateSetListener mDateTimeSetListener =
        new DateSlider.OnDateSetListener() {
            public void onDateSet(DateSlider view, Calendar selectedDate) {
                // update the dateText view with the corresponding date
                int minute = selectedDate.get(Calendar.MINUTE) /
                        TimeLabeler.MINUTEINTERVAL*TimeLabeler.MINUTEINTERVAL;
                dateText.setText(String.format("The chosen date and time:%n%te. %tB %tY%n%tH:%02d",
                        selectedDate, selectedDate, selectedDate, selectedDate, minute));
            }
    };

    @Override
    protected Dialog onCreateDialog(int id) {
        // this method is called after invoking 'showDialog' for the first time
        // here we initiate the corresponding DateSlideSelector and return the dialog to its caller
      
        final Calendar c = Calendar.getInstance();
        switch (id) {
        case DEFAULTDATESELECTOR_ID:
            return new DefaultDateSlider(this,mDateSetListener,c);
        case DEFAULTDATESELECTOR_WITHLIMIT_ID:
          final Calendar maxTime = Calendar.getInstance();
          maxTime.add(Calendar.DAY_OF_MONTH, 14);
            return new DefaultDateSlider(this,mDateSetListener,c,c,maxTime);
        case ALTERNATIVEDATESELECTOR_ID:
            return new AlternativeDateSlider(this,mDateSetListener,c,c,null);
        case CUSTOMDATESELECTOR_ID:
            return new CustomDateSlider(this,mDateSetListener,c);
        case MONTHYEARDATESELECTOR_ID:
            return new MonthYearDateSlider(this,mMonthYearSetListener,c);
        case TIMESELECTOR_ID:
            return new TimeSlider(this,mTimeSetListener,c,15);
        case TIMESELECTOR_WITHLIMIT_ID:
          final Calendar minTime = Calendar.getInstance();
          minTime.add(Calendar.HOUR, -2);
            return new TimeSlider(this,mTimeSetListener,c,minTime,c,5);
        case DATETIMESELECTOR_ID:
            return new DateTimeSlider(this,mDateTimeSetListener,c);
        }
        return null;
    }
}




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