Search in sources :

Example 1 with DateTime

use of hirondelle.date4j.DateTime in project Caldroid by roomorama.

the class CaldroidFragment method clearSelectedDate.

/**
     * Clear selection of the specified date
     * @author Alov Maxim <alovmax@yandex.ru>
     */
public void clearSelectedDate(Date date) {
    if (date == null) {
        return;
    }
    DateTime dateTime = CalendarHelper.convertDateToDateTime(date);
    selectedDates.remove(dateTime);
}
Also used : DateTime(hirondelle.date4j.DateTime)

Example 2 with DateTime

use of hirondelle.date4j.DateTime in project Caldroid by roomorama.

the class CaldroidFragment method setDisableDatesFromString.

/**
     * Set disableDates from ArrayList of String with custom date format. For
     * example, if the date string is 06-Jan-2013, use date format dd-MMM-yyyy.
     * This method will refresh the calendar, it's not necessary to call
     * refreshView()
     *
     * @param disableDateStrings
     * @param dateFormat
     */
public void setDisableDatesFromString(ArrayList<String> disableDateStrings, String dateFormat) {
    if (disableDateStrings == null) {
        return;
    }
    disableDates.clear();
    for (String dateString : disableDateStrings) {
        DateTime dateTime = CalendarHelper.getDateTimeFromString(dateString, dateFormat);
        disableDates.add(dateTime);
    }
}
Also used : DateTime(hirondelle.date4j.DateTime)

Example 3 with DateTime

use of hirondelle.date4j.DateTime in project Caldroid by roomorama.

the class CaldroidFragment method setSelectedDates.

/**
     * Select the dates from fromDate to toDate. By default the background color
     * is holo_blue_light, and the text color is black. You can customize the
     * background by changing CaldroidFragment.selectedBackgroundDrawable, and
     * change the text color CaldroidFragment.selectedTextColor before call this
     * method. This method does not refresh view, need to call refreshView()
     *
     * @param fromDate
     * @param toDate
     */
public void setSelectedDates(Date fromDate, Date toDate) {
    // Ensure fromDate is before toDate
    if (fromDate == null || toDate == null || fromDate.after(toDate)) {
        return;
    }
    selectedDates.clear();
    DateTime fromDateTime = CalendarHelper.convertDateToDateTime(fromDate);
    DateTime toDateTime = CalendarHelper.convertDateToDateTime(toDate);
    DateTime dateTime = fromDateTime;
    while (dateTime.lt(toDateTime)) {
        selectedDates.add(dateTime);
        dateTime = dateTime.plusDays(1);
    }
    selectedDates.add(toDateTime);
}
Also used : DateTime(hirondelle.date4j.DateTime)

Example 4 with DateTime

use of hirondelle.date4j.DateTime in project Caldroid by roomorama.

the class CaldroidFragment method clearTextColorForDate.

public void clearTextColorForDate(Date date) {
    DateTime dateTime = CalendarHelper.convertDateToDateTime(date);
    textColorForDateTimeMap.remove(dateTime);
}
Also used : DateTime(hirondelle.date4j.DateTime)

Example 5 with DateTime

use of hirondelle.date4j.DateTime in project Caldroid by roomorama.

the class CaldroidGridAdapter method setCustomResources.

@SuppressWarnings("unchecked")
protected void setCustomResources(DateTime dateTime, View backgroundView, TextView textView) {
    // Set custom background resource
    Map<DateTime, Drawable> backgroundForDateTimeMap = (Map<DateTime, Drawable>) caldroidData.get(CaldroidFragment._BACKGROUND_FOR_DATETIME_MAP);
    if (backgroundForDateTimeMap != null) {
        // Get background resource for the dateTime
        Drawable drawable = backgroundForDateTimeMap.get(dateTime);
        // Set it
        if (drawable != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                backgroundView.setBackground(drawable);
            } else {
                backgroundView.setBackgroundDrawable(drawable);
            }
        }
    }
    // Set custom text color
    Map<DateTime, Integer> textColorForDateTimeMap = (Map<DateTime, Integer>) caldroidData.get(CaldroidFragment._TEXT_COLOR_FOR_DATETIME_MAP);
    if (textColorForDateTimeMap != null) {
        // Get textColor for the dateTime
        Integer textColorResource = textColorForDateTimeMap.get(dateTime);
        // Set it
        if (textColorResource != null) {
            textView.setTextColor(resources.getColor(textColorResource));
        }
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) HashMap(java.util.HashMap) Map(java.util.Map) DateTime(hirondelle.date4j.DateTime)

Aggregations

DateTime (hirondelle.date4j.DateTime)52 Date (java.util.Date)17 SuppressLint (android.annotation.SuppressLint)8 ArrayList (java.util.ArrayList)6 Calendar (java.util.Calendar)6 DateWindow (com.instructure.candroid.model.DateWindow)4 Test (org.junit.Test)4 View (android.view.View)3 TextView (android.widget.TextView)3 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)3 Dialog (android.app.Dialog)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 LayoutInflater (android.view.LayoutInflater)2 InfinitePagerAdapter (com.antonyt.infiniteviewpager.InfinitePagerAdapter)2 EventData (com.instructure.candroid.model.EventData)2 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Resources (android.content.res.Resources)1 Button (android.widget.Button)1