Пример #1
0
    @Override
    public String humanReadableName(Context context, boolean shorter) {

      switch (type) {
        case FRONTPAGE:
          return context.getString(R.string.mainmenu_frontpage);

        case ALL:
          return context.getString(R.string.mainmenu_all);

        case SUBREDDIT:
          try {
            return RedditSubreddit.getCanonicalName(subreddit);
          } catch (RedditSubreddit.InvalidSubredditNameException e) {
            return subreddit;
          }

        case SUBREDDIT_COMBINATION:
        case ALL_SUBTRACTION:
          return subreddit;

        default:
          return super.humanReadableName(context, shorter);
      }
    }
Пример #2
0
    public static RedditURL getSubreddit(String subreddit)
        throws RedditSubreddit.InvalidSubredditNameException {

      Uri.Builder builder = new Uri.Builder();
      builder.scheme(Constants.Reddit.getScheme()).authority(Constants.Reddit.getDomain());

      builder.encodedPath("/r/");
      builder.appendPath(RedditSubreddit.stripRPrefix(subreddit));

      return RedditURLParser.parse(builder.build());
    }