@Test public void teamIntent_invalidTeamNumber() { Uri uri = Uri.parse("http: Intent intent = Utilities.getIntentForTBAUrl(context, uri); assertNull(intent); }
public static Intent getIntentForTBAUrl(Context c, Uri data) { TbaLogger.d("Uri: " + data.toString()); List<String> urlParts = data.getPathSegments(); String tbaHostPattern = "(.*\\.?)thebluealliance.com"; Pattern pattern = Pattern.compile(tbaHostPattern); if (!pattern.matcher(data.getHost()).matches()) { return null; } Intent intent = null; if (urlParts != null) { if (urlParts.isEmpty()) { return HomeActivity.newInstance(c, R.id.nav_item_events); } System.out.println(urlParts.get(0)); switch (urlParts.get(0)) { case "teams": intent = HomeActivity.newInstance(c, R.id.nav_item_teams); break; case "team": if (indexExists(urlParts, 1) && TeamHelper.validateTeamKey("frc" + urlParts.get(1))) { String teamNumber = urlParts.get(1).replaceFirst("^0+", ""); if (indexExists(urlParts, 2) && urlParts.get(2).matches("\\d\\d\\d\\d")) { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber, Integer.parseInt(urlParts.get(2))); } else { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber); } } break; case "": case "events": intent = HomeActivity.newInstance(c, R.id.nav_item_events); break; case "event": if (indexExists(urlParts, 1) && EventHelper.validateEventKey(urlParts.get(1))) { intent = ViewEventActivity.newInstance(c, urlParts.get(1)); } break; case "match": if (indexExists(urlParts, 1) && MatchHelper.validateMatchKey(urlParts.get(1))) { intent = ViewMatchActivity.newInstance(c, urlParts.get(1)); } break; case "gameday": intent = HomeActivity.newInstance(c, R.id.nav_item_gameday); break; default: intent = null; } } return intent; }
Utilities { public static Intent getIntentForTBAUrl(Context c, Uri data) { TbaLogger.d("Uri: " + data.toString()); List<String> urlParts = data.getPathSegments(); String tbaHostPattern = "(.*\\.?)thebluealliance.com"; Pattern pattern = Pattern.compile(tbaHostPattern); if (!pattern.matcher(data.getHost()).matches()) { return null; } Intent intent = null; if (urlParts != null) { if (urlParts.isEmpty()) { return HomeActivity.newInstance(c, R.id.nav_item_events); } System.out.println(urlParts.get(0)); switch (urlParts.get(0)) { case "teams": intent = HomeActivity.newInstance(c, R.id.nav_item_teams); break; case "team": if (indexExists(urlParts, 1) && TeamHelper.validateTeamKey("frc" + urlParts.get(1))) { String teamNumber = urlParts.get(1).replaceFirst("^0+", ""); if (indexExists(urlParts, 2) && urlParts.get(2).matches("\\d\\d\\d\\d")) { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber, Integer.parseInt(urlParts.get(2))); } else { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber); } } break; case "": case "events": intent = HomeActivity.newInstance(c, R.id.nav_item_events); break; case "event": if (indexExists(urlParts, 1) && EventHelper.validateEventKey(urlParts.get(1))) { intent = ViewEventActivity.newInstance(c, urlParts.get(1)); } break; case "match": if (indexExists(urlParts, 1) && MatchHelper.validateMatchKey(urlParts.get(1))) { intent = ViewMatchActivity.newInstance(c, urlParts.get(1)); } break; case "gameday": intent = HomeActivity.newInstance(c, R.id.nav_item_gameday); break; default: intent = null; } } return intent; } }
Utilities { public static Intent getIntentForTBAUrl(Context c, Uri data) { TbaLogger.d("Uri: " + data.toString()); List<String> urlParts = data.getPathSegments(); String tbaHostPattern = "(.*\\.?)thebluealliance.com"; Pattern pattern = Pattern.compile(tbaHostPattern); if (!pattern.matcher(data.getHost()).matches()) { return null; } Intent intent = null; if (urlParts != null) { if (urlParts.isEmpty()) { return HomeActivity.newInstance(c, R.id.nav_item_events); } System.out.println(urlParts.get(0)); switch (urlParts.get(0)) { case "teams": intent = HomeActivity.newInstance(c, R.id.nav_item_teams); break; case "team": if (indexExists(urlParts, 1) && TeamHelper.validateTeamKey("frc" + urlParts.get(1))) { String teamNumber = urlParts.get(1).replaceFirst("^0+", ""); if (indexExists(urlParts, 2) && urlParts.get(2).matches("\\d\\d\\d\\d")) { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber, Integer.parseInt(urlParts.get(2))); } else { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber); } } break; case "": case "events": intent = HomeActivity.newInstance(c, R.id.nav_item_events); break; case "event": if (indexExists(urlParts, 1) && EventHelper.validateEventKey(urlParts.get(1))) { intent = ViewEventActivity.newInstance(c, urlParts.get(1)); } break; case "match": if (indexExists(urlParts, 1) && MatchHelper.validateMatchKey(urlParts.get(1))) { intent = ViewMatchActivity.newInstance(c, urlParts.get(1)); } break; case "gameday": intent = HomeActivity.newInstance(c, R.id.nav_item_gameday); break; default: intent = null; } } return intent; } private  Utilities(); }
Utilities { public static Intent getIntentForTBAUrl(Context c, Uri data) { TbaLogger.d("Uri: " + data.toString()); List<String> urlParts = data.getPathSegments(); String tbaHostPattern = "(.*\\.?)thebluealliance.com"; Pattern pattern = Pattern.compile(tbaHostPattern); if (!pattern.matcher(data.getHost()).matches()) { return null; } Intent intent = null; if (urlParts != null) { if (urlParts.isEmpty()) { return HomeActivity.newInstance(c, R.id.nav_item_events); } System.out.println(urlParts.get(0)); switch (urlParts.get(0)) { case "teams": intent = HomeActivity.newInstance(c, R.id.nav_item_teams); break; case "team": if (indexExists(urlParts, 1) && TeamHelper.validateTeamKey("frc" + urlParts.get(1))) { String teamNumber = urlParts.get(1).replaceFirst("^0+", ""); if (indexExists(urlParts, 2) && urlParts.get(2).matches("\\d\\d\\d\\d")) { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber, Integer.parseInt(urlParts.get(2))); } else { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber); } } break; case "": case "events": intent = HomeActivity.newInstance(c, R.id.nav_item_events); break; case "event": if (indexExists(urlParts, 1) && EventHelper.validateEventKey(urlParts.get(1))) { intent = ViewEventActivity.newInstance(c, urlParts.get(1)); } break; case "match": if (indexExists(urlParts, 1) && MatchHelper.validateMatchKey(urlParts.get(1))) { intent = ViewMatchActivity.newInstance(c, urlParts.get(1)); } break; case "gameday": intent = HomeActivity.newInstance(c, R.id.nav_item_gameday); break; default: intent = null; } } return intent; } private  Utilities(); static int getPixelsFromDp(Context c, int dipValue); static String exceptionStacktraceToString(Exception e); static int getFirstCompWeek(Date date); static int getFirstCompWeek(int year); static int getCmpWeek(int year); static String getAsciiApproximationOfUnicode(String input); static String getPreparedQueryForSearch(String query); static Intent getIntentForTBAUrl(Context c, Uri data); static boolean indexExists(List<String> data, int index); static int getCurrentYear(); static int getCurrentCompWeek(); static String getOrdinalFor(int value); static void showHelpDialog(Context c, @RawRes int rawText, String dialogTitle); static boolean isInteger(String s); static boolean isDebuggable(); static String getUUID(); static String stringifyListOfStrings(Context context, List<String> strings); static CharSequence boldNameList(Iterable<? extends CharSequence> names,
                                            Predicate<String> beBold); static String sha256(String input); static boolean hasKApis(); static boolean hasLApis(); static boolean hasMApis(); static String getDeviceUUID(Context context); static String getBuildTimestamp(Context c); static String getVersionNumber(); static Map<K, V> getMapForPlatform(Class<K> key, Class<V> value); static void setLightStatusBar(Window window, boolean lightBackground); static int getCurrentDarkModePreference(String prefValue); }
Utilities { public static Intent getIntentForTBAUrl(Context c, Uri data) { TbaLogger.d("Uri: " + data.toString()); List<String> urlParts = data.getPathSegments(); String tbaHostPattern = "(.*\\.?)thebluealliance.com"; Pattern pattern = Pattern.compile(tbaHostPattern); if (!pattern.matcher(data.getHost()).matches()) { return null; } Intent intent = null; if (urlParts != null) { if (urlParts.isEmpty()) { return HomeActivity.newInstance(c, R.id.nav_item_events); } System.out.println(urlParts.get(0)); switch (urlParts.get(0)) { case "teams": intent = HomeActivity.newInstance(c, R.id.nav_item_teams); break; case "team": if (indexExists(urlParts, 1) && TeamHelper.validateTeamKey("frc" + urlParts.get(1))) { String teamNumber = urlParts.get(1).replaceFirst("^0+", ""); if (indexExists(urlParts, 2) && urlParts.get(2).matches("\\d\\d\\d\\d")) { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber, Integer.parseInt(urlParts.get(2))); } else { intent = ViewTeamActivity.newInstance(c, "frc" + teamNumber); } } break; case "": case "events": intent = HomeActivity.newInstance(c, R.id.nav_item_events); break; case "event": if (indexExists(urlParts, 1) && EventHelper.validateEventKey(urlParts.get(1))) { intent = ViewEventActivity.newInstance(c, urlParts.get(1)); } break; case "match": if (indexExists(urlParts, 1) && MatchHelper.validateMatchKey(urlParts.get(1))) { intent = ViewMatchActivity.newInstance(c, urlParts.get(1)); } break; case "gameday": intent = HomeActivity.newInstance(c, R.id.nav_item_gameday); break; default: intent = null; } } return intent; } private  Utilities(); static int getPixelsFromDp(Context c, int dipValue); static String exceptionStacktraceToString(Exception e); static int getFirstCompWeek(Date date); static int getFirstCompWeek(int year); static int getCmpWeek(int year); static String getAsciiApproximationOfUnicode(String input); static String getPreparedQueryForSearch(String query); static Intent getIntentForTBAUrl(Context c, Uri data); static boolean indexExists(List<String> data, int index); static int getCurrentYear(); static int getCurrentCompWeek(); static String getOrdinalFor(int value); static void showHelpDialog(Context c, @RawRes int rawText, String dialogTitle); static boolean isInteger(String s); static boolean isDebuggable(); static String getUUID(); static String stringifyListOfStrings(Context context, List<String> strings); static CharSequence boldNameList(Iterable<? extends CharSequence> names,
                                            Predicate<String> beBold); static String sha256(String input); static boolean hasKApis(); static boolean hasLApis(); static boolean hasMApis(); static String getDeviceUUID(Context context); static String getBuildTimestamp(Context c); static String getVersionNumber(); static Map<K, V> getMapForPlatform(Class<K> key, Class<V> value); static void setLightStatusBar(Window window, boolean lightBackground); static int getCurrentDarkModePreference(String prefValue);  }