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
31597ce1
Commit
31597ce1
authored
May 13, 2022
by
万齐军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: 倾诉2.0视频播放网络检查
parent
080ea869
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
6 deletions
+64
-6
ExpertIntroActivity.kt
m-confide/src/main/java/com/ydl/confide/intro/ExpertIntroActivity.kt
+3
-1
IntroAdapter.kt
m-confide/src/main/java/com/ydl/confide/intro/IntroAdapter.kt
+50
-2
ItemIntroHolder.kt
m-confide/src/main/java/com/ydl/confide/intro/ItemIntroHolder.kt
+9
-3
strings.xml
m-confide/src/main/res/values/strings.xml
+2
-0
No files found.
m-confide/src/main/java/com/ydl/confide/intro/ExpertIntroActivity.kt
View file @
31597ce1
...
...
@@ -12,6 +12,8 @@ import com.alibaba.android.arouter.facade.annotation.Route
import
com.ydl.confide.R
import
com.ydl.confide.api.ConfideRoute
import
com.ydl.confide.databinding.ActivityExpertIntroBinding
import
com.ydl.confide.home.util.ConfideNetworkUtil
import
com.ydl.ydlcommon.view.dialog.CommonDialog
@Route
(
path
=
ConfideRoute
.
R_VIDEO_SHOW
)
...
...
@@ -54,7 +56,7 @@ class ExpertIntroActivity : AppCompatActivity() {
}
}
})
adapter
.
checkNetwork
()
}
private
fun
loadMore
()
{
...
...
m-confide/src/main/java/com/ydl/confide/intro/IntroAdapter.kt
View file @
31597ce1
package
com.ydl.confide.intro
import
android.app.Activity
import
android.content.Context
import
android.net.Uri
import
android.util.Log
...
...
@@ -14,6 +15,8 @@ import androidx.recyclerview.widget.RecyclerView
import
com.dou361.ijkplayer.widget.IjkVideoView
import
com.ydl.confide.R
import
com.ydl.confide.databinding.ItemExpertIntroBinding
import
com.ydl.confide.home.util.ConfideNetworkUtil
import
com.ydl.ydlcommon.view.dialog.CommonDialog
internal
class
IntroAdapter
(
private
val
context
:
Context
,
...
...
@@ -23,6 +26,10 @@ internal class IntroAdapter(
private
val
videoViews
=
hashMapOf
<
Int
,
IjkVideoView
>()
private
var
hasAgreePlayWithoutWiFi
=
false
private
var
curPos
=
0
init
{
lifecycleOwner
.
lifecycle
.
addObserver
(
this
)
}
...
...
@@ -49,11 +56,49 @@ internal class IntroAdapter(
override
fun
onViewAttachedToWindow
(
holder
:
ItemIntroHolder
)
{
val
adapterPosition
=
holder
.
adapterPosition
val
videoView
=
IjkVideoView
(
context
)
videoView
.
setVideoURI
(
Uri
.
parse
(
"https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"
))
if
(
hasAgreePlayWithoutWiFi
||
ConfideNetworkUtil
.
isWifi
(
context
))
{
videoView
.
setVideoURI
(
Uri
.
parse
(
"https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"
))
}
else
{
data
[
adapterPosition
].
playUrl
?.
let
{
videoView
.
tag
=
it
}
}
videoViews
.
put
(
adapterPosition
,
videoView
)
holder
.
onAttach
(
videoView
)
}
internal
fun
checkNetwork
()
{
if
(!
ConfideNetworkUtil
.
isWifi
(
context
))
{
val
dialog
=
CommonDialog
.
create
(
context
)
.
setTitle
(
context
.
getString
(
R
.
string
.
confide_tip
))
.
setMessage
(
context
.
getString
(
R
.
string
.
confide_video_wifi_tip
))
.
setLeftOnclick
(
"继续播放"
)
{
hasAgreePlayWithoutWiFi
=
true
for
(
entry
in
videoViews
.
entries
)
{
val
value
=
entry
.
value
(
value
.
tag
as
?
String
)
?.
let
{
value
.
setVideoURI
(
Uri
.
parse
(
it
))
if
(
curPos
==
entry
.
key
)
{
value
.
start
()
}
}
}
}
.
setLeftButton_color
(
R
.
color
.
platform_but_text_color_selected
)
.
setRightButton_color
(
R
.
color
.
platform_text_bright_color
)
.
setRightClick
(
"取消"
)
{
if
(
context
is
Activity
)
{
context
.
onBackPressed
()
}
}
.
setCancelAble
(
true
)
dialog
.
setOnCancelListener
{
if
(
context
is
Activity
)
{
context
.
onBackPressed
()
}
}
dialog
.
show
()
}
}
override
fun
onViewDetachedFromWindow
(
holder
:
ItemIntroHolder
)
{
super
.
onViewDetachedFromWindow
(
holder
)
val
adapterPosition
=
holder
.
adapterPosition
...
...
@@ -76,7 +121,10 @@ internal class IntroAdapter(
}
fun
onSelect
(
position
:
Int
)
{
Log
.
i
(
"qwe"
,
""
+
videoViews
.
size
)
curPos
=
position
if
(!
ConfideNetworkUtil
.
isWifi
(
context
)
&&
!
hasAgreePlayWithoutWiFi
)
{
return
}
for
(
entry
in
videoViews
.
entries
)
{
if
(
entry
.
key
==
position
)
{
entry
.
value
.
seekTo
(
0
)
...
...
m-confide/src/main/java/com/ydl/confide/intro/ItemIntroHolder.kt
View file @
31597ce1
...
...
@@ -3,7 +3,6 @@ package com.ydl.confide.intro
import
android.util.Log
import
android.view.View
import
android.widget.SeekBar
import
androidx.databinding.ObservableBoolean
import
androidx.databinding.ObservableField
import
androidx.databinding.ObservableInt
import
androidx.databinding.ViewDataBinding
...
...
@@ -22,6 +21,10 @@ import java.util.concurrent.TimeUnit
internal
class
ItemIntroHolder
(
binding
:
ItemExpertIntroBinding
)
:
BindingViewHolder
<
ItemExpertIntroBinding
>(
binding
),
LifecycleObserver
{
companion
object
{
private
const
val
TAG
=
"ItemIntroHolder"
}
private
var
disposable
:
Disposable
?
=
null
private
var
video
:
IjkVideoView
?
=
null
...
...
@@ -65,7 +68,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
this
.
video
=
videoView
binding
.
videoView
.
addView
(
videoView
)
video
?.
setOnPreparedListener
{
player
->
Log
.
d
(
"qweqwe"
,
"${player.videoHeight},${player.videoWidth},${player.duration}"
)
Log
.
d
(
TAG
,
"${player.videoHeight},${player.videoWidth},${player.duration}"
)
val
duration
=
player
.
duration
.
toInt
()
if
(
duration
>
0
)
{
binding
.
seekbar
.
max
=
duration
...
...
@@ -74,7 +77,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
}
video
?.
setOnInfoListener
{
mp
,
what
,
extra
->
Log
.
d
(
"qweqwe"
,
"${what},${extra}"
)
Log
.
d
(
TAG
,
"${what},${extra}"
)
return
@setOnInfoListener
false
}
video
?.
setOnCompletionListener
{
stopTiming
()
}
...
...
@@ -115,6 +118,9 @@ class VideoViewModel {
val
count
=
ObservableInt
()
val
intro
=
ObservableField
<
String
>(
""
)
val
tag
=
ObservableField
<
String
>(
""
)
var
playUrl
:
String
?
=
"https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"
var
coverUrl
:
String
?
=
null
var
isVideo
=
true
}
...
...
m-confide/src/main/res/values/strings.xml
View file @
31597ce1
<resources>
<string
name=
"confide_title"
>
即时倾诉
</string>
<string
name=
"confide_video_wifi_tip"
>
当前处于非wifi环境下,播放会消耗流量,确定继续播放?
</string>
<string
name=
"confide_tip"
>
提示
</string>
</resources>
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