Commit 123bc6a5 by 万齐军

feature: 视频播放

parent 53610264
......@@ -15,7 +15,7 @@ import com.ydl.confide.intro.BindingViewHolder
class VideoShowAdapter(private val data: List<ConfideHomeBodyBean>?, private val event: IConfideHomeEvent) :
RecyclerView.Adapter<BindingViewHolder<ItemVideoShowBinding>>() {
private val dataList:List<ItemVideoShowViewModel> = data?.map { ItemVideoShowViewModel().mapOf(it) } ?: emptyList()
private val dataList: List<ItemVideoShowViewModel> = data?.map { ItemVideoShowViewModel().mapOf(it) } ?: emptyList()
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
......@@ -74,7 +74,7 @@ internal fun ItemVideoShowViewModel.mapOf(bean: ConfideHomeBodyBean): ItemVideoS
name.set(bean.confidedName)
coverUrl.set(bean.coverPicture)
videoCoverUrl.set(bean.coverVideoPicture)
state.set(bean.confideLine?:0)
state.set(bean.confideLine ?: 0)
linkUrl = bean.linkUrl
return this
}
......
......@@ -67,11 +67,6 @@ class ExpertIntroActivity : AppCompatActivity() {
val h5Paramsqing = H5Params(YDL_H5 + "confideOrderList", null)
NewH5Activity.start(this, h5Paramsqing)
}
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
binding.viewPager.orientation = ViewPager2.ORIENTATION_VERTICAL
binding.viewPager.offscreenPageLimit = 1
adapter = IntroAdapter(this, data, this)
......@@ -89,11 +84,11 @@ class ExpertIntroActivity : AppCompatActivity() {
}
private fun loadMore() {
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
data.add(VideoViewModel())
adapter.notifyItemRangeInserted(data.size - 5, 5)
// data.add(VideoViewModel())
// data.add(VideoViewModel())
// data.add(VideoViewModel())
// data.add(VideoViewModel())
// data.add(VideoViewModel())
// adapter.notifyItemRangeInserted(data.size - 5, 5)
}
}
\ No newline at end of file
......@@ -29,6 +29,8 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
private var disposable: Disposable? = null
private var video: IjkVideoView? = null
@Volatile
private var isTouch = false
fun onDetach() {
stopTiming()
......@@ -66,9 +68,11 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
isTouch = true
}
override fun onStopTrackingTouch(seekBar: SeekBar?) {
isTouch = false
if (seekBar != null) {
video?.seekTo(seekBar.progress)
video?.start()
......@@ -102,6 +106,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
disposable = Observable.interval(300, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.computation())
.filter { !isTouch }
.subscribe {
val pos = (video?.mMediaPlayer as IjkMediaPlayer?)?.currentPosition ?: 0
if (pos > 0) {
......@@ -118,7 +123,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
class VideoViewModel {
val name = ObservableField<String>("")
val avatar = ObservableField<String>("")
val count = ObservableInt()
val count = ObservableField<String>("")
val lineStatus = ObservableInt()
val intro = ObservableField<String>("")
val tag = ObservableField<String>("")
......@@ -132,10 +137,10 @@ class VideoViewModel {
internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel {
name.set(bean.confidedName)
avatar.set(bean.confidedIcon)
// count.set(bean.confideHearNum)
intro.set(bean.categoryContent)
count.set(bean.confideHearNum)
intro.set(bean.confideContent)
val sb = StringBuilder()
bean.confidedTag?.forEach { sb.append(it).append("|") }
bean.confidedTag?.forEach { sb.append(it).append(" | ") }
sb.setLength(sb.length - 1)
tag.set(sb.toString())
if (bean.videoUrl != null) {
......
......@@ -2,10 +2,22 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="4dp" />
<solid android:color="#59FFFFFF" />
</shape>
<selector>
<item android:state_pressed="true">
<shape>
<corners android:radius="4dp" />
<solid android:color="#59FFFFFF" />
<stroke android:width="1dp" />
</shape>
</item>
<item>
<shape>
<corners android:radius="4dp" />
<solid android:color="#59FFFFFF" />
<stroke android:width="2dp" />
</shape>
</item>
</selector>
</item>
<item android:id="@android:id/secondaryProgress">
......@@ -18,12 +30,26 @@
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/white" />
</shape>
</clip>
<selector>
<item android:state_pressed="true">
<clip>
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/white" />
<stroke android:width="1dp" />
</shape>
</clip>
</item>
<item>
<clip>
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/white" />
<stroke android:width="2dp" />
</shape>
</clip>
</item>
</selector>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<size android:width="6dp" android:height="6dp" />
<size android:width="6dp" android:height="8dp" />
<corners android:radius="2dp" />
</shape>
</item>
<item>
<item android:state_pressed="false">
<shape android:shape="oval">
<solid android:color="@color/white" />
<size android:width="6dp" android:height="6dp" />
<size android:width="8dp" android:height="8dp" />
<stroke android:width="2dp" android:color="@color/transparent" />
</shape>
</item>
</selector>
\ No newline at end of file
......@@ -52,11 +52,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="23dp"
android:maxHeight="4dp"
android:maxHeight="8dp"
android:paddingStart="0dp"
android:paddingTop="4dp"
android:paddingEnd="0dp"
android:paddingBottom="4dp"
android:progressDrawable="@drawable/confide_seekbar_style"
android:splitTrack="false"
android:thumb="@drawable/confide_seekbar_thumb"
......@@ -146,6 +144,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:text="@{item.count}"
android:textSize="13sp"
app:layout_constraintBottom_toBottomOf="@+id/tvName"
app:layout_constraintLeft_toRightOf="@+id/tvName"
......@@ -201,6 +200,7 @@
android:layout_height="46dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="20dp"
app:circle="@{true}"
app:imageUrl="@{item.avatar}"
app:layout_constraintBottom_toTopOf="@+id/btnChat"
app:layout_constraintRight_toRightOf="parent" />
......
......@@ -7,10 +7,14 @@ import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.ydl.ydl_image.module.GlideApp
@BindingAdapter("imageUrl")
fun setImageUrl(imageView: ImageView, url: String?) {
@BindingAdapter("imageUrl", "circle", requireAll = false)
fun setImageUrl(imageView: ImageView, url: String?, circle: Boolean = false) {
if (url.isNullOrEmpty()) return
GlideApp.with(imageView).load(url).into(imageView)
if (circle) {
GlideApp.with(imageView).load(url).circleCrop().into(imageView)
} else {
GlideApp.with(imageView).load(url).into(imageView)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment