Ejemplo n.º 1
0
 private static void openImage(Activity contextActivity, String submission) {
   if (SettingValues.image) {
     Intent myIntent = new Intent(contextActivity, FullscreenImage.class);
     myIntent.putExtra(FullscreenImage.EXTRA_URL, submission);
     contextActivity.startActivity(myIntent);
   } else {
     Reddit.defaultShare(submission, contextActivity);
   }
 }
Ejemplo n.º 2
0
 private static void openGif(final boolean gfy, Activity contextActivity, String submission) {
   if (SettingValues.gif) {
     Intent myIntent = new Intent(contextActivity, GifView.class);
     if (gfy) {
       myIntent.putExtra(GifView.EXTRA_URL, "gfy" + submission);
     } else {
       myIntent.putExtra(GifView.EXTRA_URL, "" + submission);
     }
     contextActivity.startActivity(myIntent);
     contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
   } else {
     Reddit.defaultShare(submission, contextActivity);
   }
 }
Ejemplo n.º 3
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.º 4
0
  private static void addClickFunctions(
      final View base,
      final View clickingArea,
      ContentType.ImageType type,
      final Activity contextActivity,
      final Submission submission) {
    if (!PostMatch.openExternal(submission.getUrl())) {

      switch (type) {
        case NSFW_IMAGE:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openImage(contextActivity, submission);
                }
              });
          break;
        case VID_ME:
        case STREAMABLE:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  if (SettingValues.video) {
                    Intent myIntent = new Intent(contextActivity, GifView.class);

                    myIntent.putExtra(GifView.EXTRA_STREAMABLE, submission.getUrl());
                    contextActivity.startActivity(myIntent);

                  } else {
                    Reddit.defaultShare(submission.getUrl(), contextActivity);
                  }
                }
              });
        case EMBEDDED:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  if (SettingValues.video) {
                    Reddit.defaultShare(submission.getUrl(), contextActivity);
                    String data =
                        submission.getDataNode().get("media_embed").get("content").asText();
                    {
                      Intent i = new Intent(contextActivity, FullscreenVideo.class);
                      i.putExtra(FullscreenVideo.EXTRA_HTML, data);
                      contextActivity.startActivity(i);
                    }
                  } else {
                    Reddit.defaultShare(submission.getUrl(), contextActivity);
                  }
                }
              });
          break;
        case NSFW_GIF:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openGif(false, contextActivity, submission);
                }
              });
          break;
        case NSFW_GFY:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openGif(true, contextActivity, submission);
                }
              });
          break;
        case REDDIT:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openRedditContent(
                      submission.getUrl(), contextActivity);
                }
              });
          break;
        case LINK:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  CustomTabUtil.openUrl(
                      submission.getUrl(),
                      Palette.getColor(submission.getSubredditName()),
                      contextActivity);
                }
              });
          break;
        case IMAGE_LINK:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  CustomTabUtil.openUrl(
                      submission.getUrl(),
                      Palette.getColor(submission.getSubredditName()),
                      contextActivity);
                }
              });
          break;
        case NSFW_LINK:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  CustomTabUtil.openUrl(
                      submission.getUrl(),
                      Palette.getColor(submission.getSubredditName()),
                      contextActivity);
                }
              });
          break;
        case SELF:
          break;
        case GFY:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openGif(true, contextActivity, submission);
                }
              });
          break;
        case ALBUM:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {

                  if (SettingValues.album) {
                    if (SettingValues.albumSwipe) {
                      Intent i = new Intent(contextActivity, AlbumPager.class);
                      i.putExtra(Album.EXTRA_URL, submission.getUrl());
                      contextActivity.startActivity(i);
                      contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
                    } else {
                      Intent i = new Intent(contextActivity, Album.class);
                      i.putExtra(Album.EXTRA_URL, submission.getUrl());
                      contextActivity.startActivity(i);
                      contextActivity.overridePendingTransition(R.anim.slideright, R.anim.fade_out);
                    }

                  } else {
                    Reddit.defaultShare(submission.getUrl(), contextActivity);
                  }
                }
              });
          break;
        case DEVIANTART:
        case IMAGE:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openImage(contextActivity, submission);
                }
              });
          break;
        case GIF:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openGif(false, contextActivity, submission);
                }
              });
          break;
        case NONE_GFY:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openGif(true, contextActivity, submission);
                }
              });
          break;
        case NONE_GIF:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openGif(false, contextActivity, submission);
                }
              });
          break;

        case NONE:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  CustomTabUtil.openUrl(
                      submission.getUrl(),
                      Palette.getColor(submission.getSubredditName()),
                      contextActivity);
                }
              });
          break;
        case NONE_IMAGE:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v2) {
                  PopulateSubmissionViewHolder.openImage(contextActivity, submission);
                }
              });
          break;
        case NONE_URL:
          base.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v2) {
                  CustomTabUtil.openUrl(
                      submission.getUrl(),
                      Palette.getColor(submission.getSubredditName()),
                      contextActivity);
                }
              });
          break;
        case VIDEO:
          base.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                  Reddit.defaultShare(submission.getUrl(), contextActivity);
                }
              });
      }
    } else {
      Reddit.defaultShare(submission.getUrl(), contextActivity);
    }
  }