Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = (ViewGroup) inflater.inflate(R.layout.submission_imagecard, container, false);
    image = (SubsamplingScaleImageView) rootView.findViewById(R.id.image);

    PopulateShadowboxInfo.doActionbar(s, rootView, getActivity());

    (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);

    type = ContentType.getImageType(s);

    if (type.toString().toLowerCase().contains("image")
        && type != ContentType.ImageType.IMAGE_LINK) {
      addClickFunctions(image, rootView, type, getActivity(), s);
      loadImage(s.getUrl());
    } else if (s.getDataNode().has("preview")
        && s.getDataNode().get("preview").get("images").get(0).get("source").has("height")
        && s.getDataNode().get("preview").get("images").get(0).get("source").get("height").asInt()
            > 200) {
      loadImage(
          s.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText());
    } else {
      image.recycle();
      (rootView.findViewById(R.id.thumbimage2)).setVisibility(View.VISIBLE);
      ((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource(R.drawable.web);
      addClickFunctions(
          (rootView.findViewById(R.id.thumbimage2)), rootView, type, getActivity(), s);

      (rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
    }

    rootView
        .findViewById(R.id.base)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {

                Intent i2 = new Intent(getActivity(), CommentsScreen.class);
                i2.putExtra(CommentsScreen.EXTRA_PAGE, i);
                i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, sub);
                (getActivity()).startActivity(i2);
              }
            });
    return rootView;
  }
Ejemplo n.º 3
0
    @Override
    public Fragment getItem(int i) {

      Fragment f;
      ContentType.ImageType t = ContentType.getImageType(subredditPosts.getPosts().get(i));

      if (subredditPosts.getPosts().size() - 2 <= i && subredditPosts.hasMore()) {
        subredditPosts.loadMore(Shadowbox.this.getApplicationContext(), Shadowbox.this, false);
      }
      switch (t) {
        case NSFW_IMAGE:
        case NSFW_GIF:
        case NSFW_GFY:
        case GFY:
        case GIF:
        case IMAGE:
        case NONE_GFY:
        case NONE_GIF:
        case NONE_IMAGE:
          {
            f = new MediaFragment();
            Bundle args = new Bundle();
            Submission submission = OfflineSubreddit.getSubreddit(subreddit).submissions.get(i);
            String previewUrl = "";
            if (submission.getDataNode().has("preview")
                && submission
                    .getDataNode()
                    .get("preview")
                    .get("images")
                    .get(0)
                    .get("source")
                    .has("height")) { // Load the preview image which has probably already been
              // cached in memory instead of the direct link
              previewUrl =
                  submission
                      .getDataNode()
                      .get("preview")
                      .get("images")
                      .get(0)
                      .get("source")
                      .get("url")
                      .asText();
            }
            args.putString("contentUrl", submission.getUrl());
            args.putString("firstUrl", previewUrl);
            args.putInt("page", i);
            args.putString("sub", subreddit);
            f.setArguments(args);
          }
          break;
        case REDDIT:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case EMBEDDED:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case LINK:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case IMAGE_LINK:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case NSFW_LINK:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case SELF:
          {
            if (subredditPosts.getPosts().get(i).getSelftext().isEmpty()) {
              f = new TitleFull();
              Bundle args = new Bundle();
              args.putInt("page", i);
              args.putString("sub", subreddit);

              f.setArguments(args);
            } else {
              f = new SelftextFull();
              Bundle args = new Bundle();
              args.putInt("page", i);
              args.putString("sub", subreddit);

              f.setArguments(args);
            }
          }
          break;
        case ALBUM:
          {
            f = new AlbumFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case VID_ME:
        case STREAMABLE:
          {
            f = new Gif();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case NONE:
          {
            if (subredditPosts.getPosts().get(i).getSelftext().isEmpty()) {
              f = new TitleFull();
              Bundle args = new Bundle();
              args.putInt("page", i);
              args.putString("sub", subreddit);

              f.setArguments(args);
            } else {
              f = new SelftextFull();
              Bundle args = new Bundle();
              args.putInt("page", i);
              args.putString("sub", subreddit);

              f.setArguments(args);
            }
          }
          break;
        case VIDEO:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        case NONE_URL:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
        default:
          {
            f = new ImageFull();
            Bundle args = new Bundle();
            args.putInt("page", i);
            args.putString("sub", subreddit);

            f.setArguments(args);
          }
          break;
      }

      return f;
    }
Ejemplo n.º 4
0
    /**
     * @param url the url link (e.g. #s for some spoilers)
     * @param xOffset the last index of the url text (not the link)
     */
    public void onLinkClick(String url, int xOffset) {
      if (url == null) {
        return;
      }

      ContentType.ImageType type = ContentType.getImageType(url);
      switch (type) {
        case IMGUR:
          Intent intent2 = new Intent(c, Imgur.class);
          intent2.putExtra(Imgur.EXTRA_URL, url);
          c.startActivity(intent2);
          break;
        case NSFW_IMAGE:
          openImage(c, url);
          break;
        case NSFW_GIF:
          openGif(false, c, url);
          break;
        case NSFW_GFY:
          openGif(true, c, url);
          break;
        case REDDIT:
          new OpenRedditLink(c, url);
          break;
        case LINK:
        case IMAGE_LINK:
        case NSFW_LINK:
          CustomTabUtil.openUrl(url, Palette.getColor(subreddit), c);
          break;
        case SELF:
          break;

        case GFY:
          openGif(true, c, url);
          break;
        case ALBUM:
          if (SettingValues.album) {
            Intent i = new Intent(c, Album.class);
            i.putExtra(Album.EXTRA_URL, url);
            c.startActivity(i);
          } else {
            Reddit.defaultShare(url, c);
          }
          break;
        case IMAGE:
          openImage(c, url);
          break;
        case GIF:
          openGif(false, c, url);
          break;
        case NONE_GFY:
          openGif(true, c, url);
          break;
        case NONE_GIF:
          openGif(false, c, url);
          break;
        case NONE:
          break;
        case NONE_IMAGE:
          openImage(c, url);
          break;
        case NONE_URL:
          CustomTabUtil.openUrl(url, Palette.getColor(subreddit), c);
          break;
        case VIDEO:
          if (SettingValues.video) {
            Intent intent = new Intent(c, FullscreenVideo.class);
            intent.putExtra(FullscreenVideo.EXTRA_HTML, url);
            c.startActivity(intent);
          } else {
            Reddit.defaultShare(url, c);
          }
        case SPOILER:
          comm.spoilerClicked = true;

          setOrRemoveSpoilerSpans(comm, (Spannable) sequence, xOffset);
          break;
      }
    }
Ejemplo n.º 5
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView =
        (ViewGroup) inflater.inflate(R.layout.submission_imagecard, container, false);

    final SubsamplingScaleImageView image =
        (SubsamplingScaleImageView) rootView.findViewById(R.id.image);
    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.getCreatedUtc().getTime()));
    ContentType.ImageType type = ContentType.getImageType(s);

    String url;

    if (type.toString().toLowerCase().contains("image")) {
      addClickFunctions(image, rootView, type, getActivity(), s);

      url = ContentType.getFixedUrl(s.getUrl());
      ((Reddit) getContext().getApplicationContext())
          .getImageLoader()
          .loadImage(
              url,
              new SimpleImageLoadingListener() {

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                  image.setImage(ImageSource.bitmap(loadedImage));
                }
              });
    } else if (s.getDataNode().has("preview")
        && s.getDataNode().get("preview").get("images").get(0).get("source").has("height")
        && s.getDataNode().get("preview").get("images").get(0).get("source").get("height").asInt()
            > 200) {

      url = s.getDataNode().get("preview").get("images").get(0).get("source").get("url").asText();
      ((Reddit) getContext().getApplicationContext())
          .getImageLoader()
          .loadImage(
              url,
              new SimpleImageLoadingListener() {

                @Override
                public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                  image.setImage(ImageSource.bitmap(loadedImage));
                }
              });

    } else {
      addClickFunctions(image, rootView, type, getActivity(), s);
      Log.v("Slide", "NO IMAGE");
      image.recycle();
    }

    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;
  }