Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fastdevelop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高超
fastdevelop
Commits
21b5253f
Commit
21b5253f
authored
Sep 29, 2019
by
gao.chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web优化
parent
fc1d4efe
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
web/src/main/java/com/mayi/fastdevelop/web/BaseWebActivity.java
+16
-12
No files found.
web/src/main/java/com/mayi/fastdevelop/web/BaseWebActivity.java
View file @
21b5253f
...
...
@@ -150,7 +150,7 @@ public class BaseWebActivity extends BaseActivity {
if
(
TextUtils
.
isEmpty
(
url
))
{
return
;
}
if
(
url
.
contains
(
"isNeedBackButton"
))
{
if
(
url
.
contains
(
"isNeedBackButton
=true
"
))
{
title
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
title
.
setVisibility
(
View
.
GONE
);
...
...
@@ -216,7 +216,6 @@ public class BaseWebActivity extends BaseActivity {
public
void
takePhoto
()
{
StringBuilder
fileName
=
new
StringBuilder
();
Intent
intent
=
new
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
);
fileName
.
append
(
System
.
currentTimeMillis
()).
append
(
"_upload.jpg"
);
File
tempFile
=
new
File
(
getExternalFilesDir
(
Environment
.
DIRECTORY_PICTURES
),
fileName
.
toString
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
...
...
@@ -257,12 +256,11 @@ public class BaseWebActivity extends BaseActivity {
handler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
webView
.
loadUrl
(
"javascript:appCallJs
.invoking;
("
+
method
+
","
+
data
+
")"
);
webView
.
loadUrl
(
"javascript:appCallJs("
+
method
+
","
+
data
+
")"
);
}
});
}
@JavascriptInterface
public
void
invoking
(
final
String
method
,
final
String
data
)
{
handler
.
post
(
new
Runnable
()
{
...
...
@@ -273,7 +271,12 @@ public class BaseWebActivity extends BaseActivity {
webView
.
clearHistory
();
webView
.
clearFormData
();
}
else
if
(
TextUtils
.
equals
(
"goCallPhone"
,
method
))
{
//去打电话
SystemUtil
.
makePhoneCall
(
BaseWebActivity
.
this
,
data
);
try
{
JSONObject
jsonObject
=
new
JSONObject
(
data
);
SystemUtil
.
makePhoneCall
(
BaseWebActivity
.
this
,
jsonObject
.
optString
(
"tel"
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
else
if
(
TextUtils
.
equals
(
"backPage"
,
method
))
{
//返回上一页
webPageBack
();
}
else
if
(
TextUtils
.
equals
(
"goPage"
,
method
))
{
//跳转原生页面
...
...
@@ -286,7 +289,8 @@ public class BaseWebActivity extends BaseActivity {
appCallJs
(
"setUserInfo"
,
SpUtil
.
get
(
Key
.
USER_INFO
,
""
));
}
else
if
(
TextUtils
.
equals
(
"sendSMS"
,
method
))
{
//发送短信
sendSMS
(
data
);
}
else
if
(
TextUtils
.
equals
(
"location"
,
method
))
{
//定位
}
// else if (TextUtils.equals("location", method)) {//定位
// LocationUtils.startLocation(BaseWebActivity.this, new LocationUtils.LocationCallback() {
// @Override
// public void onFail(String msg) {
...
...
@@ -298,7 +302,7 @@ public class BaseWebActivity extends BaseActivity {
// appCallJs("LocationSuccess", JSON.toJSONString(bean));
// }
// });
}
//
}
}
});
}
...
...
@@ -326,20 +330,20 @@ public class BaseWebActivity extends BaseActivity {
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
if
(
TextUtils
.
equals
(
pageName
,
"MapLocation"
))
{
//地图定位页面
//
if (TextUtils.equals(pageName, "MapLocation")) {//地图定位页面
// Intent intent = new Intent(this, MapLocationActivity.class);
// startActivityForResult(intent, RequestCode.MAP_LOCATION_ACTIVITY_RESULTCODE);
}
else
{
//
} else {
if
(
webListener
!=
null
)
{
webListener
.
goPageListener
(
pageName
,
parameter
);
}
}
//
}
}
private
void
initWebView
()
{
WebSettings
settings
=
webView
.
getSettings
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
settings
.
setMixedContentMode
(
2
);
settings
.
setMixedContentMode
(
0
);
}
settings
.
setBlockNetworkImage
(
false
);
...
...
@@ -357,7 +361,7 @@ public class BaseWebActivity extends BaseActivity {
settings
.
setDefaultTextEncodingName
(
"utf-8"
);
settings
.
setJavaScriptEnabled
(
true
);
settings
.
setJavaScriptCanOpenWindowsAutomatically
(
true
);
settings
.
setCacheMode
(
WebSettings
.
LOAD_
CACHE_ELSE_NETWORK
);
settings
.
setCacheMode
(
WebSettings
.
LOAD_
DEFAULT
);
settings
.
setAllowFileAccess
(
true
);
settings
.
setAppCacheEnabled
(
true
);
webView
.
setHorizontalScrollBarEnabled
(
false
);
//水平不显示
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment