List of usage examples for android.webkit WebView getContentHeight
@ViewDebug.ExportedProperty(category = "webview") public int getContentHeight()
From source file:cn.bingoogolapple.refreshlayout.util.BGARefreshScrollingUtil.java
public static boolean isWebViewToBottom(WebView webView) { return webView != null && webView.getContentHeight() * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight()); }
From source file:com.lanma.customviewproject.utils.ScrollingUtil.java
/** * webView?/*from w ww .java 2 s .co m*/ */ public static boolean isWebViewToBottom(WebView webView) { return webView != null && webView.getContentHeight() * webView.getScale() == (webView.getScrollY() + webView.getMeasuredHeight()); }
From source file:com.ranger.xyg.library.tkrefreshlayout.utils.ScrollingUtil.java
public static boolean isWebViewToBottom(WebView webview, int mTouchSlop) { return webview != null && ((webview.getContentHeight() * webview.getScale() - (webview.getHeight() + webview.getScrollY())) <= 2 * mTouchSlop); }
From source file:com.recyclerviewpulldownrefresh.view.refresh.AbPullToRefreshView.java
/** * ??//from ww w.j a v a2 s .c om * * @return */ public boolean canChildScrollDown() { if (!mEnableLoadMore) { return false; } if (mTarget instanceof AdapterView<?>) { AdapterView<?> absListView = (AdapterView<?>) mTarget; View lastChild = absListView.getChildAt(absListView.getChildCount() - 1); if (lastChild == null) { return true; } // ??viewBottom?ViewmAdapterView?view, // ViewmAdapterView?? if (lastChild.getBottom() <= getHeight() && absListView.getLastVisiblePosition() == absListView.getCount() - 1) { return true; } } else if (mTarget instanceof WebView) { WebView webview = (WebView) mTarget; return webview.getContentHeight() * webview.getScale() <= webview.getHeight() + webview.getScrollY(); } else if (mTarget instanceof ScrollView) { ScrollView scrollView = (ScrollView) mTarget; View childView = scrollView.getChildAt(0); if (childView != null) { return childView.getMeasuredHeight() <= getHeight() + mScrollView.getScrollY(); } } else if (mTarget instanceof RecyclerView) { int lastVisiblePosition = 0; View childView = null; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager instanceof LinearLayoutManager) { lastVisiblePosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition(); childView = layoutManager.findViewByPosition(lastVisiblePosition); } else if (layoutManager instanceof GridLayoutManager) { lastVisiblePosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition(); childView = layoutManager.findViewByPosition(lastVisiblePosition); } else if (layoutManager instanceof StaggeredGridLayoutManager) { int[] spanPosition = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()]; ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(spanPosition); lastVisiblePosition = getLastVisibleItemPosition(spanPosition); childView = getLastVisibleItemBottomView(layoutManager, spanPosition, lastVisiblePosition); } if (null == childView) { return false; } if (lastVisiblePosition == layoutManager.getItemCount() - 1 && childView.getBottom() + layoutManager.getBottomDecorationHeight(childView) <= mTarget.getBottom()) { return true; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } return false; }
From source file:com.facebook.react.views.webview.ReactWebViewManager.java
private WebView.PictureListener getPictureListener() { if (mPictureListener == null) { mPictureListener = new WebView.PictureListener() { @Override/*from ww w. jav a 2s . c o m*/ public void onNewPicture(WebView webView, Picture picture) { dispatchEvent(webView, new ContentSizeChangeEvent(webView.getId(), webView.getWidth(), webView.getContentHeight())); } }; } return mPictureListener; }
From source file:com.tct.mail.ui.ConversationViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { LogUtils.d(LOG_TAG, "IN CVF.onActivityCreated, this=%s visible=%s", this, isUserVisible()); super.onActivityCreated(savedInstanceState); if (mActivity == null || mActivity.isFinishing()) { // Activity is finishing, just bail. return;/* w w w . java 2s.c o m*/ } Context context = getContext(); mTemplates = new HtmlConversationTemplates(context); final FormattedDateBuilder dateBuilder = new FormattedDateBuilder(context); mNavigationController = mActivity.getKeyboardNavigationController(); mAdapter = new ConversationViewAdapter(mActivity, this, getLoaderManager(), this, this, getContactInfoSource(), this, this, getListController(), this, mAddressCache, dateBuilder, mBidiFormatter, this); mConversationContainer.setOverlayAdapter(mAdapter); // set up snap header (the adapter usually does this with the other ones) mConversationContainer.getSnapHeader().initialize(this, mAddressCache, this, getContactInfoSource(), mActivity.getAccountController().getVeiledAddressMatcher()); final Resources resources = getResources(); mMaxAutoLoadMessages = resources.getInteger(R.integer.max_auto_load_messages); mSideMarginPx = resources.getDimensionPixelOffset(R.dimen.conversation_message_content_margin_side); mUrlToMessageIdMap = new ArrayMap<String, String>(); final InlineAttachmentViewIntentBuilderCreator creator = InlineAttachmentViewIntentBuilderCreatorHolder .getInlineAttachmentViewIntentCreator(); final WebViewContextMenu contextMenu = new WebViewContextMenu(getActivity(), creator .createInlineAttachmentViewIntentBuilder(mAccount, mConversation != null ? mConversation.id : -1)); contextMenu.setCallbacks(this); mWebView.setOnCreateContextMenuListener(contextMenu); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_S mWebView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_UP && webViewScaleHasChanged) { mWebView.loadUrl(String.format("javascript:setConversationHeaderSpacerHeight(%s);", mCovHeaderHeight * mWebView.getInitialScale() / mWebView.getScale())); if (mAdapter.getMessageHeaderItem() != null) { mWebView.loadUrl(String.format("javascript:setMessageHeaderSpacerHeight('%s', %s);", mTemplates.getMessageDomId(mAdapter.getMessageHeaderItem().getMessage()), mMsgHeaderHeight * mWebView.getInitialScale() / mWebView.getScale())); } mWebView.loadUrl(String.format("javascript:setConversationFooterSpacerHeight(%s);", mCovFooterHegiht * mWebView.getInitialScale() / mWebView.getScale())); webViewScaleHasChanged = false; } return mWebView.onTouchEvent(event); } }); // TS: zhaotianyong 2015-03-13 EMAIL BUGFIX-932165 ADD_E //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_S mFabButton.setAccountController(this); //Because we can't get the webview's contentHeight when onPageFinished(),so set the PictureListener //to get the contentHeight and judge if it's initialized bottom,and then do the animation. mWebView.setPictureListener(new PictureListener() { int previousHeight; @Deprecated public void onNewPicture(WebView w, Picture picture) { // TODO Auto-generated method stub int height = w.getContentHeight(); if (previousHeight == height) return; previousHeight = height; if (mWebView.isInitializedBottom()) { mWebView.animateBottom(true); } else { mWebView.animateHideFooter(); } } }); //TS: tao.gan 2015-09-10 EMAIL FEATURE-559891 ADD_E // set this up here instead of onCreateView to ensure the latest Account is loaded setupOverviewMode(); // Defer the call to initLoader with a Handler. // We want to wait until we know which fragments are present and their final visibility // states before going off and doing work. This prevents extraneous loading from occurring // as the ViewPager shifts about before the initial position is set. // // e.g. click on item #10 // ViewPager.setAdapter() actually first loads #0 and #1 under the assumption that #0 is // the initial primary item // Then CPC immediately sets the primary item to #10, which tears down #0/#1 and sets up // #9/#10/#11. getHandler().post(new FragmentRunnable("showConversation", this) { @Override public void go() { showConversation(); } }); if (mConversation != null && mConversation.conversationBaseUri != null && !Utils.isEmpty(mAccount.accountCookieQueryUri)) { // Set the cookie for this base url new SetCookieTask(getContext(), mConversation.conversationBaseUri.toString(), mAccount.accountCookieQueryUri).execute(); } // Find the height of the screen for manually scrolling the webview via keyboard. final Rect screen = new Rect(); mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(screen); mMaxScreenHeight = screen.bottom; mTopOfVisibleScreen = screen.top + mActivity.getSupportActionBar().getHeight(); //[BUGFIX]-Add-BEGIN?by?TSCD.zheng.zou,01/14/2015,887972 //[Email]It?still?display?download?remaining?when?rotate?the?screen?during?loading //note:use initLoader to reconnect with the previous loader. if (savedInstanceState != null) { mIsDownloadingRemaining = savedInstanceState.getBoolean(IS_DOWNLOADING_REMAINING); mIsPopDownloadRemain = savedInstanceState.getBoolean(IS_POP_DOWNLOAD_REMAIN); } LoaderManager lm = getLoaderManager(); if (lm.getLoader(LOADER_DOWNLOAD_REMAINING) != null) { lm.initLoader(LOADER_DOWNLOAD_REMAINING, null, mDownloadRemainCallback); } //[BUGFIX]-Add-END?by?TSCD.zheng.zou }