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
acdb275d
Commit
acdb275d
authored
May 19, 2022
by
霍志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:bottomSheet改为bottomSheetDialogFragment
parent
de606ea3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
105 deletions
+209
-105
ConfideBottomSheetDialogFragment.kt
m-confide/src/main/java/com/ydl/confide/home/ConfideBottomSheetDialogFragment.kt
+185
-0
ConfideHomeEventImpl.kt
m-confide/src/main/java/com/ydl/confide/home/event/ConfideHomeEventImpl.kt
+4
-103
confide_bottom_webview.xml
m-confide/src/main/res/drawable/confide_bottom_webview.xml
+10
-0
styles.xml
m-confide/src/main/res/values/styles.xml
+10
-2
No files found.
m-confide/src/main/java/com/ydl/confide/home/ConfideBottomSheetDialogFragment.kt
0 → 100644
View file @
acdb275d
package
com.ydl.confide.home
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Dialog
import
android.os.Bundle
import
android.view.*
import
android.widget.FrameLayout
import
com.google.android.material.bottomsheet.BottomSheetBehavior
import
com.google.android.material.bottomsheet.BottomSheetDialog
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
import
com.tencent.smtt.sdk.WebSettings
import
com.ydl.confide.R
import
com.ydl.webview.ProgressWebView
import
com.ydl.webview.TellData
import
com.ydl.webview.WebModularServiceUtils
import
com.ydl.ydlcommon.base.BaseActivity
import
com.yidianling.common.tools.RxImageTool
class
ConfideBottomSheetDialogFragment
:
BottomSheetDialogFragment
()
{
lateinit
var
activity
:
BaseActivity
;
lateinit
var
wv_content
:
ProgressWebView
;
lateinit
var
text_title
:
View
;
lateinit
var
line
:
View
;
lateinit
var
rl_title
:
View
;
lateinit
var
close_webview_Icon
:
View
;
fun
showBottomSheetDialog
(
activity
:
BaseActivity
)
{
this
.
activity
=
activity
show
(
activity
.
supportFragmentManager
,
"confide_bottom_showdialog"
)
}
@SuppressLint
(
"WrongConstant"
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setStyle
(
STYLE_NORMAL
,
R
.
style
.
AppBottomSheet
)
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
{
return
inflater
.
inflate
(
R
.
layout
.
confide_webview
,
container
,
false
)
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
wv_content
=
view
.
findViewById
<
ProgressWebView
>(
com
.
ydl
.
webview
.
R
.
id
.
wv_content
)
close_webview_Icon
=
view
.
findViewById
<
View
>(
R
.
id
.
close_webview_Icon
)
text_title
=
view
.
findViewById
<
View
>(
R
.
id
.
text_title
)
line
=
view
.
findViewById
<
View
>(
R
.
id
.
line
)
rl_title
=
view
.
findViewById
<
View
>(
R
.
id
.
rl_title
)
close_webview_Icon
?.
setOnClickListener
{
this
.
dismiss
()
}
webViewInit
(
wv_content
)
}
override
fun
setCancelable
(
cancelable
:
Boolean
)
{
val
dialog
=
dialog
val
touchOutsideView
=
dialog
?.
window
?.
decorView
?.
findViewById
<
View
>(
com
.
google
.
android
.
material
.
R
.
id
.
touch_outside
)
val
bottomSheetView
=
dialog
?.
window
?.
decorView
?.
findViewById
<
View
>(
com
.
google
.
android
.
material
.
R
.
id
.
design_bottom_sheet
)
val
itemView
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
confide_bottom_two
,
null
,
false
)
val
layoutCall
=
itemView
.
findViewById
<
View
>(
R
.
id
.
layoutCall
)
val
layoutChange
=
itemView
.
findViewById
<
View
>(
R
.
id
.
layoutChange
)
val
layout_change_text
=
itemView
.
findViewById
<
View
>(
R
.
id
.
layout_change_text
)
val
confide_progress
=
itemView
.
findViewById
<
View
>(
R
.
id
.
confide_progress
)
layoutCall
.
setOnClickListener
{
callJsFun
(
wv_content
,
"layoutCall()"
)
}
layoutChange
.
setOnClickListener
{
layout_change_text
.
visibility
=
View
.
GONE
confide_progress
.
visibility
=
View
.
VISIBLE
callJsFun
(
wv_content
,
"layoutCall()"
)
}
val
layoutParams
=
FrameLayout
.
LayoutParams
(
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
,
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
).
apply
{
gravity
=
Gravity
.
BOTTOM
or
Gravity
.
CENTER_HORIZONTAL
}
dialog
?.
window
?.
addContentView
(
itemView
,
layoutParams
)
if
(
cancelable
)
{
touchOutsideView
?.
setOnClickListener
(
View
.
OnClickListener
{
if
(
dialog
.
isShowing
)
{
dialog
.
cancel
()
}
})
BottomSheetBehavior
.
from
<
View
>(
bottomSheetView
!!
).
setHideable
(
true
)
}
else
{
touchOutsideView
?.
setOnClickListener
(
null
)
// if false 按返回键也无法取消
// dialog.setCancelable(false)
BottomSheetBehavior
.
from
<
View
>(
bottomSheetView
!!
).
setHideable
(
false
)
}
}
override
fun
onCreateDialog
(
savedInstanceState
:
Bundle
?):
Dialog
{
val
dialog
=
super
.
onCreateDialog
(
savedInstanceState
)
as
BottomSheetDialog
dialog
.
setOnShowListener
{
val
bottomSheet
=
(
it
as
BottomSheetDialog
).
findViewById
<
View
>(
com
.
google
.
android
.
material
.
R
.
id
.
design_bottom_sheet
)
as
FrameLayout
?
val
behavior
=
BottomSheetBehavior
.
from
(
bottomSheet
!!
)
behavior
.
peekHeight
=
RxImageTool
.
dp2px
(
800f
)
//true是跳过peekHeight,直接滑下去,false是可以滑动到顶部还可以保持peekHeight在滑下去
// behavior?.skipCollapsed=true
behavior
.
addBottomSheetCallback
(
object
:
BottomSheetBehavior
.
BottomSheetCallback
()
{
override
fun
onStateChanged
(
bottomSheet
:
View
,
newState
:
Int
)
{
when
(
newState
)
{
3
->
{
rl_title
?.
visibility
=
View
.
VISIBLE
close_webview_Icon
?.
visibility
=
View
.
VISIBLE
text_title
?.
visibility
=
View
.
VISIBLE
line
?.
visibility
=
View
.
GONE
}
1
->
{
rl_title
?.
visibility
=
View
.
VISIBLE
close_webview_Icon
?.
visibility
=
View
.
GONE
text_title
?.
visibility
=
View
.
GONE
line
?.
visibility
=
View
.
VISIBLE
}
4
->
{
rl_title
?.
visibility
=
View
.
VISIBLE
line
?.
visibility
=
View
.
VISIBLE
}
}
}
override
fun
onSlide
(
bottomSheet
:
View
,
slideOffset
:
Float
)
{}
})
}
return
dialog
}
private
fun
callJsFun
(
wv_content
:
ProgressWebView
,
funcName
:
String
)
{
val
sb
=
StringBuffer
(
"javascript:"
)
sb
.
append
(
funcName
)
wv_content
.
post
{
try
{
wv_content
.
loadUrl
(
sb
.
toString
())
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
@SuppressLint
(
"ClickableViewAccessibility"
)
private
fun
webViewInit
(
wv_content
:
ProgressWebView
)
{
val
setting
:
WebSettings
=
wv_content
?.
settings
!!
//支持js
//支持js
setting
.
setJavaScriptEnabled
(
true
)
//设置字符编码
//设置字符编码
setting
.
setDefaultTextEncodingName
(
"GBK"
)
setting
.
setDomStorageEnabled
(
true
)
val
appCachePath
:
String
=
activity
?.
getCacheDir
()
?.
getAbsolutePath
().
toString
()
setting
.
setAppCachePath
(
appCachePath
)
setting
.
setAllowFileAccessFromFileURLs
(
true
)
setting
.
setAppCacheEnabled
(
true
)
setting
.
setAllowFileAccess
(
true
)
// 解决图片不显示
// 解决图片不显示
setting
.
setBlockNetworkImage
(
false
)
wv_content
!!
.
scrollBarStyle
=
View
.
SCROLLBARS_INSIDE_OVERLAY
//滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
var
jtoJHandle
=
WebModularServiceUtils
.
getWebService
()
.
getJavascripHandler
(
activity
as
Activity
,
tellData
=
TellData
())
wv_content
!!
.
addJavascriptInterface
(
jtoJHandle
,
"javascriptHandler"
)
wv_content
.
loadUrl
(
"https://m.ydl.com/jy/experts/23035?v=4.0.99&uid=9404770&ts=1652787528&toConfide=1&"
+
"platform_main_theme_light=00D4DF&platform_main_theme_bright=EAFAFC&platform_main_theme=00C9E2&isFromApp=1&"
+
"id=1927&ffrom=android_zhuzhan&barHeight=81&accessToken=87cba5b57f9bb196856ade3522805c11MjIwMw&sign="
+
"6ce496690d7d5a184935f986c3631cc2"
)
wv_content
.
setOnTouchListener
{
p0
,
p1
->
//canScrollVertically(-1)的值表示是否能向下滚动,false表示已经滚动到顶部
if
(!
wv_content
.
canScrollVertically
(-
1
))
{
wv_content
.
requestDisallowInterceptTouchEvent
(
false
);
}
else
{
wv_content
.
requestDisallowInterceptTouchEvent
(
true
);
}
false
;
}
}
}
\ No newline at end of file
m-confide/src/main/java/com/ydl/confide/home/event/ConfideHomeEventImpl.kt
View file @
acdb275d
...
...
@@ -19,6 +19,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import
com.tencent.smtt.sdk.WebSettings
import
com.ydl.confide.R
import
com.ydl.confide.api.ConfideRoute
import
com.ydl.confide.home.ConfideBottomSheetDialogFragment
import
com.ydl.confide.home.ConfideHomeActivity
import
com.ydl.confide.home.adapter.ConfideHomeAdapter
import
com.ydl.confide.home.bean.ConfideHomeAllFiltersBean
...
...
@@ -144,112 +145,12 @@ class ConfideHomeEventImpl(context: Context, var confideHomeView: IConfideHomeCo
*/
@SuppressLint
(
"JavascriptInterface"
,
"ClickableViewAccessibility"
)
override
fun
consultantClick
(
linkUrl
:
String
?)
{
val
bottomSheetDialog
=
mContext
?.
let
{
BottomSheetDialog
(
it
,
R
.
style
.
CustomShapeAppearanceBottomSheetDialog
)
}
val
bottomView
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
confide_webview
,
FrameLayout
(
mContext
),
false
)
bottomSheetDialog
?.
setContentView
(
bottomView
)
bottomSheetDialog
?.
show
()
var
wv_content
=
bottomSheetDialog
?.
findViewById
<
ProgressWebView
>(
com
.
ydl
.
webview
.
R
.
id
.
wv_content
)
var
close_webview_Icon
=
bottomSheetDialog
?.
findViewById
<
View
>(
R
.
id
.
close_webview_Icon
)
var
text_title
=
bottomSheetDialog
?.
findViewById
<
View
>(
R
.
id
.
text_title
)
var
line
=
bottomSheetDialog
?.
findViewById
<
View
>(
R
.
id
.
line
)
var
rl_title
=
bottomSheetDialog
?.
findViewById
<
View
>(
R
.
id
.
rl_title
)
close_webview_Icon
?.
setOnClickListener
{
bottomSheetDialog
?.
hide
()
}
val
setting
:
WebSettings
=
wv_content
?.
settings
!!
//支持js
//支持js
setting
.
setJavaScriptEnabled
(
true
)
//设置字符编码
//设置字符编码
setting
.
setDefaultTextEncodingName
(
"GBK"
)
setting
.
setDomStorageEnabled
(
true
)
val
appCachePath
:
String
=
mContext
?.
getCacheDir
()
?.
getAbsolutePath
().
toString
()
setting
.
setAppCachePath
(
appCachePath
)
setting
.
setAllowFileAccessFromFileURLs
(
true
)
setting
.
setAppCacheEnabled
(
true
)
setting
.
setAllowFileAccess
(
true
)
// 解决图片不显示
// 解决图片不显示
setting
.
setBlockNetworkImage
(
false
)
wv_content
!!
.
scrollBarStyle
=
View
.
SCROLLBARS_INSIDE_OVERLAY
//滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
var
jtoJHandle
=
getWebService
().
getJavascripHandler
(
mContext
as
Activity
,
tellData
=
TellData
())
wv_content
!!
.
addJavascriptInterface
(
jtoJHandle
,
"javascriptHandler"
)
bottomSheetDialog
?.
behavior
?.
peekHeight
=
1500
bottomSheetDialog
?.
behavior
?.
addBottomSheetCallback
(
object
:
BottomSheetBehavior
.
BottomSheetCallback
(){
override
fun
onStateChanged
(
p0
:
View
,
p1
:
Int
)
{
LogUtil
.
e
(
"aaaa"
+
p1
)
if
(
p1
==
3
){
rl_title
?.
visibility
=
View
.
VISIBLE
close_webview_Icon
?.
visibility
=
View
.
VISIBLE
text_title
?.
visibility
=
View
.
VISIBLE
line
?.
visibility
=
View
.
GONE
}
else
if
(
p1
==
1
){
rl_title
?.
visibility
=
View
.
VISIBLE
close_webview_Icon
?.
visibility
=
View
.
GONE
text_title
?.
visibility
=
View
.
GONE
line
?.
visibility
=
View
.
VISIBLE
}
else
if
(
p1
==
4
){
rl_title
?.
visibility
=
View
.
VISIBLE
line
?.
visibility
=
View
.
VISIBLE
}
}
override
fun
onSlide
(
p0
:
View
,
p1
:
Float
)
{
}
ConfideBottomSheetDialogFragment
()
.
showBottomSheetDialog
(
mContext
as
BaseActivity
)
})
val
itemView
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
confide_bottom_two
,
null
,
false
)
val
layoutCall
=
itemView
.
findViewById
<
View
>(
R
.
id
.
layoutCall
)
val
layoutChange
=
itemView
.
findViewById
<
View
>(
R
.
id
.
layoutChange
)
val
layout_change_text
=
itemView
.
findViewById
<
View
>(
R
.
id
.
layout_change_text
)
val
confide_progress
=
itemView
.
findViewById
<
View
>(
R
.
id
.
confide_progress
)
layoutCall
.
setOnClickListener
{
callJsFun
(
wv_content
,
"layoutCall()"
)
}
layoutChange
.
setOnClickListener
{
layout_change_text
.
visibility
=
View
.
GONE
confide_progress
.
visibility
=
View
.
VISIBLE
callJsFun
(
wv_content
,
"layoutCall()"
)
}
val
layoutParams
=
FrameLayout
.
LayoutParams
(
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
,
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
).
apply
{
gravity
=
Gravity
.
BOTTOM
or
Gravity
.
CENTER_HORIZONTAL
}
bottomSheetDialog
?.
window
?.
addContentView
(
itemView
,
layoutParams
)
//true是跳过peekHeight,直接滑下去,false是可以滑动到顶部还可以保持peekHeight在滑下去
// bottomSheetDialog?.behavior?.skipCollapsed=true
wv_content
.
loadUrl
(
"https://m.ydl.com/jy/experts/23035?v=4.0.99&uid=9404770&ts=1652787528&toConfide=1&"
+
"platform_main_theme_light=00D4DF&platform_main_theme_bright=EAFAFC&platform_main_theme=00C9E2&isFromApp=1&"
+
"id=1927&ffrom=android_zhuzhan&barHeight=81&accessToken=87cba5b57f9bb196856ade3522805c11MjIwMw&sign="
+
"6ce496690d7d5a184935f986c3631cc2"
)
wv_content
.
setOnTouchListener
(
object
:
View
.
OnTouchListener
{
override
fun
onTouch
(
p0
:
View
?,
p1
:
MotionEvent
?):
Boolean
{
//canScrollVertically(-1)的值表示是否能向下滚动,false表示已经滚动到顶部
if
(!
wv_content
.
canScrollVertically
(-
1
))
{
wv_content
.
requestDisallowInterceptTouchEvent
(
false
);
}
else
{
wv_content
.
requestDisallowInterceptTouchEvent
(
true
);
}
return
false
;
}
})
// link(linkUrl)
}
private
fun
callJsFun
(
wv_content
:
ProgressWebView
,
funcName
:
String
)
{
val
sb
=
StringBuffer
(
"javascript:"
)
sb
.
append
(
funcName
)
wv_content
.
post
{
try
{
wv_content
.
loadUrl
(
sb
.
toString
())
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
}
override
fun
videoShowClick
(
index
:
Int
,
data
:
List
<
ConfideHomeBodyBean
>?)
{
val
dataJson
=
if
(
data
!=
null
)
JSON
.
toJSONString
(
data
)
else
null
...
...
m-confide/src/main/res/drawable/confide_bottom_webview.xml
0 → 100644
View file @
acdb275d
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item>
<shape
android:shape=
"rectangle"
>
<solid
android:color=
"@android:color/white"
/>
<corners
android:topLeftRadius=
"15dp"
android:topRightRadius=
"15dp"
/>
</shape>
</item>
</selector>
\ No newline at end of file
m-confide/src/main/res/values/styles.xml
View file @
acdb275d
...
...
@@ -10,7 +10,9 @@
<item
name=
"colorPrimaryDark"
>
@color/platform_main_theme
</item>
<item
name=
"colorAccent"
>
@color/platform_main_theme
</item>
</style>
<style
name=
"confide_dialog"
parent=
"Theme.MaterialComponents.Light.BottomSheetDialog"
>
<!-- Customize your theme here. -->
</style>
<style
name=
"CustomShapeAppearanceBottomSheetDialog"
parent=
"Theme.MaterialComponents.Light.BottomSheetDialog"
>
<item
name=
"cornerFamily"
>
rounded
</item>
<item
name=
"cornerSizeTopRight"
>
16dp
</item>
...
...
@@ -18,6 +20,11 @@
<item
name=
"cornerSizeBottomRight"
>
0dp
</item>
<item
name=
"cornerSizeBottomLeft"
>
0dp
</item>
<item
name=
"background"
>
@color/transparent
</item>
</style>
<style
name=
"AppBottomSheet"
parent=
"Theme.Design.Light.BottomSheetDialog"
>
<item
name=
"bottomSheetStyle"
>
@style/AppBottomSheetStyle
</item>
</style>
<style
name=
"AppBottomSheetStyle"
parent=
"Widget.Design.BottomSheet.Modal"
>
<item
name=
"android:background"
>
@drawable/confide_bottom_webview
</item>
</style>
</resources>
\ No newline at end of file
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