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);
}
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);
}
}
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);
}
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);
}
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));
}
}
}
Aggregations