use of hirondelle.date4j.DateTime in project Caldroid by roomorama.
the class CaldroidGridAdapter method populateFromCaldroidData.
/**
* Retrieve internal parameters from caldroid data
*/
@SuppressWarnings("unchecked")
private void populateFromCaldroidData() {
disableDates = (ArrayList<DateTime>) caldroidData.get(CaldroidFragment.DISABLE_DATES);
if (disableDates != null) {
disableDatesMap.clear();
for (DateTime dateTime : disableDates) {
disableDatesMap.put(dateTime, 1);
}
}
selectedDates = (ArrayList<DateTime>) caldroidData.get(CaldroidFragment.SELECTED_DATES);
if (selectedDates != null) {
selectedDatesMap.clear();
for (DateTime dateTime : selectedDates) {
selectedDatesMap.put(dateTime, 1);
}
}
minDateTime = (DateTime) caldroidData.get(CaldroidFragment._MIN_DATE_TIME);
maxDateTime = (DateTime) caldroidData.get(CaldroidFragment._MAX_DATE_TIME);
startDayOfWeek = (Integer) caldroidData.get(CaldroidFragment.START_DAY_OF_WEEK);
sixWeeksInCalendar = (Boolean) caldroidData.get(CaldroidFragment.SIX_WEEKS_IN_CALENDAR);
squareTextViewCell = (Boolean) caldroidData.get(CaldroidFragment.SQUARE_TEXT_VIEW_CELL);
// Get theme
themeResource = (Integer) caldroidData.get(CaldroidFragment.THEME_RESOURCE);
this.datetimeList = CalendarHelper.getFullWeeks(this.month, this.year, startDayOfWeek, sixWeeksInCalendar);
getDefaultResources();
}
use of hirondelle.date4j.DateTime in project Caldroid by roomorama.
the class CaldroidFragment method getDaysOfWeek.
/**
* To display the week day title
*
* @return "SUN, MON, TUE, WED, THU, FRI, SAT"
*/
protected ArrayList<String> getDaysOfWeek() {
ArrayList<String> list = new ArrayList<String>();
SimpleDateFormat fmt = new SimpleDateFormat("EEE", Locale.getDefault());
// 17 Feb 2013 is Sunday
DateTime sunday = new DateTime(2013, 2, 17, 0, 0, 0, 0);
DateTime nextDay = sunday.plusDays(startDayOfWeek - SUNDAY);
for (int i = 0; i < 7; i++) {
Date date = CalendarHelper.convertDateTimeToDate(nextDay);
list.add(fmt.format(date).toUpperCase());
nextDay = nextDay.plusDays(1);
}
return list;
}
use of hirondelle.date4j.DateTime in project Caldroid by roomorama.
the class CaldroidFragment method setTextColorForDate.
public void setTextColorForDate(int textColorRes, Date date) {
DateTime dateTime = CalendarHelper.convertDateToDateTime(date);
textColorForDateTimeMap.put(dateTime, textColorRes);
}
use of hirondelle.date4j.DateTime in project Caldroid by roomorama.
the class CaldroidFragment method setSelectedDate.
/**
* Select single date
* @author Alov Maxim <alovmax@yandex.ru>
*/
public void setSelectedDate(Date date) {
if (date == null) {
return;
}
DateTime dateTime = CalendarHelper.convertDateToDateTime(date);
selectedDates.add(dateTime);
}
use of hirondelle.date4j.DateTime in project Caldroid by roomorama.
the class CaldroidFragment method setupDateGridPages.
/**
* Setup 4 pages contain date grid views. These pages are recycled to use
* memory efficient
*
* @param view
*/
private void setupDateGridPages(View view) {
// Get current date time
DateTime currentDateTime = new DateTime(year, month, 1, 0, 0, 0, 0);
// Set to pageChangeListener
pageChangeListener = new DatePageChangeListener();
pageChangeListener.setCurrentDateTime(currentDateTime);
// Setup adapters for the grid views
// Current month
CaldroidGridAdapter adapter0 = getNewDatesGridAdapter(currentDateTime.getMonth(), currentDateTime.getYear());
// Setup dateInMonthsList
dateInMonthsList = adapter0.getDatetimeList();
// Next month
DateTime nextDateTime = currentDateTime.plus(0, 1, 0, 0, 0, 0, 0, DateTime.DayOverflow.LastDay);
CaldroidGridAdapter adapter1 = getNewDatesGridAdapter(nextDateTime.getMonth(), nextDateTime.getYear());
// Next 2 month
DateTime next2DateTime = nextDateTime.plus(0, 1, 0, 0, 0, 0, 0, DateTime.DayOverflow.LastDay);
CaldroidGridAdapter adapter2 = getNewDatesGridAdapter(next2DateTime.getMonth(), next2DateTime.getYear());
// Previous month
DateTime prevDateTime = currentDateTime.minus(0, 1, 0, 0, 0, 0, 0, DateTime.DayOverflow.LastDay);
CaldroidGridAdapter adapter3 = getNewDatesGridAdapter(prevDateTime.getMonth(), prevDateTime.getYear());
// Add to the array of adapters
datePagerAdapters.add(adapter0);
datePagerAdapters.add(adapter1);
datePagerAdapters.add(adapter2);
datePagerAdapters.add(adapter3);
// Set adapters to the pageChangeListener so it can refresh the adapter
// when page change
pageChangeListener.setCaldroidGridAdapters(datePagerAdapters);
// Setup InfiniteViewPager and InfinitePagerAdapter. The
// InfinitePagerAdapter is responsible
// for reuse the fragments
dateViewPager = (InfiniteViewPager) view.findViewById(R.id.months_infinite_pager);
// Set enable swipe
dateViewPager.setEnabled(enableSwipe);
// Set if viewpager wrap around particular month or all months (6 rows)
dateViewPager.setSixWeeksInCalendar(sixWeeksInCalendar);
// Set the numberOfDaysInMonth to dateViewPager so it can calculate the
// height correctly
dateViewPager.setDatesInMonth(dateInMonthsList);
// MonthPagerAdapter actually provides 4 real fragments. The
// InfinitePagerAdapter only recycles fragment provided by this
// MonthPagerAdapter
final MonthPagerAdapter pagerAdapter = new MonthPagerAdapter(getChildFragmentManager());
// Provide initial data to the fragments, before they are attached to
// view.
fragments = pagerAdapter.getFragments();
for (int i = 0; i < NUMBER_OF_PAGES; i++) {
DateGridFragment dateGridFragment = fragments.get(i);
CaldroidGridAdapter adapter = datePagerAdapters.get(i);
dateGridFragment.setGridViewRes(getGridViewRes());
dateGridFragment.setGridAdapter(adapter);
dateGridFragment.setOnItemClickListener(getDateItemClickListener());
dateGridFragment.setOnItemLongClickListener(getDateItemLongClickListener());
}
// Setup InfinitePagerAdapter to wrap around MonthPagerAdapter
InfinitePagerAdapter infinitePagerAdapter = new InfinitePagerAdapter(pagerAdapter);
// Use the infinitePagerAdapter to provide data for dateViewPager
dateViewPager.setAdapter(infinitePagerAdapter);
// Setup pageChangeListener
dateViewPager.setOnPageChangeListener(pageChangeListener);
}
Aggregations