Java Code Examples for java.util.Calendar.THURSDAY

The following are Jave code examples for showing how to use THURSDAY of the java.util.Calendar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: LightSIP   File: SIPDate.java   View Source Code Vote up 8 votes
/**
 * Set the wkday member
 * @param w String to set
 * @throws IllegalArgumentException if w is not a valid day.
 */
public void setWkday(String w) throws IllegalArgumentException {
    sipWkDay = w;
    if (sipWkDay.compareToIgnoreCase(MON) == 0) {
        wkday = Calendar.MONDAY;
    } else if (sipWkDay.compareToIgnoreCase(TUE) == 0) {
        wkday = Calendar.TUESDAY;
    } else if (sipWkDay.compareToIgnoreCase(WED) == 0) {
        wkday = Calendar.WEDNESDAY;
    } else if (sipWkDay.compareToIgnoreCase(THU) == 0) {
        wkday = Calendar.THURSDAY;
    } else if (sipWkDay.compareToIgnoreCase(FRI) == 0) {
        wkday = Calendar.FRIDAY;
    } else if (sipWkDay.compareToIgnoreCase(SAT) == 0) {
        wkday = Calendar.SATURDAY;
    } else if (sipWkDay.compareToIgnoreCase(SUN) == 0) {
        wkday = Calendar.SUNDAY;
    } else {
        throw new IllegalArgumentException("Illegal Week day :" + w);
    }
}
 
Example 2
Project: DateScroller   File: DateScrollerUitls.java   View Source Code Vote up 7 votes
public static String formateDay(Context context,int dayOfWeak){
    switch (dayOfWeak){
        case Calendar.SUNDAY:
        default:
            return  context.getString(R.string.datescroller_sunday);
        case Calendar.MONDAY:
            return context.getString(R.string.datescroller_monday);
        case Calendar.TUESDAY:
            return context.getString(R.string.datescroller_tuseday);
        case Calendar.WEDNESDAY:
            return context.getString(R.string.datescroller_wednesday);
        case Calendar.THURSDAY:
            return context.getString(R.string.datescroller_thursday);
        case Calendar.FRIDAY:
            return context.getString(R.string.datescroller_friday);
        case Calendar.SATURDAY:
            return context.getString(R.string.datescroller_saturday);
    }
}
 
Example 3
Project: GitHub   File: Countly.java   View Source Code Vote up 7 votes
/**
 * Utility method to return a current day of the week that can be used in the Count.ly API.
 */
static int currentDayOfWeek(){
    int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
    switch (day) {
        case Calendar.MONDAY:
            return 1;
        case Calendar.TUESDAY:
            return 2;
        case Calendar.WEDNESDAY:
            return 3;
        case Calendar.THURSDAY:
            return 4;
        case Calendar.FRIDAY:
            return 5;
        case Calendar.SATURDAY:
            return 6;
    }
    return 0;
}
 
Example 4
Project: unitimes   File: Event.java   View Source Code Vote up 7 votes
public String getDays(String[] dayNames, String[] shortDyNames) {
    int nrDays = 0;
    int dayCode = 0;
    for (Meeting meeting : getMeetings()) {
        int dc = 0;
        switch (meeting.getDayOfWeek()) {
           case Calendar.MONDAY    : dc = Constants.DAY_CODES[Constants.DAY_MON]; break;
           case Calendar.TUESDAY   : dc = Constants.DAY_CODES[Constants.DAY_TUE]; break;
           case Calendar.WEDNESDAY : dc = Constants.DAY_CODES[Constants.DAY_WED]; break;
           case Calendar.THURSDAY  : dc = Constants.DAY_CODES[Constants.DAY_THU]; break;
           case Calendar.FRIDAY    : dc = Constants.DAY_CODES[Constants.DAY_FRI]; break;
           case Calendar.SATURDAY  : dc = Constants.DAY_CODES[Constants.DAY_SAT]; break;
           case Calendar.SUNDAY    : dc = Constants.DAY_CODES[Constants.DAY_SUN]; break;
        }
        if ((dayCode & dc)==0) nrDays++;
        dayCode |= dc;
    }
       String ret = "";
    for (int i=0;i<Constants.DAY_CODES.length;i++) {
        if ((dayCode & Constants.DAY_CODES[i])!=0)
            ret += (nrDays==1?dayNames:shortDyNames)[i];
    }
       return ret;
}
 
Example 5
Project: Android-Scrapper   File: GridCalendarAdapter.java   View Source Code Vote up 7 votes
private int getDay(int day) {
    switch (day) {
        case Calendar.SUNDAY:
            return 0;
        case Calendar.MONDAY:
            return 1;
        case Calendar.TUESDAY:
            return 2;
        case Calendar.WEDNESDAY:
            return 3;
        case Calendar.THURSDAY:
            return 4;
        case Calendar.FRIDAY:
            return 5;
        case Calendar.SATURDAY:
            return 6;
        default:
            return 0;
    }
}
 
Example 6
Project: buildAPKsApps   File: TimeUtil.java   View Source Code Vote up 7 votes
private static boolean dayIsRepeat(int calendarDow, int repeat) {
  switch (calendarDow) {
    case Calendar.SUNDAY:
      return (1 & repeat) != 0;
    case Calendar.MONDAY:
      return (2 & repeat) != 0;
    case Calendar.TUESDAY:
      return (4 & repeat) != 0;
    case Calendar.WEDNESDAY:
      return (8 & repeat) != 0;
    case Calendar.THURSDAY:
      return (16 & repeat) != 0;
    case Calendar.FRIDAY:
      return (32 & repeat) != 0;
    case Calendar.SATURDAY:
      return (64 & repeat) != 0;
  }
  return true;
}
 
Example 7
Project: DMS   File: ApplyDataUtil.java   View Source Code Vote up 7 votes
public static boolean canApplyStay() {
    boolean check = false;
    Calendar calendar = Calendar.getInstance();
    int today = calendar.get(Calendar.DAY_OF_WEEK);
    int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    int currentMinute = calendar.get(Calendar.MINUTE);
    if ((Calendar.MONDAY <= today) && (today <= Calendar.THURSDAY)) {
        // Between Monday and Thursday
        if (today == Calendar.THURSDAY) {
            if (currentHour < 20 || (currentHour == 20 && currentMinute <= 30)) {
                check = true;
            } else {
                check = false;
            }
        } else {
            check = true;
        }
    } else {
        check = false;
    }
    return check;
}
 
Example 8
Project: unitimes   File: PersonalizedExamReportAction.java   View Source Code Vote up 7 votes
public int getDaysCode(Set meetings) {
    int daysCode = 0;
    for (Iterator i=meetings.iterator();i.hasNext();) {
        Meeting meeting = (Meeting)i.next();
        Calendar date = Calendar.getInstance(Locale.US);
        date.setTime(meeting.getMeetingDate());
        switch (date.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.MONDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_MON]; break;
        case Calendar.TUESDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_TUE]; break;
        case Calendar.WEDNESDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_WED]; break;
        case Calendar.THURSDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_THU]; break;
        case Calendar.FRIDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_FRI]; break;
        case Calendar.SATURDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_SAT]; break;
        case Calendar.SUNDAY : daysCode |= Constants.DAY_CODES[Constants.DAY_SUN]; break;
        }
    }
    return daysCode;
}
 
Example 9
Project: wisebite_android   File: Utils.java   View Source Code Vote up 7 votes
public static int parseViewIdToDayOfWeek(Integer viewId) {
    switch (viewId) {
        case R.id.monday_date_picker:
            return Calendar.MONDAY;
        case R.id.tuesday_date_picker:
            return Calendar.TUESDAY;
        case R.id.wednesday_date_picker:
            return Calendar.WEDNESDAY;
        case R.id.thursday_date_picker:
            return Calendar.THURSDAY;
        case R.id.friday_date_picker:
            return Calendar.FRIDAY;
        case R.id.saturday_date_picker:
            return Calendar.SATURDAY;
        case R.id.sunday_date_picker:
            return Calendar.SUNDAY;
        default:
            return 0;
    }
}
 
Example 10
Project: unitimes   File: Constants.java   View Source Code Vote up 7 votes
public static int getDayOfWeek(Date date) {
  	Calendar c = Calendar.getInstance(Locale.US);
  	c.setTime(date);
switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.MONDAY:
	return DAY_MON;
case Calendar.TUESDAY:
	return DAY_TUE;
case Calendar.WEDNESDAY:
	return DAY_WED;
case Calendar.THURSDAY:
	return DAY_THU;
case Calendar.FRIDAY:
	return DAY_FRI;
case Calendar.SATURDAY:
	return DAY_SAT;
case Calendar.SUNDAY:
	return DAY_SUN;
default:
	return DAY_MON;
}
  }
 
Example 11
Project: broadlink-java-api   File: DiscoveryPacket.java   View Source Code Vote up 7 votes
private static int dayOfWeekConv(int fieldVal) {
    switch (fieldVal) {
    case Calendar.SUNDAY:
        return 6;
    case Calendar.MONDAY:
        return 0;
    case Calendar.TUESDAY:
        return 1;
    case Calendar.WEDNESDAY:
        return 2;
    case Calendar.THURSDAY:
        return 3;
    case Calendar.FRIDAY:
        return 4;
    case Calendar.SATURDAY:
        return 5;
    }
    return -1;
}
 
Example 12
Project: CHIP-Android-SDK   File: AlarmFragment.java   View Source Code Vote up 6 votes
void setCurrentClock() {
    ChipRobot robot = ChipRobotFinder.getInstance().getChipRobotConnectedList().get(0);

    Calendar rightNow = Calendar.getInstance();
    final int year = rightNow.get(Calendar.YEAR);
    final int month = rightNow.get(Calendar.MONTH);
    final int day = rightNow.get(Calendar.DATE);
    final int hour = rightNow.get(Calendar.HOUR_OF_DAY);
    final int minute = rightNow.get(Calendar.MINUTE);
    final int seconds = rightNow.get(Calendar.SECOND);
    int dayOfWeek_t = rightNow.get(Calendar.DAY_OF_WEEK);
    switch (dayOfWeek_t) {
        case Calendar.SUNDAY:
            dayOfWeek_t = 0;
            break;
        case Calendar.MONDAY:
            dayOfWeek_t = 1;
            break;
        case Calendar.TUESDAY:
            dayOfWeek_t = 2;
            break;
        case Calendar.WEDNESDAY:
            dayOfWeek_t = 3;
            break;
        case Calendar.THURSDAY:
            dayOfWeek_t = 4;
            break;
        case Calendar.FRIDAY:
            dayOfWeek_t = 5;
            break;
        case Calendar.SATURDAY:
            break;
    }
    final int dayOfWeek = dayOfWeek_t;
    robot.chipSetCurrentClock(year, (byte) (month + 1), (byte) day, (byte) hour, (byte) minute, (byte) seconds, (byte) dayOfWeek);
}
 
Example 13
Project: SER316-Dresden   File: EventsTableMonthly.java   View Source Code Vote up 6 votes
public Object getValueAt(int row, int col) {
	Event ev = getEventAt(row,col);
	if(ev == null) return "";
	Calendar cal = (Calendar)days[col].get(row);
	String res = "";
	switch(cal.get(Calendar.DAY_OF_WEEK)){
		case Calendar.SUNDAY: res += "SU";
			break;
		case Calendar.MONDAY: res += "MO";
			break;
		case Calendar.TUESDAY: res += "TU";
			break;
		case Calendar.WEDNESDAY: res += "WE";
			break;
		case Calendar.THURSDAY: res += "TH";
			break;
		case Calendar.FRIDAY: res += "FR";
			break;
		case Calendar.SATURDAY: res += "SA";
			break;
		default: res += "??";
	}
	String dOM = cal.get(Calendar.DAY_OF_MONTH) + "";
	switch(cal.get(Calendar.DAY_OF_MONTH)%10){
		case 1: dOM += "st";
			break;
		case 2: dOM += "nd";
			break;
		case 3: dOM += "rd";
			break;
		default:dOM+="th";
	}
	res+= " / " + dOM  + ": ";
	if(ev.getText().equals("")) res+= "EVENT";
	else res += ev.getText();
	return res;       		
}
 
Example 14
Project: unitimes   File: MinutesPerWeek.java   View Source Code Vote up 6 votes
/**
 * Return all dates marked yellow in the given date pattern that are matching the selected day code (days of week)
 */
@Override
public List<Date> getDates(int minsPerWeek, DatePattern datePattern, int dayCode, int minutesPerMeeting) {
	List<Date> ret = new ArrayList<Date>();
	if (datePattern == null) return ret;
	Calendar cal = Calendar.getInstance(Locale.US);
	cal.setTime(datePattern.getStartDate()); cal.setLenient(true);
       EventDateMapping.Class2EventDateMap class2eventDates = EventDateMapping.getMapping(datePattern.getSession().getUniqueId());
       String pattern = datePattern.getPattern();
       for (int idx = 0; idx < pattern.length(); idx++) {
       	if (pattern.charAt(idx) == '1') {
       		boolean offered = false;
       		switch (cal.get(Calendar.DAY_OF_WEEK)) {
       			case Calendar.MONDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_MON]) != 0); break;
       			case Calendar.TUESDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_TUE]) != 0); break;
       			case Calendar.WEDNESDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_WED]) != 0); break;
       			case Calendar.THURSDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_THU]) != 0); break;
       			case Calendar.FRIDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_FRI]) != 0); break;
       			case Calendar.SATURDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_SAT]) != 0); break;
       			case Calendar.SUNDAY : offered = ((dayCode & Constants.DAY_CODES[Constants.DAY_SUN]) != 0); break;
       		}
       		if (offered) ret.add(class2eventDates.getEventDate(cal.getTime()));
       	}
       	cal.add(Calendar.DAY_OF_YEAR, 1);
       }
	return ret;
}
 
Example 15
Project: unitimes   File: InstructorScheduleConnector.java   View Source Code Vote up 6 votes
protected static Date firstDate(DatePattern dp, int dayCode) {
   	if (dp == null) return null;
   	BitSet weekCode = dp.getPatternBitSet();
   	if (weekCode.isEmpty()) return null;
   	Calendar cal = Calendar.getInstance(Locale.US); cal.setLenient(true);
   	Date dpFirstDate = DateUtils.getDate(1, dp.getSession().getPatternStartMonth(), dp.getSession().getSessionStartYear());
   	cal.setTime(dpFirstDate);
   	int idx = weekCode.nextSetBit(0);
   	cal.add(Calendar.DAY_OF_YEAR, idx);
   	while (idx < weekCode.size()) {
   		if (weekCode.get(idx)) {
       		int dow = cal.get(Calendar.DAY_OF_WEEK);
       		switch (dow) {
       		case Calendar.MONDAY:
       			if ((dayCode & DayCode.MON.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.TUESDAY:
       			if ((dayCode & DayCode.TUE.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.WEDNESDAY:
       			if ((dayCode & DayCode.WED.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.THURSDAY:
       			if ((dayCode & DayCode.THU.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.FRIDAY:
       			if ((dayCode & DayCode.FRI.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.SATURDAY:
       			if ((dayCode & DayCode.SAT.getCode()) != 0) return cal.getTime();
       			break;
       		case Calendar.SUNDAY:
       			if ((dayCode & DayCode.SUN.getCode()) != 0) return cal.getTime();
       			break;
       		}
       	}
   		cal.add(Calendar.DAY_OF_YEAR, 1); idx++;
   	}
   	return null;
}
 
Example 16
Project: EsperantoRadio   File: RepeatPreference.java   View Source Code Vote up 6 votes
public RepeatPreference(Context context, AttributeSet attrs) {
  super(context, attrs);

  String[] weekdays = new DateFormatSymbols().getWeekdays();
  String[] values = new String[]{
      weekdays[Calendar.MONDAY],
      weekdays[Calendar.TUESDAY],
      weekdays[Calendar.WEDNESDAY],
      weekdays[Calendar.THURSDAY],
      weekdays[Calendar.FRIDAY],
      weekdays[Calendar.SATURDAY],
      weekdays[Calendar.SUNDAY],};
  setEntries(values);
  setEntryValues(values);
}
 
Example 17
Project: School1-Android   File: DashboardAdapter.java   View Source Code Vote up 5 votes
public DashboardAdapter(Context context) {
    Calendar calendar = Calendar.getInstance();
    int today = calendar.get(Calendar.DAY_OF_WEEK);

    // Today is default
    rowItems.add(new Section(context.getString(R.string.section_title_today), getSectionDate(calendar)));
    calendar.add(Calendar.DAY_OF_YEAR, 1);

    if (today >= Calendar.MONDAY && today <= Calendar.WEDNESDAY) {
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        rowItems.add(new Section(context.getString(R.string.section_title_this_week), getSectionDate(calendar)));
    } else if (today == Calendar.THURSDAY) {
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
    } else if (today == Calendar.FRIDAY)
        rowItems.add(new Section(context.getString(R.string.section_title_weekend), getSectionDate(calendar)));
    else if (today == Calendar.SATURDAY)
        rowItems.add(new Section(context.getString(R.string.section_title_tomorrow), getSectionDate(calendar)));

    calendar = Calendar.getInstance();
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

    if (calendar.getFirstDayOfWeek() != Calendar.SUNDAY || today != Calendar.SUNDAY)
        calendar.add(Calendar.WEEK_OF_YEAR, 1);

    rowItems.add(new Section(context.getString(R.string.section_title_next_week), getSectionDate(calendar)));

    // TODO: Holiday and interval sections (between two holidays, to give a clearer overview over whats happening in the long run)
    calendar.add(Calendar.WEEK_OF_YEAR, 1);
    rowItems.add(new Section("Until the end of the universe", getSectionDate(calendar)));

    // TODO: Listen on login
    UserInfo userInfo = FirebaseAuth.getInstance().getCurrentUser();
    if (userInfo != null) {
        DocumentReference userReference = FirebaseFirestore.getInstance()
                .collection("users")
                .document(userInfo.getUid());

        userReference.collection("groups")
                .addSnapshotListener(this);
        userReference.collection("items")
                .addSnapshotListener(new GroupItemsChangeListener(FirebaseAuth.getInstance().getCurrentUser().getUid()));
    }
}
 
Example 18
Project: unitimes   File: CourseOfferingExport.java   View Source Code Vote up 5 votes
protected void exportEvent(Element classElement, Event event, Session session) {
  	if (event == null) return;
  	List<Meeting> meetings = new ArrayList<Meeting>(event.getMeetings());
  	Collections.sort(meetings, new Comparator<Meeting>() {
	@Override
	public int compare(Meeting m1, Meeting m2) {
		if (m1.equals(m2)) return 0;
		int cmp = m1.getMeetingDate().compareTo(m2.getMeetingDate());
		if (cmp != 0) return cmp;
		cmp = m1.getStartPeriod().compareTo(m2.getStartPeriod());
		if (cmp != 0) return cmp;
		Location l1 = (m1.getLocationPermanentId() == null ? null : iMeetingLocations.get(m1.getLocationPermanentId()));
		Location l2 = (m2.getLocationPermanentId() == null ? null : iMeetingLocations.get(m2.getLocationPermanentId()));
		cmp = (l1 == null ? "" : l1.getLabel()).compareTo(l2 == null ? "" : l2.getLabel());
		if (cmp != 0) return cmp;
		return m1.getUniqueId().compareTo(m2.getUniqueId());
	}
});
      for (Meeting meeting: meetings) {
          if (meeting.getStatus() != Meeting.Status.APPROVED) continue;
          Element meetingElement = classElement.addElement("meeting");
          meetingElement.addAttribute("startDate", sDateFormat.format(meeting.getMeetingDate()));
          meetingElement.addAttribute("endDate", sDateFormat.format(meeting.getMeetingDate()));
          meetingElement.addAttribute("startTime", sTimeFormat.format(meeting.getStartTime()));
          meetingElement.addAttribute("endTime", sTimeFormat.format(meeting.getStopTime()));
          Calendar c = Calendar.getInstance(Locale.US); c.setTime(meeting.getMeetingDate());
          switch (c.get(Calendar.DAY_OF_WEEK)) {
              case Calendar.MONDAY : meetingElement.addAttribute("days","M"); break;
              case Calendar.TUESDAY : meetingElement.addAttribute("days","T"); break;
              case Calendar.WEDNESDAY : meetingElement.addAttribute("days","W"); break;
              case Calendar.THURSDAY : meetingElement.addAttribute("days","R"); break;
              case Calendar.FRIDAY : meetingElement.addAttribute("days","F"); break;
              case Calendar.SATURDAY : meetingElement.addAttribute("days","S"); break;
              case Calendar.SUNDAY : meetingElement.addAttribute("days","U"); break;
          }
          Location location = (meeting.getLocationPermanentId() == null ? null : iMeetingLocations.get(meeting.getLocationPermanentId()));
          if (location==null) {
          } else if (location instanceof Room) {
              meetingElement.addAttribute("building", ((Room)location).getBuildingAbbv());
              meetingElement.addAttribute("room", ((Room)location).getRoomNumber());
          } else {
              meetingElement.addAttribute("location", location.getLabel());
          }
      }
  }
 
Example 19
Project: routineKeen   File: HabitTrackerFullTest.java   View Source Code Vote up 5 votes
@Test
public void testHabitSchedule() {

    // Get current day of the week in string form
    String today;
    int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
    switch (day) {
        case Calendar.SUNDAY:   today = "Sun";  break;
        case Calendar.MONDAY:   today = "Mon";  break;
        case Calendar.TUESDAY:  today = "Tue";  break;
        case Calendar.WEDNESDAY:today = "Wed";  break;
        case Calendar.THURSDAY: today = "Thu";  break;
        case Calendar.FRIDAY:   today = "Fri";  break;
        case Calendar.SATURDAY: today = "Sat";  break;
        default:                today = null;   break;
    }

    login();

    // add 2 habits
    solo.assertCurrentActivity("Wrong Activity", UserMenu.class);
    solo.clickOnText("View Habit List");
    clearHabitList();

    addTestHabit(TEST_HABIT_NAME, TEST_HABIT_REASON);
    addTestHabit(TEST_HABIT_NAME2, TEST_HABIT_REASON);
    addTestHabit(TEST_HABIT_NAME3, TEST_HABIT_REASON);

    solo.assertCurrentActivity("Wrong Activity", HabitListActivity.class);
    solo.clickOnText(TEST_HABIT_NAME);
    disableAllDays();
    solo.clickOnButton("Save");

    solo.assertCurrentActivity("Wrong Activity", HabitListActivity.class);
    solo.clickOnText(TEST_HABIT_NAME2);
    disableAllDays();
    solo.clickOnText(today);
    solo.clickOnButton("Save");

    solo.goBack();
    solo.assertCurrentActivity("Wrong Activity", UserMenu.class);
    solo.clickOnText("View Habit Schedule");

    try { TimeUnit.SECONDS.sleep(2); } catch (InterruptedException e) { Log.d(LOG, "wait interrupted"); }
    // check that there are 2 habits in today's schedule
    assertEquals(((ListView)solo.getView("habitSchedule_listView")).getAdapter().getCount(), 2);
}
 
Example 20
Project: unitimes   File: EventRoomAvailabilityBackend.java   View Source Code Vote up 5 votes
public static TreeSet<MeetingConflictInterface> generateUnavailabilityMeetings(Location location, List<Integer> dates, int startSlot, int endSlot) {
	if (location.getEventAvailability() == null || location.getEventAvailability().length() != Constants.SLOTS_PER_DAY * Constants.DAY_CODES.length) return null;

	TreeSet<MeetingConflictInterface> ret = new TreeSet<MeetingConflictInterface>();
	
	ResourceInterface resource = new ResourceInterface();
	resource.setType(ResourceType.ROOM);
	resource.setId(location.getUniqueId());
	resource.setName(location.getLabel());
	resource.setSize(location.getCapacity());
	resource.setRoomType(location.getRoomTypeLabel());
	resource.setBreakTime(location.getEffectiveBreakTime());
	resource.setMessage(location.getEventMessage());
	resource.setIgnoreRoomCheck(location.isIgnoreRoomCheck());
	resource.setDisplayName(location.getDisplayName());
	
	Calendar calendar = Calendar.getInstance();
       for (int day = 0; day < Constants.DAY_CODES.length; day++)
       	for (int startTime = 0; startTime < Constants.SLOTS_PER_DAY; ) {
       		if (location.getEventAvailability().charAt(day * Constants.SLOTS_PER_DAY + startTime) != '1') { startTime++; continue; }
       		int endTime = startTime + 1;
       		while (endTime < Constants.SLOTS_PER_DAY && location.getEventAvailability().charAt(day * Constants.SLOTS_PER_DAY + endTime) == '1') endTime++;
       		if (startTime < endSlot && startSlot < endTime) {
           		calendar.setTime(location.getSession().getEventBeginDate());
           		int dayOfYear = CalendarUtils.date2dayOfYear(location.getSession().getSessionStartYear(), calendar.getTime());
           		
           		do {
           			if (dates.contains(dayOfYear)) {
               			int dayOfWeek = -1;
               			switch (calendar.get(Calendar.DAY_OF_WEEK)) {
               			case Calendar.MONDAY: dayOfWeek = Constants.DAY_MON; break;
               			case Calendar.TUESDAY: dayOfWeek = Constants.DAY_TUE; break;
               			case Calendar.WEDNESDAY: dayOfWeek = Constants.DAY_WED; break;
               			case Calendar.THURSDAY: dayOfWeek = Constants.DAY_THU; break;
               			case Calendar.FRIDAY: dayOfWeek = Constants.DAY_FRI; break;
               			case Calendar.SATURDAY: dayOfWeek = Constants.DAY_SAT; break;
               			case Calendar.SUNDAY: dayOfWeek = Constants.DAY_SUN; break;
               			}
               			
               			if (day == dayOfWeek) {
                   			MeetingConflictInterface m = new MeetingConflictInterface();
               				m.setName(MESSAGES.unavailableEventDefaultName());
               				m.setType(EventInterface.EventType.Unavailabile);
                       		m.setStartSlot(startTime);
                       		m.setEndSlot(endTime);
                       		m.setDayOfWeek(dayOfWeek);
                       		m.setMeetingDate(calendar.getTime());
                       		m.setDayOfYear(dayOfYear);
                       		m.setLocation(resource);
                       		ret.add(m);
               			}
           			}
           			calendar.add(Calendar.DAY_OF_YEAR, 1); dayOfYear++;
           		} while (!calendar.getTime().after(location.getSession().getEventEndDate()));        			
       		}
       		startTime = endTime;
       	}
	return ret;
}