@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; }
@Override public void updateOffline(List<Submission> submissions, final long cacheTime) { if (getActivity() instanceof MainActivity) { if (((MainActivity) getActivity()).runAfterLoad != null) { new Handler().post(((MainActivity) getActivity()).runAfterLoad); } } if (this.isAdded()) { if (mSwipeRefreshLayout != null) { mSwipeRefreshLayout.setRefreshing(false); Toast.makeText( mSwipeRefreshLayout.getContext(), getString( R.string.offline_last_update, TimeUtils.getTimeAgo(cacheTime, mSwipeRefreshLayout.getContext())), Toast.LENGTH_SHORT) .show(); } adapter.notifyDataSetChanged(); } }
@Override public void onBindViewHolder(final RecyclerView.ViewHolder firstHolder, final int i) { if (firstHolder instanceof SubmissionViewHolder) { SubmissionViewHolder holder = (SubmissionViewHolder) firstHolder; final Submission submission = (Submission) dataSet.get(i); holder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { /*TODO Single comment screen Intent i2 = new Intent(mContext, CommentsScreen.class); DataShare.sharedSubreddit = dataSet; i2.putExtra("page", i); ((Activity) mContext).startActivityForResult(i2, 2); */ } }); new PopulateSubmissionViewHolder() .PopulateSubmissionViewHolder(holder, submission, mContext, false, false); holder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new OpenRedditLink(mContext, "www.reddit.com" + submission.getPermalink()); } }); lastPosition = i; } else { // IS COMMENT ProfileCommentViewHolder holder = (ProfileCommentViewHolder) firstHolder; final Comment comment = (Comment) dataSet.get(i); holder.score.setText(comment.getScore() + ""); holder.time.setText(TimeUtils.getTimeAgo(comment.getCreatedUtc().getTime())); new MakeTextviewClickable() .ParseTextWithLinksTextViewComment( comment.getDataNode().get("body_html").asText(), holder.content, (Activity) mContext, comment.getSubredditName()); if (comment.getTimesGilded() > 0) { holder.gild.setVisibility(View.VISIBLE); } else { holder.gild.setVisibility(View.GONE); } holder.title.setText(comment.getSubmissionTitle()); holder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new OpenRedditLink( mContext, comment.getSubmissionId(), comment.getSubredditName(), comment.getId()); } }); holder.content.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new OpenRedditLink( mContext, comment.getSubmissionId(), comment.getSubredditName(), comment.getId()); } }); } return; }
@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; }