Commit 94eeae82 by 万齐军

feature: 呼叫按钮的状态

parent 7da17db6
package com.ydl.confide.home.bean
class DialStatus {
var confideLine: Int? = null
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.ydl.confide.home.http
import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.bean.DialStatus
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
......@@ -33,4 +34,8 @@ interface ConfideHomeApi {
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("auth/listen/dial")
fun connectJava(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ConfideConnectResponse>>
// 1=在线 3-通话中 2-离线
@GET("auth/listen/dialchangestatus")
fun getDialStatus(@Query("doctorId") doctorId: String): Observable<BaseAPIResponse<DialStatus>>
}
\ No newline at end of file
package com.ydl.confide.home.util
import android.widget.TextView
import androidx.databinding.BindingAdapter
@BindingAdapter("confideLineText")
fun TextView.confideLineText(line: Int) {
when (line) {
1 -> {
text = "立即拨打"
}
2 -> {
text = "已离线"
}
3 -> {
text = "通话中"
}
}
}
\ No newline at end of file
......@@ -15,8 +15,14 @@ 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.http.ConfideHomeApi
import com.ydl.confide.home.util.ConfideNetworkUtil
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
internal class IntroAdapter(
private val context: Context,
......@@ -30,6 +36,8 @@ internal class IntroAdapter(
private var curPos = 0
private var dispose: Disposable? = null
init {
lifecycleOwner.lifecycle.addObserver(this)
}
......@@ -132,6 +140,24 @@ internal class IntroAdapter(
fun onSelect(position: Int) {
curPos = position
val confideApi = YDLHttpUtils.obtainApi(ConfideHomeApi::class.java)
val curUid = data[position].uid
if (curUid != null) {
dispose?.dispose()
dispose = confideApi.getDialStatus(curUid)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
if (resp.code == "200") {
val lineStatus = resp.data?.confideLine ?: 2
data[position].lineStatus.set(lineStatus)
} else {
if (!resp.msg.isNullOrEmpty()) {
ToastUtil.toastShort(resp.msg)
}
}
}, { throwable -> throwable.printStackTrace() })
}
if (!ConfideNetworkUtil.isWifi(context) && !hasAgreePlayWithoutWiFi) {
return
}
......
......@@ -36,7 +36,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
}
fun onBind(item: VideoViewModel) {
binding.btnCall.setOnClickListener { }
binding.layoutCall.setOnClickListener { }
binding.btnChat.setOnClickListener {
val aty = it.context as? Activity
if (aty != null && !item.uid.isNullOrEmpty()) {
......@@ -119,6 +119,7 @@ class VideoViewModel {
val name = ObservableField<String>("")
val avatar = ObservableField<String>("")
val count = ObservableInt()
val lineStatus = ObservableInt()
val intro = ObservableField<String>("")
val tag = ObservableField<String>("")
var playUrl: String? = null//"https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4"
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="26dp" />
<gradient
android:endColor="#48CC95"
android:startColor="#61CEAC" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="26dp" />
<gradient
android:endColor="#BBC1CD"
android:startColor="#D5D6D7" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="26dp" />
<gradient
android:endColor="#FF994B"
android:startColor="#F6B37F" />
</shape>
\ No newline at end of file
......@@ -5,6 +5,8 @@
<data>
<import type="android.view.View" />
<variable
name="item"
type="com.ydl.confide.intro.VideoViewModel" />
......@@ -42,7 +44,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvName" />
app:layout_constraintTop_toTopOf="@+id/tvName"
tools:visibility="gone" />
<SeekBar
android:id="@+id/seekbar"
......@@ -57,21 +60,49 @@
android:progressDrawable="@drawable/confide_seekbar_style"
android:splitTrack="false"
android:thumb="@drawable/confide_seekbar_thumb"
app:layout_constraintBottom_toTopOf="@+id/btnCall"
app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/btnCall"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layoutCall"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_height="42dp"
android:layout_marginBottom="32dp"
android:gravity="center"
android:text="通话中"
android:textColor="@color/white"
android:background="@{item.lineStatus==3?@drawable/confide_line_bg_3:(item.lineStatus==2?@drawable/confide_line_bg_2:@drawable/confide_line_bg_1)}"
android:paddingLeft="28dp"
android:paddingRight="28dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
app:layout_constraintRight_toRightOf="parent"
tools:background="@drawable/confide_line_bg_1">
<ImageView
android:id="@+id/ivCall"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="4dp"
android:src="@drawable/ic_confide_call"
android:visibility="@{item.lineStatus==2?View.GONE:View.VISIBLE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tvCall"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvCall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/white"
android:textSize="17sp"
app:confideLineText="@{item.lineStatus}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/ivCall"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="通话中" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tvTag"
......@@ -82,7 +113,7 @@
android:text="@{item.tag}"
android:textColor="#99FFFFFF"
android:textSize="13sp"
app:layout_constraintBottom_toTopOf="@+id/btnCall"
app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintLeft_toLeftOf="parent"
tools:text="tag|tag|tag" />
......@@ -132,7 +163,7 @@
android:text="分享"
android:textColor="@color/white"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnCall"
app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintRight_toRightOf="parent" />
<TextView
......
......@@ -2,9 +2,6 @@ package com.yidianling.common.binding
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.PaintDrawable
import android.graphics.drawable.shapes.RectShape
import android.graphics.drawable.shapes.RoundRectShape
import android.view.View
import android.widget.ImageView
import androidx.databinding.BindingAdapter
......@@ -39,22 +36,14 @@ fun View.setCustomStyle(
} else {
background as GradientDrawable
}
val density = resources.displayMetrics.density
gradientDrawable.setColor(shapeBg)
gradientDrawable.setStroke(
shapeStrokeWidth.toInt(),
(shapeStrokeWidth * density).toInt(),
shapeStrokeColor
)
val radius = resources.displayMetrics.density * shapeRadius
gradientDrawable.cornerRadii = floatArrayOf(
radius,
radius,
radius,
radius,
radius,
radius,
radius,
radius
)
val radius = density * shapeRadius
gradientDrawable.cornerRadius = radius
when (shape) {
GradientDrawable.RECTANGLE -> gradientDrawable.shape = GradientDrawable.RECTANGLE
GradientDrawable.OVAL -> gradientDrawable.shape = GradientDrawable.OVAL
......
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