|
@@ -23,6 +23,7 @@ import android.view.animation.AnimationUtils;
|
|
|
import android.widget.FrameLayout;
|
|
import android.widget.FrameLayout;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.ProgressBar;
|
|
import android.widget.ProgressBar;
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.dateview.DateUtil;
|
|
import com.sheep.gamegroup.dateview.DateUtil;
|
|
|
import com.sheep.gamegroup.event.WXLoginAuthEvent;
|
|
import com.sheep.gamegroup.event.WXLoginAuthEvent;
|
|
@@ -119,13 +120,14 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(webParams.getTitle().equals("游戏")){
|
|
|
|
|
|
|
+ if (webParams.getTitle().equals("游戏")) {
|
|
|
//不显示系统的标题栏
|
|
//不显示系统的标题栏
|
|
|
- getActivity().getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
|
|
|
- WindowManager.LayoutParams.FLAG_FULLSCREEN );
|
|
|
|
|
|
|
+ getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
|
|
|
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String url = webParams.getUrl();
|
|
String url = webParams.getUrl();
|
|
|
|
|
+ Log.d("访问前的Cookie 5", "-- " + CookieManager.getInstance().getCookie(Uri.parse(url).getHost()));
|
|
|
String jsUrl = webParams.getJsUrl();
|
|
String jsUrl = webParams.getJsUrl();
|
|
|
if (!TextUtils.isEmpty(url)) {
|
|
if (!TextUtils.isEmpty(url)) {
|
|
|
url = url.trim();
|
|
url = url.trim();
|
|
@@ -137,6 +139,9 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
setLandscape();
|
|
setLandscape();
|
|
|
}
|
|
}
|
|
|
initWebViewSettings(mWebView);
|
|
initWebViewSettings(mWebView);
|
|
|
|
|
+ if(webParams.getOriginAccessToken()!=null){
|
|
|
|
|
+ saveWXToken(requireContext(), Uri.parse(webParams.getUrl()).getHost(), webParams.getOriginAccessToken(), webParams.getOriginRefreshToken(), webParams.getOriginExpires());
|
|
|
|
|
+ }
|
|
|
kfzsJs = new KFZSJs(SheepApp.getInstance().getCurrentActivity(), this);
|
|
kfzsJs = new KFZSJs(SheepApp.getInstance().getCurrentActivity(), this);
|
|
|
if (TextUtils.isEmpty(jsUrl)) {
|
|
if (TextUtils.isEmpty(jsUrl)) {
|
|
|
loadUrl(url);
|
|
loadUrl(url);
|
|
@@ -160,7 +165,7 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
@Override
|
|
@Override
|
|
|
protected void onProcessEvent(Object ev) {
|
|
protected void onProcessEvent(Object ev) {
|
|
|
if (ev instanceof WXLoginAuthEvent) {
|
|
if (ev instanceof WXLoginAuthEvent) {
|
|
|
- Log.d("######","···广播 回调登录"+getWebUrl());
|
|
|
|
|
|
|
+ Log.d("######", "···广播 回调登录" + getWebUrl());
|
|
|
EventBus.getDefault().unregister(this);
|
|
EventBus.getDefault().unregister(this);
|
|
|
if (!TextUtils.isEmpty(((WXLoginAuthEvent) ev).code)) {
|
|
if (!TextUtils.isEmpty(((WXLoginAuthEvent) ev).code)) {
|
|
|
WXAPIUtil.loadWXUserToken(((WXLoginAuthEvent) ev).code, (ret, openid, accessToken, refreshToken) -> {
|
|
WXAPIUtil.loadWXUserToken(((WXLoginAuthEvent) ev).code, (ret, openid, accessToken, refreshToken) -> {
|
|
@@ -317,7 +322,6 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
private String mCameraPhotoPath;
|
|
private String mCameraPhotoPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
private void loadUrl(final String url) {
|
|
private void loadUrl(final String url) {
|
|
|
|
|
|
|
|
mWebView.setWebChromeClient(new WebChromeClient() {
|
|
mWebView.setWebChromeClient(new WebChromeClient() {
|
|
@@ -838,6 +842,22 @@ public class FgtWebX5 extends BaseFgtWebX5 {
|
|
|
CookieSyncManager.createInstance(context).sync();
|
|
CookieSyncManager.createInstance(context).sync();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static void saveWXToken(Context context, String host, String accessToken, String refreshToken, String expires) {
|
|
|
|
|
+ CookieSyncManager.createInstance(context);
|
|
|
|
|
+ CookieManager cookieManager = CookieManager.getInstance();
|
|
|
|
|
+ cookieManager.setAcceptCookie(true);
|
|
|
|
|
+ String cookies = cookieManager.getCookie(host);
|
|
|
|
|
+ Map<String, String> cookieMap = StringUtils.string2Map(cookies, ";", "=");
|
|
|
|
|
+ cookieMap.put("access_token", accessToken);
|
|
|
|
|
+ cookieMap.put("refresh_token", refreshToken);
|
|
|
|
|
+ cookieMap.put("Expires", expires);
|
|
|
|
|
+ for (String key : cookieMap.keySet()) {
|
|
|
|
|
+ cookieManager.setCookie(host, key + "=" + cookieMap.get(key));
|
|
|
|
|
+ }
|
|
|
|
|
+ cookieManager.flush();
|
|
|
|
|
+ CookieSyncManager.createInstance(context).sync();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void initDataOnVisibleToUser() {
|
|
public void initDataOnVisibleToUser() {
|
|
|
if (onResumeCount > 0 && mWebView != null && webParams != null && webParams.isRefreshClick()) {
|
|
if (onResumeCount > 0 && mWebView != null && webParams != null && webParams.isRefreshClick()) {
|
|
|
mWebView.invalidate();
|
|
mWebView.invalidate();
|