|
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
|
+import android.content.SharedPreferences;
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Bitmap;
|
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
@@ -14,6 +15,7 @@ import android.support.v7.app.ActionBar;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
import android.util.DisplayMetrics;
|
|
import android.util.DisplayMetrics;
|
|
|
|
|
+import android.util.Log;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
import android.view.animation.Animation;
|
|
import android.view.animation.Animation;
|
|
@@ -101,6 +103,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
// mWebView = new WebView(SheepApp.getInstance());
|
|
// mWebView = new WebView(SheepApp.getInstance());
|
|
|
mWebView = new WebView(getActivity());
|
|
mWebView = new WebView(getActivity());
|
|
|
|
|
+ //getSavedCookies();
|
|
|
webContainer.addView(mWebView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
webContainer.addView(mWebView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
// ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
|
|
// ViewUtil.setImage(act_web_loading_iv, R.drawable.gif_sheep_loading);
|
|
|
ViewUtil.setGif(act_web_loading_iv, R.drawable.gif_sheep_loading);
|
|
ViewUtil.setGif(act_web_loading_iv, R.drawable.gif_sheep_loading);
|
|
@@ -172,9 +175,8 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
|
|
|
|
|
webView.setClickable(true);
|
|
webView.setClickable(true);
|
|
|
WebSettings webSetting = webView.getSettings();
|
|
WebSettings webSetting = webView.getSettings();
|
|
|
- webSetting.setJavaScriptEnabled(true);
|
|
|
|
|
- webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
|
|
|
|
|
- webSetting.setAllowFileAccess(true);
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
|
|
//webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
|
|
|
//自适应屏幕
|
|
//自适应屏幕
|
|
|
WebSettings.ZoomDensity zoomDensity = WebSettings.ZoomDensity.MEDIUM;
|
|
WebSettings.ZoomDensity zoomDensity = WebSettings.ZoomDensity.MEDIUM;
|
|
@@ -189,7 +191,19 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
zoomDensity = WebSettings.ZoomDensity.FAR;
|
|
zoomDensity = WebSettings.ZoomDensity.FAR;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
+ webSetting.setJavaScriptEnabled(true);
|
|
|
|
|
+ webSetting.setGeolocationEnabled(true);
|
|
|
|
|
+ webSetting.setJavaScriptCanOpenWindowsAutomatically(true);
|
|
|
webSetting.setDefaultZoom(zoomDensity);
|
|
webSetting.setDefaultZoom(zoomDensity);
|
|
|
|
|
+ webSetting.setSupportMultipleWindows(true);
|
|
|
|
|
+ webSetting.setDomStorageEnabled(true);
|
|
|
|
|
+ webSetting.setAppCacheMaxSize(1024 * 1024 * 8);
|
|
|
|
|
+ String appCachePath = SheepApp.getInstance().getApplicationContext().getCacheDir().getAbsolutePath();
|
|
|
|
|
+ webSetting.setAppCachePath(appCachePath);
|
|
|
|
|
+ webSetting.setAllowFileAccess(true);
|
|
|
|
|
+ webSetting.setAppCacheEnabled(true);
|
|
|
|
|
+ webSetting.setDatabaseEnabled(true);
|
|
|
|
|
+ webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
|
|
|
/*webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
|
/*webSetting.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
|
|
webSetting.setLoadWithOverviewMode(true);
|
|
webSetting.setLoadWithOverviewMode(true);
|
|
|
webSetting.setTextZoom(100);
|
|
webSetting.setTextZoom(100);
|
|
@@ -197,16 +211,10 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
webSetting.setSupportZoom(false);*/
|
|
webSetting.setSupportZoom(false);*/
|
|
|
// webSetting.setSupportZoom(true);
|
|
// webSetting.setSupportZoom(true);
|
|
|
// webSetting.setBuiltInZoomControls(true);
|
|
// webSetting.setBuiltInZoomControls(true);
|
|
|
-
|
|
|
|
|
- webSetting.setSupportMultipleWindows(true);
|
|
|
|
|
// webSetting.setLoadWithOverviewMode(true);
|
|
// webSetting.setLoadWithOverviewMode(true);
|
|
|
- webSetting.setAppCacheEnabled(true);
|
|
|
|
|
// webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
|
|
// webSetting.setAppCacheMaxSize(Long.MAX_VALUE);
|
|
|
// webSetting.setDatabaseEnabled(true);
|
|
// webSetting.setDatabaseEnabled(true);
|
|
|
- webSetting.setDomStorageEnabled(true);
|
|
|
|
|
- webSetting.setGeolocationEnabled(true);
|
|
|
|
|
// webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
|
|
// webSetting.setPageCacheCapacity(IX5WebSettings.DEFAULT_CACHE_CAPACITY);
|
|
|
- webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
|
|
|
|
|
// webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
|
|
// webSetting.setRenderPriority(WebSettings.RenderPriority.HIGH);
|
|
|
// webSetting.setCacheMode(NetUtil.CAN_CONNECT_SERVICE ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
|
// webSetting.setCacheMode(NetUtil.CAN_CONNECT_SERVICE ? WebSettings.LOAD_DEFAULT : WebSettings.LOAD_CACHE_ELSE_NETWORK);
|
|
|
|
|
|
|
@@ -234,6 +242,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
public void onDetach() {
|
|
public void onDetach() {
|
|
|
if (mWebView != null) {
|
|
if (mWebView != null) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ getGameUserInfo(false);
|
|
|
if (mWebView.getParent() != null) {
|
|
if (mWebView.getParent() != null) {
|
|
|
((ViewGroup) mWebView.getParent()).removeView(mWebView);
|
|
((ViewGroup) mWebView.getParent()).removeView(mWebView);
|
|
|
}
|
|
}
|
|
@@ -485,6 +494,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
CookieSyncManager.getInstance().sync();
|
|
CookieSyncManager.getInstance().sync();
|
|
|
}
|
|
}
|
|
|
|
|
+ getGameUserInfo(true);
|
|
|
loadJs();
|
|
loadJs();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -638,8 +648,8 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
|
|
|
|
|
// 注入js函数监听
|
|
// 注入js函数监听
|
|
|
public void loadJs() {
|
|
public void loadJs() {
|
|
|
- if (TextUtils.isEmpty(js))
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (TextUtils.isEmpty(js)) return;
|
|
|
ViewUtil.loadJs(mWebView, getJs());
|
|
ViewUtil.loadJs(mWebView, getJs());
|
|
|
LogUtil.println("ActWebX5", "loadJs", js);
|
|
LogUtil.println("ActWebX5", "loadJs", js);
|
|
|
}
|
|
}
|
|
@@ -652,6 +662,39 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
return BuildConfig.DEBUG ? testJsStart + "\n" + js : releaseJsStart + "\n" + js;
|
|
return BuildConfig.DEBUG ? testJsStart + "\n" + js : releaseJsStart + "\n" + js;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static final String KEY_GAME_USER_INFO = "key_game_user_info";
|
|
|
|
|
+
|
|
|
|
|
+ private void getGameUserInfo(boolean shouldLoad) {
|
|
|
|
|
+ String js = "window.localStorage.getItem('userInfo');";
|
|
|
|
|
+ mWebView.evaluateJavascript(js, new ValueCallback<String>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onReceiveValue(String s) {
|
|
|
|
|
+ Log.d("!!!!!!!!", s);
|
|
|
|
|
+ if (!s.equals("null")) {
|
|
|
|
|
+ SharedPreferencesUtil.putData(KEY_GAME_USER_INFO, s);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if(shouldLoad){
|
|
|
|
|
+ String oldUserInfo = (String) SharedPreferencesUtil.getData(KEY_GAME_USER_INFO, "");
|
|
|
|
|
+ if (oldUserInfo != null && !oldUserInfo.isEmpty()) {
|
|
|
|
|
+ String jsUrl = "window.localStorage.setItem('userInfo','" + oldUserInfo + "')";
|
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
|
|
+ mWebView.evaluateJavascript(jsUrl, new ValueCallback<String>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onReceiveValue(String s) {
|
|
|
|
|
+ mWebView.reload();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mWebView.loadUrl(jsUrl);
|
|
|
|
|
+ mWebView.reload();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public boolean isResponseBack() {
|
|
public boolean isResponseBack() {
|
|
|
return responseBack;
|
|
return responseBack;
|