Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
613d0d77
Commit
613d0d77
authored
Jun 22, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: webView传入JsMethod
parent
60a45ede
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
43 deletions
+29
-43
WebServiceImpl.java
app/src/main/java/com/ydl/component/service/WebServiceImpl.java
+7
-3
JsMethod.kt
app/src/main/java/com/ydl/component/service/web/JsMethod.kt
+12
-1
WebJavascriptHandler.kt
app/src/main/java/com/ydl/component/service/web/WebJavascriptHandler.kt
+3
-7
ConfideBottomSheetDialogFragment.kt
m-confide/src/main/java/com/ydl/confide/home/ConfideBottomSheetDialogFragment.kt
+1
-1
ExpertConsultWebview.kt
m-im/src/main/java/com/yidianling/uikit/custom/widget/expertConsultService/view/ExpertConsultWebview.kt
+2
-3
ChooseMusicActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/ChooseMusicActivity.kt
+1
-1
BuildConfig.java
ydl-webview/src/main/gen/com/ydl/webview/BuildConfig.java
+0
-9
Manifest.java
ydl-webview/src/main/gen/com/ydl/webview/Manifest.java
+0
-8
R.java
ydl-webview/src/main/gen/com/ydl/webview/R.java
+0
-8
IWebService.kt
ydl-webview/src/main/java/com/ydl/webview/IWebService.kt
+2
-1
NewH5Activity.java
ydl-webview/src/main/java/com/ydl/webview/NewH5Activity.java
+1
-1
No files found.
app/src/main/java/com/ydl/component/service/WebServiceImpl.java
View file @
613d0d77
...
...
@@ -2,13 +2,17 @@ package com.ydl.component.service;
import
android.app.Activity
;
import
android.content.Context
;
import
com.alibaba.android.arouter.facade.annotation.Route
;
import
com.
ydl.component.service.web.WebJavascriptHandler
;
import
com.
tencent.smtt.sdk.WebView
;
import
com.ydl.component.service.web.WVClickAbstractListener
;
import
com.ydl.component.service.web.WebJavascriptHandler
;
import
com.ydl.webview.IJavascriptHandler
;
import
com.ydl.webview.IWebService
;
import
com.ydl.webview.TellData
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
/**
* Created by haorui on 2019-10-10.
...
...
@@ -24,7 +28,7 @@ public class WebServiceImpl implements IWebService {
@NotNull
@Override
public
IJavascriptHandler
getJavascripHandler
(
@NotNull
Activity
activity
,
@NotNull
TellData
tellData
)
{
return
new
WebJavascriptHandler
(
new
WVClickAbstractListener
(
activity
));
public
IJavascriptHandler
getJavascripHandler
(
@NotNull
Activity
activity
,
@N
ullable
WebView
webView
,
@N
otNull
TellData
tellData
)
{
return
new
WebJavascriptHandler
(
webView
,
new
WVClickAbstractListener
(
activity
));
}
}
app/src/main/java/com/ydl/component/service/web/JsMethod.kt
View file @
613d0d77
...
...
@@ -2,6 +2,9 @@ package com.ydl.component.service.web
import
com.google.gson.JsonObject
import
com.google.gson.JsonParser
import
com.hjq.permissions.Permission
import
com.hjq.permissions.XXPermissions
import
com.tencent.smtt.sdk.WebView
import
com.ydl.confide.home.event.ConfideDialogEvent
import
com.ydl.webview.H5Params
import
com.ydl.webview.NewH5Activity
...
...
@@ -11,7 +14,7 @@ import com.yidianling.common.tools.ToastUtil
import
de.greenrobot.event.EventBus
class
JsMethod
{
class
JsMethod
(
private
val
webView
:
WebView
?)
{
fun
handle
(
param
:
String
):
Boolean
{
...
...
@@ -57,6 +60,14 @@ class JsMethod {
}
return
true
}
"has_audio_permission"
->
{
val
callback
=
param
.
getAsJsonPrimitive
(
"callback"
).
asString
if
(
callback
.
isNullOrBlank
())
return
true
val
topActivity
=
BaseActivityMgr
.
INST
.
getTopActivity
()
val
grantedPermission
=
XXPermissions
.
isGrantedPermission
(
topActivity
,
Permission
.
RECORD_AUDIO
)
webView
?.
loadUrl
(
"javascript:$callback(${if (grantedPermission) 1 else 0})"
)
return
true
}
else
->
{
return
false
}
...
...
app/src/main/java/com/ydl/component/service/web/WebJavascriptHandler.kt
View file @
613d0d77
...
...
@@ -3,6 +3,7 @@ package com.ydl.component.service.web
import
android.webkit.JavascriptInterface
import
androidx.fragment.app.FragmentActivity
import
com.google.gson.Gson
import
com.tencent.smtt.sdk.WebView
import
com.ydl.confide.api.ConfideRoute
import
com.ydl.confide.api.IConfideService
import
com.ydl.js_module.manager.WebViewRouterManager
...
...
@@ -21,18 +22,13 @@ import com.yidianling.user.UserHelper
* update by harvie on 2017/7/04
*/
class
WebJavascriptHandler
:
IJavascriptHandler
{
class
WebJavascriptHandler
(
private
val
webView
:
WebView
?,
private
val
wvEnventPro
:
WebViewClientClickListener
?)
:
IJavascriptHandler
()
{
private
val
js
=
JsMethod
()
private
val
js
=
JsMethod
(
webView
)
override
fun
getUriAppendSuffix
():
String
{
return
"platform_main_theme=00C9E2&platform_main_theme_light=00D4DF&platform_main_theme_bright=EAFAFC"
}
var
wvEnventPro
:
WebViewClientClickListener
?
=
null
constructor
(
listener
:
WebViewClientClickListener
)
:
super
()
{
this
.
wvEnventPro
=
listener
}
@JavascriptInterface
fun
sendDataToOC
(
params
:
String
)
{
...
...
m-confide/src/main/java/com/ydl/confide/home/ConfideBottomSheetDialogFragment.kt
View file @
613d0d77
...
...
@@ -416,7 +416,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
wv_content
?.
scrollBarStyle
=
View
.
SCROLLBARS_INSIDE_OVERLAY
//滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
mJtoJHandle
=
WebModularServiceUtils
.
getWebService
()
.
getJavascripHandler
(
requireActivity
(),
tellData
=
TellData
())
.
getJavascripHandler
(
requireActivity
(),
wv_content
,
tellData
=
TellData
())
wv_content
?.
addJavascriptInterface
(
mJtoJHandle
,
"javascriptHandler"
)
// var jumpurl = "http://192.168.210.152/jy/listenMask?listenerId=257&isFromApp=1"
...
...
m-im/src/main/java/com/yidianling/uikit/custom/widget/expertConsultService/view/ExpertConsultWebview.kt
View file @
613d0d77
...
...
@@ -18,7 +18,6 @@ import com.yidianling.common.tools.RxDeviceTool
import
com.yidianling.common.tools.ToastUtil
import
com.yidianling.im.R
import
com.yidianling.uikit.custom.http.response.ServiceItemBean
import
com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
class
ExpertConsultWebview
:
RelativeLayout
{
private
var
doctorID
:
String
...
...
@@ -53,7 +52,7 @@ class ExpertConsultWebview : RelativeLayout {
jumpUrl
=
HttpConfig
.
MH5_URL
+
"wb/product/chat/template?doctorId=${doctorID}&cateId=${productBean.getcatenewId()}&productId=${productBean.productDto.id}"
val
jtoJHandle
=
WebModularServiceUtils
.
getWebService
()
.
getJavascripHandler
(
mContext
as
Activity
,
tellData
=
TellData
())
.
getJavascripHandler
(
mContext
as
Activity
,
wv_content
,
tellData
=
TellData
())
val
url
=
WebUrlParamsUtils
.
getSuffix
(
jumpUrl
,
jtoJHandle
.
getUriAppendSuffix
())
wv_content
.
loadUrl
(
url
)
}
...
...
@@ -134,7 +133,7 @@ class ExpertConsultWebview : RelativeLayout {
wv_content
!!
.
scrollBarStyle
=
View
.
SCROLLBARS_INSIDE_OVERLAY
//滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
val
jtoJHandle
=
WebModularServiceUtils
.
getWebService
()
.
getJavascripHandler
(
mContext
as
Activity
,
tellData
=
TellData
())
.
getJavascripHandler
(
mContext
as
Activity
,
wv_content
,
tellData
=
TellData
())
wv_content
!!
.
addJavascriptInterface
(
jtoJHandle
,
"javascriptHandler"
)
val
url
=
WebUrlParamsUtils
.
getSuffix
(
jumpUrl
,
jtoJHandle
.
getUriAppendSuffix
())
...
...
m-muse/src/main/java/com/yidianling/muse/activity/ChooseMusicActivity.kt
View file @
613d0d77
...
...
@@ -62,7 +62,7 @@ class ChooseMusicActivity : BaseActivity() {
super
.
onCreate
(
savedInstanceState
)
getParam
()
var
tellData
=
TellData
()
jtoJHandle
=
getWebService
().
getJavascripHandler
(
this
,
tellData
.
also
{
tellData
=
it
})
jtoJHandle
=
getWebService
().
getJavascripHandler
(
this
,
null
,
tellData
.
also
{
tellData
=
it
})
initView
()
}
...
...
ydl-webview/src/main/gen/com/ydl/webview/BuildConfig.java
deleted
100644 → 0
View file @
60a45ede
/*___Generated_by_IDEA___*/
package
com
.
ydl
.
webview
;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public
final
class
BuildConfig
{
public
final
static
boolean
DEBUG
=
Boolean
.
parseBoolean
(
null
);
}
\ No newline at end of file
ydl-webview/src/main/gen/com/ydl/webview/Manifest.java
deleted
100644 → 0
View file @
60a45ede
/*___Generated_by_IDEA___*/
package
com
.
ydl
.
webview
;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public
final
class
Manifest
{
}
\ No newline at end of file
ydl-webview/src/main/gen/com/ydl/webview/R.java
deleted
100644 → 0
View file @
60a45ede
/*___Generated_by_IDEA___*/
package
com
.
ydl
.
webview
;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public
final
class
R
{
}
\ No newline at end of file
ydl-webview/src/main/java/com/ydl/webview/IWebService.kt
View file @
613d0d77
...
...
@@ -2,11 +2,12 @@ package com.ydl.webview
import
android.app.Activity
import
com.alibaba.android.arouter.facade.template.IProvider
import
com.tencent.smtt.sdk.WebView
/**
* Created by haorui on 2019-10-10.
* Des:
*/
interface
IWebService
:
IProvider
{
fun
getJavascripHandler
(
activity
:
Activity
,
tellData
:
TellData
):
IJavascriptHandler
fun
getJavascripHandler
(
activity
:
Activity
,
webView
:
WebView
?,
tellData
:
TellData
):
IJavascriptHandler
}
ydl-webview/src/main/java/com/ydl/webview/NewH5Activity.java
View file @
613d0d77
...
...
@@ -394,7 +394,7 @@ public class NewH5Activity extends BaseActivity implements PtrHandler {
setUrlHeightParams
();
EventBus
.
getDefault
().
register
(
this
);
jtoJHandle
=
WebModularServiceUtils
.
Companion
.
getWebService
().
getJavascripHandler
(
this
,
tellData
=
tellData
);
jtoJHandle
=
WebModularServiceUtils
.
Companion
.
getWebService
().
getJavascripHandler
(
this
,
wv_content
,
tellData
);
init
();
if
(
startType
==
1
)
{
...
...
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