Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }