Search in sources :

Example 51 with DateTime

use of hirondelle.date4j.DateTime in project instructure-android by instructure.

the class CalendarListRecyclerAdapter method getFirstStartDate.

private Calendar getFirstStartDate() {
    int startDay = getStartDayOfWeek();
    Calendar cal = Calendar.getInstance();
    DateTime today = DateTime.forInstant(cal.getTime().getTime(), TimeZone.getDefault());
    ArrayList<DateTime> dates = CalendarHelper.getFullWeeks(today.getMonth(), today.getYear(), startDay, false);
    DateTime startDate = dates.get(0);
    cal.set(startDate.getYear(), startDate.getMonth() - 1, startDate.getDay(), startDate.getHour(), startDate.getMinute(), startDate.getSecond());
    return cal;
}
Also used : Calendar(java.util.Calendar) DateTime(hirondelle.date4j.DateTime)

Example 52 with DateTime

use of hirondelle.date4j.DateTime in project instructure-android by instructure.

the class CalendarListRecyclerAdapter method addItemForViewType.

/**
 * A small helper method to make adding items to our adapter simpler
 *
 * @param s
 * @return
 */
private boolean addItemForViewType(ScheduleItem s) {
    Date d = s.getStartAt();
    if (d == null) {
        return false;
    }
    DateTime dateTime = DateTime.forInstant(d.getTime(), TimeZone.getDefault());
    CalendarListViewFragment.CalendarView currentCalendarView = CalendarListViewFragment.CalendarView.fromInteger(mAdapterToCalendarCallback.getCurrentCalendarView());
    if (currentCalendarView == CalendarListViewFragment.CalendarView.DAY_VIEW && mSelectedDay != null) {
        if (dateTime.getDay().equals(mSelectedDay.getDay()) && dateTime.getMonth().equals(mSelectedDay.getMonth())) {
            addOrUpdateItem(DateHelper.getCleanDate(d.getTime()), s);
        }
    } else if (currentCalendarView == CalendarListViewFragment.CalendarView.WEEK_VIEW && mSelectedDay != null) {
        Date selectedDate = new Date(mSelectedDay.getMilliseconds(TimeZone.getDefault()));
        DateWindow dateWindow = CanvasCalendarUtils.setSelectedWeekWindow(selectedDate, mIsStartDayMonday);
        if (CanvasCalendarUtils.isWithinWeekWindow(d, dateWindow.getStart(), dateWindow.getEnd())) {
            addOrUpdateItem(DateHelper.getCleanDate(d.getTime()), s);
        }
    } else if (currentCalendarView == CalendarListViewFragment.CalendarView.MONTH_VIEW) {
        addOrUpdateItem(DateHelper.getCleanDate(d.getTime()), s);
    }
    return true;
}
Also used : DateWindow(com.instructure.candroid.model.DateWindow) CalendarListViewFragment(com.instructure.candroid.fragment.CalendarListViewFragment) Date(java.util.Date) 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