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 ...@@ -2,6 +2,7 @@ package com.ydl.confide.home.http
import com.ydl.confide.home.bean.ConfideConnectResponse import com.ydl.confide.home.bean.ConfideConnectResponse
import com.ydl.confide.home.bean.ConfideHomeDataBean 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
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
...@@ -33,4 +34,8 @@ interface ConfideHomeApi { ...@@ -33,4 +34,8 @@ interface ConfideHomeApi {
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json") @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
@GET("auth/listen/dial") @GET("auth/listen/dial")
fun connectJava(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<ConfideConnectResponse>> 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 ...@@ -15,8 +15,14 @@ import androidx.recyclerview.widget.RecyclerView
import com.dou361.ijkplayer.widget.IjkVideoView import com.dou361.ijkplayer.widget.IjkVideoView
import com.ydl.confide.R import com.ydl.confide.R
import com.ydl.confide.databinding.ItemExpertIntroBinding import com.ydl.confide.databinding.ItemExpertIntroBinding
import com.ydl.confide.home.http.ConfideHomeApi
import com.ydl.confide.home.util.ConfideNetworkUtil import com.ydl.confide.home.util.ConfideNetworkUtil
import com.ydl.ydlcommon.view.dialog.CommonDialog 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( internal class IntroAdapter(
private val context: Context, private val context: Context,
...@@ -30,6 +36,8 @@ internal class IntroAdapter( ...@@ -30,6 +36,8 @@ internal class IntroAdapter(
private var curPos = 0 private var curPos = 0
private var dispose: Disposable? = null
init { init {
lifecycleOwner.lifecycle.addObserver(this) lifecycleOwner.lifecycle.addObserver(this)
} }
...@@ -132,6 +140,24 @@ internal class IntroAdapter( ...@@ -132,6 +140,24 @@ internal class IntroAdapter(
fun onSelect(position: Int) { fun onSelect(position: Int) {
curPos = position 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) { if (!ConfideNetworkUtil.isWifi(context) && !hasAgreePlayWithoutWiFi) {
return return
} }
......
...@@ -36,7 +36,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) : ...@@ -36,7 +36,7 @@ internal class ItemIntroHolder(binding: ItemExpertIntroBinding) :
} }
fun onBind(item: VideoViewModel) { fun onBind(item: VideoViewModel) {
binding.btnCall.setOnClickListener { } binding.layoutCall.setOnClickListener { }
binding.btnChat.setOnClickListener { binding.btnChat.setOnClickListener {
val aty = it.context as? Activity val aty = it.context as? Activity
if (aty != null && !item.uid.isNullOrEmpty()) { if (aty != null && !item.uid.isNullOrEmpty()) {
...@@ -119,6 +119,7 @@ class VideoViewModel { ...@@ -119,6 +119,7 @@ class VideoViewModel {
val name = ObservableField<String>("") val name = ObservableField<String>("")
val avatar = ObservableField<String>("") val avatar = ObservableField<String>("")
val count = ObservableInt() val count = ObservableInt()
val lineStatus = ObservableInt()
val intro = ObservableField<String>("") val intro = ObservableField<String>("")
val tag = ObservableField<String>("") val tag = ObservableField<String>("")
var playUrl: String? = null//"https://video.ydlcdn.com/2020/04/01/ac2e4bb4e3ac8e2f0eca41e2d49c8484.mp4" 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 @@ ...@@ -5,6 +5,8 @@
<data> <data>
<import type="android.view.View" />
<variable <variable
name="item" name="item"
type="com.ydl.confide.intro.VideoViewModel" /> type="com.ydl.confide.intro.VideoViewModel" />
...@@ -42,7 +44,8 @@ ...@@ -42,7 +44,8 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvName" /> app:layout_constraintTop_toTopOf="@+id/tvName"
tools:visibility="gone" />
<SeekBar <SeekBar
android:id="@+id/seekbar" android:id="@+id/seekbar"
...@@ -57,21 +60,49 @@ ...@@ -57,21 +60,49 @@
android:progressDrawable="@drawable/confide_seekbar_style" android:progressDrawable="@drawable/confide_seekbar_style"
android:splitTrack="false" android:splitTrack="false"
android:thumb="@drawable/confide_seekbar_thumb" 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_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" /> app:layout_constraintRight_toRightOf="parent" />
<TextView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/btnCall" android:id="@+id/layoutCall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48dp" android:layout_height="42dp"
android:layout_marginBottom="32dp" android:layout_marginBottom="32dp"
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"
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:gravity="center"
android:text="通话中"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="17sp"
app:confideLineText="@{item.lineStatus}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toRightOf="@+id/ivCall"
app:layout_constraintRight_toRightOf="parent" /> app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="通话中" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView <TextView
android:id="@+id/tvTag" android:id="@+id/tvTag"
...@@ -82,7 +113,7 @@ ...@@ -82,7 +113,7 @@
android:text="@{item.tag}" android:text="@{item.tag}"
android:textColor="#99FFFFFF" android:textColor="#99FFFFFF"
android:textSize="13sp" android:textSize="13sp"
app:layout_constraintBottom_toTopOf="@+id/btnCall" app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
tools:text="tag|tag|tag" /> tools:text="tag|tag|tag" />
...@@ -132,7 +163,7 @@ ...@@ -132,7 +163,7 @@
android:text="分享" android:text="分享"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="11sp" android:textSize="11sp"
app:layout_constraintBottom_toTopOf="@+id/btnCall" app:layout_constraintBottom_toTopOf="@+id/layoutCall"
app:layout_constraintRight_toRightOf="parent" /> app:layout_constraintRight_toRightOf="parent" />
<TextView <TextView
......
...@@ -2,9 +2,6 @@ package com.yidianling.common.binding ...@@ -2,9 +2,6 @@ package com.yidianling.common.binding
import android.graphics.Color import android.graphics.Color
import android.graphics.drawable.GradientDrawable 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.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.databinding.BindingAdapter import androidx.databinding.BindingAdapter
...@@ -39,22 +36,14 @@ fun View.setCustomStyle( ...@@ -39,22 +36,14 @@ fun View.setCustomStyle(
} else { } else {
background as GradientDrawable background as GradientDrawable
} }
val density = resources.displayMetrics.density
gradientDrawable.setColor(shapeBg) gradientDrawable.setColor(shapeBg)
gradientDrawable.setStroke( gradientDrawable.setStroke(
shapeStrokeWidth.toInt(), (shapeStrokeWidth * density).toInt(),
shapeStrokeColor shapeStrokeColor
) )
val radius = resources.displayMetrics.density * shapeRadius val radius = density * shapeRadius
gradientDrawable.cornerRadii = floatArrayOf( gradientDrawable.cornerRadius = radius
radius,
radius,
radius,
radius,
radius,
radius,
radius,
radius
)
when (shape) { when (shape) {
GradientDrawable.RECTANGLE -> gradientDrawable.shape = GradientDrawable.RECTANGLE GradientDrawable.RECTANGLE -> gradientDrawable.shape = GradientDrawable.RECTANGLE
GradientDrawable.OVAL -> gradientDrawable.shape = GradientDrawable.OVAL 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