@Test public void testWeekLabelFromNumber() { assertEquals(EventHelper.weekLabelFromNum(2015, -1), EventHelper.PRESEASON_LABEL); assertEquals(EventHelper.weekLabelFromNum(2015, 4), "Week 4"); assertEquals(EventHelper.weekLabelFromNum(2015, 9), EventHelper.CHAMPIONSHIP_LABEL); assertEquals(EventHelper.weekLabelFromNum(2015, 12), EventHelper.OFFSEASON_LABEL); assertEquals(EventHelper.weekLabelFromNum(2016, -1), EventHelper.PRESEASON_LABEL); assertEquals(EventHelper.weekLabelFromNum(2016, 1), "Week 0.5"); assertEquals(EventHelper.weekLabelFromNum(2016, 4), "Week 3"); assertEquals(EventHelper.weekLabelFromNum(2016, 10), EventHelper.CHAMPIONSHIP_LABEL); assertEquals(EventHelper.weekLabelFromNum(2016, 12), EventHelper.OFFSEASON_LABEL); }
public static String weekLabelFromNum(int year, @Nullable Integer weekNum) { if (weekNum == null) { return WEEKLESS_LABEL; } if (weekNum <= 0) { return PRESEASON_LABEL; } int cmpWeek = Utilities.getCmpWeek(year); if (year == 2016 && weekNum == 1) { return String.format(FLOAT_REGIONAL_LABEL, 0.5); } if (year == 2016 && weekNum > 1 && weekNum < cmpWeek) { weekNum--; } if (weekNum > 0 && weekNum < cmpWeek) { return String.format(REGIONAL_LABEL, weekNum); } if (weekNum == cmpWeek) { return CHAMPIONSHIP_LABEL; } if (weekNum > cmpWeek) { return OFFSEASON_LABEL; } return WEEKLESS_LABEL; }
EventHelper { public static String weekLabelFromNum(int year, @Nullable Integer weekNum) { if (weekNum == null) { return WEEKLESS_LABEL; } if (weekNum <= 0) { return PRESEASON_LABEL; } int cmpWeek = Utilities.getCmpWeek(year); if (year == 2016 && weekNum == 1) { return String.format(FLOAT_REGIONAL_LABEL, 0.5); } if (year == 2016 && weekNum > 1 && weekNum < cmpWeek) { weekNum--; } if (weekNum > 0 && weekNum < cmpWeek) { return String.format(REGIONAL_LABEL, weekNum); } if (weekNum == cmpWeek) { return CHAMPIONSHIP_LABEL; } if (weekNum > cmpWeek) { return OFFSEASON_LABEL; } return WEEKLESS_LABEL; } }
EventHelper { public static String weekLabelFromNum(int year, @Nullable Integer weekNum) { if (weekNum == null) { return WEEKLESS_LABEL; } if (weekNum <= 0) { return PRESEASON_LABEL; } int cmpWeek = Utilities.getCmpWeek(year); if (year == 2016 && weekNum == 1) { return String.format(FLOAT_REGIONAL_LABEL, 0.5); } if (year == 2016 && weekNum > 1 && weekNum < cmpWeek) { weekNum--; } if (weekNum > 0 && weekNum < cmpWeek) { return String.format(REGIONAL_LABEL, weekNum); } if (weekNum == cmpWeek) { return CHAMPIONSHIP_LABEL; } if (weekNum > cmpWeek) { return OFFSEASON_LABEL; } return WEEKLESS_LABEL; } private  EventHelper(); }
EventHelper { public static String weekLabelFromNum(int year, @Nullable Integer weekNum) { if (weekNum == null) { return WEEKLESS_LABEL; } if (weekNum <= 0) { return PRESEASON_LABEL; } int cmpWeek = Utilities.getCmpWeek(year); if (year == 2016 && weekNum == 1) { return String.format(FLOAT_REGIONAL_LABEL, 0.5); } if (year == 2016 && weekNum > 1 && weekNum < cmpWeek) { weekNum--; } if (weekNum > 0 && weekNum < cmpWeek) { return String.format(REGIONAL_LABEL, weekNum); } if (weekNum == cmpWeek) { return CHAMPIONSHIP_LABEL; } if (weekNum > cmpWeek) { return OFFSEASON_LABEL; } return WEEKLESS_LABEL; } private  EventHelper(); static boolean validateEventKey(String key); static String shortName(String eventName); static int getYear(String eventKey); static int getYearWeek(Date date); static int competitionWeek(Date date); static String generateLabelForEvent(Event e); static String weekLabelFromNum(int year, @Nullable Integer weekNum); static int weekNumFromLabel(int year, String label); static void renderEventListForTeam(Context context,List<Event> events, List<Object> output); static void renderEventListForWeek(Context context, List<Event> events, List<Object> output); static void renderEventListForDistrict(
            Context context,
            List<Event> events,
            List<Object> output); static String getDateString(Date startDate, Date endDate); static String getShortCodeForEventKey(String eventKey); static String getEventCode(String matchOrEventOrDistrictKey); }
EventHelper { public static String weekLabelFromNum(int year, @Nullable Integer weekNum) { if (weekNum == null) { return WEEKLESS_LABEL; } if (weekNum <= 0) { return PRESEASON_LABEL; } int cmpWeek = Utilities.getCmpWeek(year); if (year == 2016 && weekNum == 1) { return String.format(FLOAT_REGIONAL_LABEL, 0.5); } if (year == 2016 && weekNum > 1 && weekNum < cmpWeek) { weekNum--; } if (weekNum > 0 && weekNum < cmpWeek) { return String.format(REGIONAL_LABEL, weekNum); } if (weekNum == cmpWeek) { return CHAMPIONSHIP_LABEL; } if (weekNum > cmpWeek) { return OFFSEASON_LABEL; } return WEEKLESS_LABEL; } private  EventHelper(); static boolean validateEventKey(String key); static String shortName(String eventName); static int getYear(String eventKey); static int getYearWeek(Date date); static int competitionWeek(Date date); static String generateLabelForEvent(Event e); static String weekLabelFromNum(int year, @Nullable Integer weekNum); static int weekNumFromLabel(int year, String label); static void renderEventListForTeam(Context context,List<Event> events, List<Object> output); static void renderEventListForWeek(Context context, List<Event> events, List<Object> output); static void renderEventListForDistrict(
            Context context,
            List<Event> events,
            List<Object> output); static String getDateString(Date startDate, Date endDate); static String getShortCodeForEventKey(String eventKey); static String getEventCode(String matchOrEventOrDistrictKey); static final String CHAMPIONSHIP_LABEL; static final String CITY_CHAMPIONSHIP_LABEL; static final String REGIONAL_LABEL; static final String FLOAT_REGIONAL_LABEL; static final String WEEKLESS_LABEL; static final String OFFSEASON_LABEL; static final String PRESEASON_LABEL; }