Methods Summary |
---|
static java.util.HashMap | getAllTimeFeatures(long utcTime)
HashMap<String, String> features = new HashMap<String, String>();
Time time = new Time();
time.set(utcTime);
if (mFakeTimeOfDay != null && mFakeTimeOfDay.length() != 0) {
List<String> day_list = Arrays.asList(DAYTIME_VALUES);
if (day_list.contains(mFakeTimeOfDay)) {
features.put(PERIOD_OF_DAY, DAYTIME);
} else {
features.put(PERIOD_OF_DAY, NIGHTTIME);
}
features.put(TIME_OF_DAY, mFakeTimeOfDay);
} else {
features.put(PERIOD_OF_DAY, getPeriodOfDay(time.hour));
features.put(TIME_OF_DAY, getTimeOfDay(time.hour));
}
if (mFakeDayOfWeek != null && mFakeDayOfWeek.length() != 0) {
features.put(DAY_OF_WEEK, mFakeDayOfWeek);
if (mFakeDayOfWeek.equals(SUNDAY) ||
mFakeDayOfWeek.equals(SATURDAY) ||
mFakeDayOfWeek.equals(FRIDAY) &&
features.get(PERIOD_OF_DAY).equals(NIGHTTIME)) {
features.put(TIME_OF_WEEK, WEEKEND);
} else {
features.put(TIME_OF_WEEK, WEEKDAY);
}
}
else {
features.put(DAY_OF_WEEK, getDayOfWeek(time.weekDay));
if (time.weekDay == Time.SUNDAY || time.weekDay == Time.SATURDAY ||
(time.weekDay == Time.FRIDAY &&
features.get(PERIOD_OF_DAY).equals(NIGHTTIME))) {
features.put(TIME_OF_WEEK, WEEKEND);
} else {
features.put(TIME_OF_WEEK, WEEKDAY);
}
}
return features;
|
private static java.lang.String | getDayOfWeek(int day)
switch (day) {
case Time.SATURDAY:
return SATURDAY;
case Time.SUNDAY:
return SUNDAY;
case Time.MONDAY:
return MONDAY;
case Time.TUESDAY:
return TUESDAY;
case Time.WEDNESDAY:
return WEDNESDAY;
case Time.THURSDAY:
return THURSDAY;
default:
return FRIDAY;
}
|
public static java.util.List | getDayOfWeekValues()
return Arrays.asList(DAY_OF_WEEK_VALUES);
|
public java.util.Map | getFeatureValue(java.lang.String featureName)
HashMap<String,String> feature = new HashMap<String,String>();
HashMap<String, String> features =
getAllTimeFeatures(System.currentTimeMillis());
if (features.containsKey(featureName)) {
feature.put(featureName, features.get(featureName));
} else {
Log.e(TAG, "There is no Time feature called " + featureName);
}
return (Map)feature;
|
public java.lang.String[] | getListOfFeatures()
String [] list = new String[4];
list[0] = TIME_OF_WEEK;
list[1] = DAY_OF_WEEK;
list[2] = TIME_OF_DAY;
list[3] = PERIOD_OF_DAY;
return list;
|
private static java.lang.String | getPeriodOfDay(int hour)
if (hour > 6 && hour < 19) {
return DAYTIME;
} else {
return NIGHTTIME;
}
|
private static java.lang.String | getTimeOfDay(int hour)
if (hour >= 5 && hour < 11) {
return MORNING;
} else if (hour >= 11 && hour < 14) {
return NOON;
} else if (hour >= 14 && hour < 18) {
return AFTERNOON;
} else if (hour >= 18 && hour < 21) {
return EVENING;
} else if ((hour >= 21 && hour < 24) ||
(hour >= 0 && hour < 1)) {
return NIGHT;
} else {
return LATENIGHT;
}
|
public static java.util.List | getTimeOfDayValues()
return Arrays.asList(TIME_OF_DAY_VALUES);
|
public static void | setFakeDayOfWeek(java.lang.String day_of_week)
mFakeDayOfWeek = day_of_week;
|
public static void | setFakeTimeOfDay(java.lang.String time_of_day)
mFakeTimeOfDay = time_of_day;
|