Java Code Examples for android.webkit.WebView#postDelayed()
The following examples show how to use
android.webkit.WebView#postDelayed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebUtil.java From DoraemonKit with Apache License 2.0 | 6 votes |
public static void webViewLoadLocalHtml(final WebView view, String jsPath) { String htmlData = assetFileToString(view.getContext(), jsPath); view.loadDataWithBaseURL("http://localhost", htmlData, "text/html", "UTF-8", null); //必须要延迟一定的时间 方便html字符串先加载完 view.postDelayed(new Runnable() { @Override public void run() { LatLng latLng = GpsMockConfig.getMockLocation(); if (latLng == null) { latLng = new LatLng(0, 0); } String url = String.format("javascript:init(%s,%s)", latLng.latitude, latLng.longitude); //String url = String.format("javascript:init(%s,%s)", 0, 0); //String url = String.format("javascript:init(%s,%s)", 39.901933, 116.396613); view.loadUrl(url); } }, 1000); }
Example 2
Source File: LightningView.java From browser with GNU General Public License v2.0 | 6 votes |
@Override public void onScaleChanged(final WebView view, final float oldScale, final float newScale) { if (view.isShown() && mTextReflow && API >= android.os.Build.VERSION_CODES.KITKAT) { if (mIsRunning) return; if (Math.abs(mZoomScale - newScale) > 0.01f) { mIsRunning = view.postDelayed(new Runnable() { @Override public void run() { mZoomScale = newScale; view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null); mIsRunning = false; } }, 100); } } }
Example 3
Source File: PageLoad.java From quickhybrid-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onProgressChanged(WebView view, int newProgress) { fragment.getProgressBar().setProgress(newProgress); if (newProgress == 100) { view.postDelayed(new Runnable() { @Override public void run() { fragment.getProgressBar().setVisibility(View.GONE); } }, 500); } else { if (fragment.getProgressBar().getVisibility() == View.GONE) { fragment.getProgressBar().setVisibility(View.VISIBLE); } } }
Example 4
Source File: LightningWebClient.java From Xndroid with GNU General Public License v3.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) @Override public void onScaleChanged(@NonNull final WebView view, final float oldScale, final float newScale) { if (view.isShown() && mLightningView.mPreferences.getTextReflowEnabled() && Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { if (mIsRunning) return; float changeInPercent = Math.abs(100 - 100 / mZoomScale * newScale); if (changeInPercent > 2.5f && !mIsRunning) { mIsRunning = view.postDelayed(new Runnable() { @Override public void run() { mZoomScale = newScale; view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, new ValueCallback<String>() { @Override public void onReceiveValue(String value) { mIsRunning = false; } }); } }, 100); } } }
Example 5
Source File: LightningWebClient.java From JumpGo with Mozilla Public License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) @Override public void onScaleChanged(@NonNull final WebView view, final float oldScale, final float newScale) { if (view.isShown() && mLightningView.mPreferences.getTextReflowEnabled() && Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { if (mIsRunning) return; float changeInPercent = Math.abs(100 - 100 / mZoomScale * newScale); if (changeInPercent > 2.5f && !mIsRunning) { mIsRunning = view.postDelayed(new Runnable() { @Override public void run() { mZoomScale = newScale; view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, new ValueCallback<String>() { @Override public void onReceiveValue(String value) { mIsRunning = false; } }); } }, 100); } } }
Example 6
Source File: ThemeFragment.java From 4pdaClient-plus with Apache License 2.0 | 6 votes |
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (startsWith(url, mOnErrorUrl)) { mUrl = url; mLoadingError = true; mLoadingFinished = false; onPageFinished(view, url); } if (mUrl == null) { mUrl = url; mLoadingError = false; mLoadingFinished = false; view.removeCallbacks(mPageLoadingTimeoutHandlerTask); view.postDelayed(mPageLoadingTimeoutHandlerTask, LOADING_ERROR_TIMEOUT); mReference = new WeakReference<>(view); } }
Example 7
Source File: DeviceApi.java From quickhybrid-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 控制键盘显隐,如果输入法在窗口上已经显示,则隐藏,反之则显示 */ public static void closeInputKeyboard(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) { wv.postDelayed(new Runnable() { public void run() { DeviceUtil.hideInputKeyboard(webLoader.getPageControl().getActivity()); callback.applySuccess(); } }, 200); }
Example 8
Source File: WebViewActivity.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public void onScaleChanged(final WebView view, float oldScale, float newScale) { final long now = System.currentTimeMillis(); if (mStableScale == null || (now - mStableScaleCalculationStart) < STABLE_SCALE_CALCULATION_DURATION) { mStableScale = "" + newScale; } else if (!mStableScale.equals("" + newScale)) { boolean zooming = (now - mRestoringScaleStart) < STABLE_SCALE_CALCULATION_DURATION; if (!zooming) { mRestoringScaleStart = now; view.zoomOut(); view.postDelayed(view::zoomOut , STABLE_SCALE_CALCULATION_DURATION); } } }