use of org.wordpress.android.ui.reader.views.ReaderWebView in project WordPress-Android by wordpress-mobile.
the class ReaderPostDetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.reader_fragment_post_detail, container, false);
CustomSwipeRefreshLayout swipeRefreshLayout = (CustomSwipeRefreshLayout) view.findViewById(R.id.swipe_to_refresh);
//this fragment hides/shows toolbar with scrolling, which messes up ptr animation position
//so we have to set it manually
int swipeToRefreshOffset = getResources().getDimensionPixelSize(R.dimen.toolbar_content_offset);
swipeRefreshLayout.setProgressViewOffset(false, 0, swipeToRefreshOffset);
mSwipeToRefreshHelper = new SwipeToRefreshHelper(getActivity(), swipeRefreshLayout, new SwipeToRefreshHelper.RefreshListener() {
@Override
public void onRefreshStarted() {
if (!isAdded()) {
return;
}
updatePost();
}
});
mScrollView = (WPScrollView) view.findViewById(R.id.scroll_view_reader);
mScrollView.setScrollDirectionListener(this);
mLayoutFooter = (ViewGroup) view.findViewById(R.id.layout_post_detail_footer);
mLikingUsersView = (ReaderLikingUsersView) view.findViewById(R.id.layout_liking_users_view);
mLikingUsersDivider = view.findViewById(R.id.layout_liking_users_divider);
mLikingUsersLabel = view.findViewById(R.id.text_liking_users_label);
// setup the ReaderWebView
mReaderWebView = (ReaderWebView) view.findViewById(R.id.reader_webview);
mReaderWebView.setCustomViewListener(this);
mReaderWebView.setUrlClickListener(this);
mReaderWebView.setPageFinishedListener(this);
// hide footer and scrollView until the post is loaded
mLayoutFooter.setVisibility(View.INVISIBLE);
mScrollView.setVisibility(View.INVISIBLE);
View relatedPostsContainer = view.findViewById(R.id.container_related_posts);
mGlobalRelatedPostsView = (ReaderSimplePostContainerView) relatedPostsContainer.findViewById(R.id.related_posts_view_global);
mLocalRelatedPostsView = (ReaderSimplePostContainerView) relatedPostsContainer.findViewById(R.id.related_posts_view_local);
mSignInButton = (WPTextView) view.findViewById(R.id.nux_sign_in_button);
mSignInButton.setOnClickListener(mSignInClickListener);
final ProgressBar progress = (ProgressBar) view.findViewById(R.id.progress_loading);
if (mPostSlugsResolutionUnderway) {
progress.setVisibility(View.VISIBLE);
}
showPost();
return view;
}
use of org.wordpress.android.ui.reader.views.ReaderWebView in project WordPress-Android by wordpress-mobile.
the class ReaderPostRenderer method renderHtmlContent.
/*
* called once the content is ready to be rendered in the webView
*/
private void renderHtmlContent(final String htmlContent) {
mRenderedHtml = htmlContent;
// make sure webView is still valid (containing fragment may have been detached)
ReaderWebView webView = mWeakWebView.get();
if (webView == null || webView.getContext() == null || webView.isDestroyed()) {
AppLog.w(AppLog.T.READER, "reader renderer > webView invalid");
return;
}
// IMPORTANT: use loadDataWithBaseURL() since loadData() may fail
// https://code.google.com/p/android/issues/detail?id=4401
// also important to use null as the baseUrl since onPageFinished
// doesn't appear to fire when it's set to an actual url
webView.loadDataWithBaseURL(null, htmlContent, "text/html", "UTF-8", null);
}
Aggregations