|
@@ -4,7 +4,9 @@ import android.app.Activity;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.content.pm.ActivityInfo;
|
|
import android.content.pm.ActivityInfo;
|
|
|
|
|
+import android.content.res.Configuration;
|
|
|
import android.graphics.PixelFormat;
|
|
import android.graphics.PixelFormat;
|
|
|
|
|
+import android.os.Build;
|
|
|
import android.support.v4.widget.SwipeRefreshLayout;
|
|
import android.support.v4.widget.SwipeRefreshLayout;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
@@ -16,11 +18,10 @@ import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
import android.view.WindowManager;
|
|
import android.view.WindowManager;
|
|
|
|
|
|
|
|
-import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient;
|
|
|
|
|
-import com.tencent.smtt.sdk.WebChromeClient;
|
|
|
|
|
-import com.tencent.smtt.sdk.WebSettings;
|
|
|
|
|
-import com.tencent.smtt.sdk.WebView;
|
|
|
|
|
-import com.tencent.smtt.sdk.WebViewClient;
|
|
|
|
|
|
|
+import android.webkit.WebChromeClient;
|
|
|
|
|
+import android.webkit.WebSettings;
|
|
|
|
|
+import android.webkit.WebView;
|
|
|
|
|
+import android.webkit.WebViewClient;
|
|
|
import android.widget.FrameLayout;
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
@@ -91,7 +92,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
protected final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
protected final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
|
private View customView;
|
|
private View customView;
|
|
|
private FrameLayout fullscreenContainer;
|
|
private FrameLayout fullscreenContainer;
|
|
|
- private IX5WebChromeClient.CustomViewCallback customViewCallback;
|
|
|
|
|
|
|
+ private WebChromeClient.CustomViewCallback customViewCallback;
|
|
|
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.refresh)
|
|
@BindView(R.id.refresh)
|
|
@@ -165,24 +166,43 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
|
|
|
|
|
|
|
|
|
|
public void initWebView() {
|
|
public void initWebView() {
|
|
|
|
|
+// getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
|
|
|
|
|
+// WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
|
|
|
|
+
|
|
|
WebChromeClient wvcc = new WebChromeClient();
|
|
WebChromeClient wvcc = new WebChromeClient();
|
|
|
- WebSettings webSettings = webView.getSettings();
|
|
|
|
|
- webSettings.setJavaScriptEnabled(true);
|
|
|
|
|
- webSettings.setUseWideViewPort(true); // 关键点
|
|
|
|
|
- webSettings.setAllowFileAccess(true); // 允许访问文件
|
|
|
|
|
- webSettings.setSupportZoom(true); // 支持缩放
|
|
|
|
|
- webSettings.setLoadWithOverviewMode(true);//是否支持全屏
|
|
|
|
|
- webSettings.setDomStorageEnabled(true);
|
|
|
|
|
- webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); // 加载缓存内容
|
|
|
|
|
- webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);// 自适应屏幕
|
|
|
|
|
|
|
+ WebSettings webSetting = webView.getSettings();
|
|
|
|
|
+ webSetting.setJavaScriptEnabled(true);
|
|
|
|
|
+ webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
|
|
|
|
|
+ webSetting.setAllowFileAccess(true);
|
|
|
|
|
+ webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
|
|
|
|
|
+ webSetting.setSupportZoom(true);
|
|
|
|
|
+ webSetting.setBuiltInZoomControls(true);
|
|
|
|
|
+ webSetting.setUseWideViewPort(true);
|
|
|
|
|
+ webSetting.setSupportMultipleWindows(true);
|
|
|
|
|
+ webSetting.setAppCacheEnabled(true);
|
|
|
|
|
+ webSetting.setDatabaseEnabled(true);
|
|
|
|
|
+ webSetting.setDomStorageEnabled(true);
|
|
|
|
|
+ webSetting.setGeolocationEnabled(true);
|
|
|
|
|
+ webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
|
|
|
|
|
+ webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
|
|
|
|
|
+ webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
|
|
|
|
|
+ webSetting.setCacheMode(android.webkit.WebSettings.LOAD_NO_CACHE);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ webSetting.setCacheMode(android.webkit.WebSettings.LOAD_DEFAULT);
|
|
|
|
|
+ webSetting.setLoadWithOverviewMode(true);
|
|
|
getWindow().setFormat(PixelFormat.TRANSLUCENT);
|
|
getWindow().setFormat(PixelFormat.TRANSLUCENT);
|
|
|
webView.setWebChromeClient(wvcc);
|
|
webView.setWebChromeClient(wvcc);
|
|
|
WebViewClient wvc = new WebViewClient() {
|
|
WebViewClient wvc = new WebViewClient() {
|
|
|
@Override
|
|
@Override
|
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
|
- webView.loadUrl(url);
|
|
|
|
|
- Jump2View.getInstance().goWeb(ActFindInformation.this, url);
|
|
|
|
|
- return true;
|
|
|
|
|
|
|
+ //Android8.0以下的需要返回true 并且需要loadUrl;8.0之后效果相反
|
|
|
|
|
+ if(Build.VERSION.SDK_INT<26) {
|
|
|
|
|
+ webView.loadUrl(url);
|
|
|
|
|
+ Jump2View.getInstance().goWeb(ActFindInformation.this, url);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
webView.setWebChromeClient(new WebChromeClient() {
|
|
webView.setWebChromeClient(new WebChromeClient() {
|
|
@@ -200,7 +220,8 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void onShowCustomView(View view, IX5WebChromeClient.CustomViewCallback callback) {
|
|
|
|
|
|
|
+ public void onShowCustomView(View view, CustomViewCallback callback) {
|
|
|
|
|
+ super.onShowCustomView(view, callback);
|
|
|
showCustomView(view, callback);
|
|
showCustomView(view, callback);
|
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//设置横屏
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//设置横屏
|
|
|
}
|
|
}
|
|
@@ -209,6 +230,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
public void onHideCustomView() {
|
|
public void onHideCustomView() {
|
|
|
hideCustomView();
|
|
hideCustomView();
|
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//设置竖屏
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//设置竖屏
|
|
|
|
|
+ super.onHideCustomView();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
webView.setWebViewClient(wvc);
|
|
webView.setWebViewClient(wvc);
|
|
@@ -218,7 +240,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
* 视频播放全屏
|
|
* 视频播放全屏
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
- private void showCustomView(View view, IX5WebChromeClient.CustomViewCallback callback) {
|
|
|
|
|
|
|
+ private void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
|
|
|
// if a view already exists then immediately terminate the new one
|
|
// if a view already exists then immediately terminate the new one
|
|
|
if (customView != null) {
|
|
if (customView != null) {
|
|
|
callback.onCustomViewHidden();
|
|
callback.onCustomViewHidden();
|
|
@@ -316,7 +338,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
initWebView();
|
|
initWebView();
|
|
|
|
|
|
|
|
|
|
|
|
|
- ViewUtil.loadDataWithBaseURL(webView, findItem.getContent());
|
|
|
|
|
|
|
+ ViewUtil.loadDataWithBaseURL(webView, /*findItem.getContent()*/"<iframe class=\"x-video\" frameborder=\"0\" allowfullscreen=\"true\" src=\"https://crazynote.v.netease.com/2018/0914/96648763b70deb3dd0a687a48a1892e2qt.mp4\"></iframe><p><br></p>");
|
|
|
LogUtil.logI("结果为——-----" + findItem.getContent());
|
|
LogUtil.logI("结果为——-----" + findItem.getContent());
|
|
|
/* webView.setWebViewClient(new WebViewClient() {
|
|
/* webView.setWebViewClient(new WebViewClient() {
|
|
|
@Override
|
|
@Override
|
|
@@ -428,7 +450,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
findItem = data;
|
|
findItem = data;
|
|
|
list.clear();
|
|
list.clear();
|
|
|
list.add("top");
|
|
list.add("top");
|
|
|
- list.add("bottom");
|
|
|
|
|
|
|
+// list.add("bottom");
|
|
|
notifyDataSetChanged();
|
|
notifyDataSetChanged();
|
|
|
if (findItem.getRelease_task_id() != 0) {//包含任务
|
|
if (findItem.getRelease_task_id() != 0) {//包含任务
|
|
|
taskHelper.initAcceptedTask(ActFindInformation.this, findItem.getRelease_task_id());
|
|
taskHelper.initAcceptedTask(ActFindInformation.this, findItem.getRelease_task_id());
|
|
@@ -625,7 +647,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
taskHelper.onResume();
|
|
taskHelper.onResume();
|
|
|
try {
|
|
try {
|
|
|
if (webView != null) {
|
|
if (webView != null) {
|
|
|
- webView.resumeTimers();
|
|
|
|
|
|
|
+// webView.resumeTimers();
|
|
|
webView.onResume();
|
|
webView.onResume();
|
|
|
webView.getClass().getMethod("onResume").invoke(webView, (Object[]) null);
|
|
webView.getClass().getMethod("onResume").invoke(webView, (Object[]) null);
|
|
|
}
|
|
}
|
|
@@ -636,17 +658,17 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
|
- super.onDestroy();
|
|
|
|
|
LogUtil.logI("释放资源");
|
|
LogUtil.logI("释放资源");
|
|
|
EventBus.getDefault().unregister(this);
|
|
EventBus.getDefault().unregister(this);
|
|
|
taskHelper.destroy();
|
|
taskHelper.destroy();
|
|
|
if (webView != null) {
|
|
if (webView != null) {
|
|
|
- webView.onPause();
|
|
|
|
|
- webView.freeMemory();
|
|
|
|
|
- webView.removeAllViews();
|
|
|
|
|
|
|
+// webView.onPause();
|
|
|
|
|
+// webView.freeMemory();
|
|
|
|
|
+// webView.removeAllViews();
|
|
|
webView.destroy();
|
|
webView.destroy();
|
|
|
- webView = null;
|
|
|
|
|
|
|
+// webView = null;
|
|
|
}
|
|
}
|
|
|
|
|
+ super.onDestroy();
|
|
|
ActFindInformation.this.finish();
|
|
ActFindInformation.this.finish();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -673,7 +695,7 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
super.onPause();
|
|
super.onPause();
|
|
|
if (webView != null) {
|
|
if (webView != null) {
|
|
|
webView.onPause();
|
|
webView.onPause();
|
|
|
- webView.pauseTimers();
|
|
|
|
|
|
|
+// webView.pauseTimers();
|
|
|
try {
|
|
try {
|
|
|
webView.getClass().getMethod("onPause").invoke(webView, (Object[]) null);
|
|
webView.getClass().getMethod("onPause").invoke(webView, (Object[]) null);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -681,4 +703,29 @@ public class ActFindInformation extends BaseActivity implements Action1<Integer>
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onBackPressed() {
|
|
|
|
|
+ if (webView != null && webView.canGoBack()) {
|
|
|
|
|
+ webView.goBack();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ super.onBackPressed();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onConfigurationChanged(Configuration config) {
|
|
|
|
|
+ super.onConfigurationChanged(config);
|
|
|
|
|
+ switch (config.orientation) {
|
|
|
|
|
+ case Configuration.ORIENTATION_LANDSCAPE:
|
|
|
|
|
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
|
|
|
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case Configuration.ORIENTATION_PORTRAIT:
|
|
|
|
|
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
|
|
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|