@Override public boolean onUrlClick(String url) { // if this is a "wordpress://blogpreview?" link, show blog preview for the blog - this is // used for Discover posts that highlight a blog if (ReaderUtils.isBlogPreviewUrl(url)) { long blogId = ReaderUtils.getBlogIdFromBlogPreviewUrl(url); if (blogId != 0) { ReaderActivityLauncher.showReaderBlogPreview(getActivity(), blogId); } return true; } // open YouTube videos in external app so they launch the YouTube player, open all other // urls using an AuthenticatedWebViewActivity final OpenUrlType openUrlType; if (ReaderVideoUtils.isYouTubeVideoLink(url)) { openUrlType = OpenUrlType.EXTERNAL; } else { openUrlType = OpenUrlType.INTERNAL; } ReaderActivityLauncher.openUrl(getActivity(), url, openUrlType); return true; }
@Override protected void onPostExecute(Boolean result) { mIsPostTaskRunning = false; if (!isAdded()) { return; } if (!result) { // post couldn't be loaded which means it doesn't exist in db, so request it from // the server if it hasn't already been requested if (!mHasAlreadyRequestedPost) { mHasAlreadyRequestedPost = true; AppLog.i(T.READER, "reader post detail > post not found, requesting it"); requestPost(); } return; } if (!canShowFooter()) { mLayoutFooter.setVisibility(View.GONE); } // add padding to the scrollView to make room for the top and bottom toolbars - this also // ensures the scrollbar matches the content so it doesn't disappear behind the toolbars int topPadding = (mAutoHideToolbarListener != null ? mToolbarHeight : 0); int bottomPadding = (canShowFooter() ? mLayoutFooter.getHeight() : 0); mScrollView.setPadding(0, topPadding, 0, bottomPadding); // scrollView was hidden in onCreateView, show it now that we have the post mScrollView.setVisibility(View.VISIBLE); // render the post in the webView mRenderer = new ReaderPostRenderer(mReaderWebView, mPost); mRenderer.beginRender(); txtTitle.setText( mPost.hasTitle() ? mPost.getTitle() : getString(R.string.reader_untitled_post)); followButton.setVisibility(mIsLoggedOutReader ? View.GONE : View.VISIBLE); if (!mIsLoggedOutReader) { followButton.setIsFollowed(mPost.isFollowedByCurrentUser); followButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { togglePostFollowed(); } }); } // clicking the header shows blog preview if (getPostListType() != ReaderPostListType.BLOG_PREVIEW) { layoutHeader.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { ReaderActivityLauncher.showReaderBlogPreview(v.getContext(), mPost); } }); } if (mPost.hasBlogName()) { txtBlogName.setText(mPost.getBlogName()); txtBlogName.setVisibility(View.VISIBLE); } else if (mPost.hasBlogUrl()) { txtBlogName.setText(UrlUtils.getDomainFromUrl(mPost.getBlogUrl())); txtBlogName.setVisibility(View.VISIBLE); } else { txtBlogName.setVisibility(View.GONE); } int avatarSz = getResources().getDimensionPixelSize(R.dimen.avatar_sz_medium); if (mPost.hasBlogUrl()) { String imageUrl = GravatarUtils.blavatarFromUrl(mPost.getBlogUrl(), avatarSz); imgAvatar.setImageUrl(imageUrl, WPNetworkImageView.ImageType.BLAVATAR); } else { imgAvatar.setImageUrl( mPost.getPostAvatarForDisplay(avatarSz), WPNetworkImageView.ImageType.AVATAR); } if (mPost.hasAuthorName()) { txtAuthor.setText(mPost.getAuthorName()); txtAuthor.setVisibility(View.VISIBLE); } else { txtAuthor.setVisibility(View.GONE); } String dateLine; if (mPost.hasBlogUrl()) { dateLine = UrlUtils.getDomainFromUrl(mPost.getBlogUrl()) + " \u2022 " + DateTimeUtils.javaDateToTimeSpan(mPost.getDatePublished()); } else { dateLine = DateTimeUtils.javaDateToTimeSpan(mPost.getDatePublished()); } txtDateLine.setText(dateLine); final String tagToDisplay = mPost.getTagForDisplay(null); if (!TextUtils.isEmpty(tagToDisplay)) { txtTag.setText(ReaderUtils.makeHashTag(tagToDisplay)); txtTag.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { ReaderTag tag = new ReaderTag(tagToDisplay, ReaderTagType.FOLLOWED); ReaderActivityLauncher.showReaderTagPreview(v.getContext(), tag); } }); } if (canShowFooter() && mLayoutFooter.getVisibility() != View.VISIBLE) { AniUtils.fadeIn(mLayoutFooter, AniUtils.Duration.LONG); } refreshIconCounts(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mIsLoggedOutReader = ReaderUtils.isLoggedOutReader(); }