示例#1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView =
        (ViewGroup) inflater.inflate(R.layout.submission_albumcard, container, false);

    TextView title = (TextView) rootView.findViewById(R.id.title);
    TextView desc = (TextView) rootView.findViewById(R.id.desc);

    title.setText(s.getTitle());
    desc.setText(
        s.getAuthor() + " " + TimeUtils.getTimeAgo(s.getCreated().getTime(), getContext()));
    ContentType.ImageType type = ContentType.getImageType(s);

    String url = "";

    if (s.getUrl().contains("gallery")) {
      gallery = true;
    }

    list = rootView.findViewById(R.id.images);

    list.setVisibility(View.VISIBLE);
    String rawDat = cutEnds(s.getUrl());
    String rawdat2 = rawDat;
    if (rawdat2.substring(rawDat.lastIndexOf("/"), rawdat2.length()).length() < 4) {
      rawDat = rawDat.replace(rawDat.substring(rawDat.lastIndexOf("/"), rawdat2.length()), "");
    }
    if (!rawDat.isEmpty()) {

      new AsyncImageLoaderAlbum().execute(getHash(rawDat));
    }

    rootView
        .findViewById(R.id.base)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                if (Reddit.tabletUI
                    && getActivity().getResources().getConfiguration().orientation
                        == Configuration.ORIENTATION_LANDSCAPE) {
                  Intent i2 = new Intent(getActivity(), CommentsScreenPopup.class);
                  i2.putExtra("page", i);
                  (getActivity()).startActivity(i2);

                } else {
                  Intent i2 = new Intent(getActivity(), CommentsScreen.class);
                  i2.putExtra("page", i);
                  (getActivity()).startActivity(i2);
                }
              }
            });
    return rootView;
  }
示例#2
0
  public static boolean doesMatch(Submission s, String baseSubreddit, boolean ignore18) {
    String title = s.getTitle();
    String body = s.getSelftext();
    String domain = s.getUrl();
    String subreddit = s.getSubredditName();
    String flair = s.getSubmissionFlair().getText() != null ? s.getSubmissionFlair().getText() : "";

    boolean titlec;
    boolean bodyc;
    boolean domainc;
    boolean subredditc;
    boolean userc;

    if (titles == null) {
      titles = SettingValues.titleFilters.replaceAll("^[,\\s]+", "").split("[,\\s]+");
    }
    if (texts == null) {
      texts = SettingValues.textFilters.replaceAll("^[,\\s]+", "").split("[,\\s]+");
    }
    if (domains == null) {
      domains = SettingValues.domainFilters.replaceAll("^[,\\s]+", "").split("[,\\s]+");
    }
    if (subreddits == null) {
      subreddits = SettingValues.subredditFilters.replaceAll("^[,\\s]+", "").split("[,\\s]+");
    }
    if (flairs == null) {
      flairs = SettingValues.flairFilters.replaceAll("^[,]+", "").split("[,]+");
    }
    if (users == null) {
      users = SettingValues.userFilters.replaceAll("^[,\\s]+", "").split("[,\\s]+");
    }

    titlec = !SettingValues.titleFilters.isEmpty() && contains(title.toLowerCase(), titles, false);

    bodyc = !SettingValues.textFilters.isEmpty() && contains(body.toLowerCase(), texts, false);

    userc =
        !SettingValues.userFilters.isEmpty() && contains(s.getAuthor().toLowerCase(), users, false);

    try {
      domainc = !SettingValues.domainFilters.isEmpty() && isDomain(domain.toLowerCase(), domains);
    } catch (MalformedURLException e) {
      domainc = false;
    }

    subredditc =
        !subreddit.equalsIgnoreCase(baseSubreddit)
            && !SettingValues.subredditFilters.isEmpty()
            && contains(subreddit.toLowerCase(), subreddits, true);

    boolean contentMatch = false;

    if (baseSubreddit == null || baseSubreddit.isEmpty()) {
      baseSubreddit = "frontpage";
    }

    baseSubreddit = baseSubreddit.toLowerCase();
    boolean gifs = isGif(baseSubreddit);
    boolean images = isImage(baseSubreddit);
    boolean nsfw = isNsfw(baseSubreddit);
    boolean albums = isAlbums(baseSubreddit);
    boolean urls = isUrls(baseSubreddit);
    boolean selftext = isSelftext(baseSubreddit);
    boolean videos = isVideo(baseSubreddit);

    if (s.isNsfw()) {
      if (nsfw) {
        contentMatch = true;
      }
      if (!Reddit.over18 && !ignore18) {
        contentMatch = true;
      }
    }
    switch (ContentType.getContentType(s)) {
      case REDDIT:
      case EMBEDDED:
      case LINK:
        if (urls) {
          contentMatch = true;
        }
        break;
      case SELF:
      case NONE:
        if (selftext) {
          contentMatch = true;
        }
        break;
      case ALBUM:
        if (albums) {
          contentMatch = true;
        }
        break;
      case IMAGE:
      case DEVIANTART:
      case IMGUR:
      case XKCD:
        if (images) {
          contentMatch = true;
        }
        break;
      case GIF:
        if (gifs) {
          contentMatch = true;
        }
        break;
      case VID_ME:
      case STREAMABLE:
      case VIDEO:
        if (videos) {
          contentMatch = true;
        }
        break;
    }

    if (!flair.isEmpty())
      for (String flairText : flairs) {
        if (flairText.toLowerCase().startsWith(baseSubreddit)) {
          String[] split = flairText.split(":");
          if (split[0].equalsIgnoreCase(baseSubreddit)) {
            if (flair.equalsIgnoreCase(split[1].trim())) {
              contentMatch = true;
              break;
            }
          }
        }
      }

    return (titlec
        || bodyc
        || userc
        || domainc
        || subredditc
        || contentMatch
        || Hidden.id.contains(s.getFullName()));
  }