Commit b310c420 by 万齐军

Merge branch 'feat/qj/confide2' into 'd/v_confide_2.0'

Feat/qj/confide2

See merge request app_android_lib/YDL-Component!67
parents 963b1c63 61142785
package com.ydl.component.service.web
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.ydl.confide.home.event.ConfideDialogEvent
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivityMgr
import com.ydl.ydlcommon.ui.Loading
import com.yidianling.common.tools.ToastUtil
import de.greenrobot.event.EventBus
class JsMethod {
fun handle(param: String): Boolean {
try {
val obj = JsonParser().parse(param).asJsonObject
val cmd = obj.getAsJsonObject("cmd")
val actionName = cmd?.getAsJsonPrimitive("action_name")?.asString
if (actionName.isNullOrBlank()) return false
return innerHandle(actionName, cmd)
} catch (throwable: Throwable) {
throwable.printStackTrace()
return false
}
}
private fun innerHandle(actionName: String, obj: JsonObject): Boolean {
val param = obj.getAsJsonObject("params")
when (actionName) {
"handle_confide_btn" -> {
val show = param.getAsJsonPrimitive("show").asInt
EventBus.getDefault().post(ConfideDialogEvent(show))
return true
}
"show_loading" -> {
val topActivity = BaseActivityMgr.INST.getTopActivity()
Loading.show(topActivity)
return true
}
"close_loading" -> {
Loading.close()
return true
}
"open_app_eval_list"->{
val url = param.getAsJsonPrimitive("url").asString
val topActivity = BaseActivityMgr.INST.getTopActivity()
NewH5Activity.start(topActivity, H5Params(url, ""))
return true
}
"toast" -> {
val msg = param.getAsJsonPrimitive("msg").asString
if (!msg.isNullOrBlank()) {
ToastUtil.toastShort(msg)
}
return true
}
else -> {
return false
}
}
}
}
\ No newline at end of file
......@@ -22,6 +22,9 @@ import com.yidianling.user.UserHelper
*/
class WebJavascriptHandler : IJavascriptHandler{
private val js = JsMethod()
override fun getUriAppendSuffix(): String {
return "platform_main_theme=00C9E2&platform_main_theme_light=00D4DF&platform_main_theme_bright=EAFAFC"
}
......@@ -47,6 +50,7 @@ class WebJavascriptHandler : IJavascriptHandler{
if (YDLRouterManager.router(params)) {
return
}
if (js.handle(params)) return
val jsData = Gson().fromJson(params, H5JsBean::class.java)
//是否登录
if (jsData.cmd?.action_name != null && jsData.cmd!!.action_name.equals("login")) {
......
......@@ -20,6 +20,8 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.tencent.smtt.export.external.interfaces.JsResult
import com.tencent.smtt.sdk.*
import com.ydl.confide.R
import com.ydl.confide.home.event.ChangeAnotherExpertEvent
import com.ydl.confide.home.event.ConfideDialogEvent
import com.ydl.confide.home.http.ConfideHomeApi
import com.ydl.confide.router.PhoneCallIn
import com.ydl.utils.WebUrlParamsUtils
......@@ -34,15 +36,18 @@ import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.service.IImService
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.*
import kotlin.math.roundToInt
class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
companion object {
private const val KEY_JUMP_URL = "jumpUrl"
private const val KEY_DOCTOR_ID = "doctor_id"
private const val KEY_SHOULD_SHOW = "should_show"
private const val KEY_UID = "uid"
}
private var firstVisitWXH5PayUrl = true
......@@ -59,23 +64,26 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
lateinit var first_order: View
lateinit var confideProgress: View
lateinit var layout_change_text: View
lateinit var layoutBottom: View
lateinit var itemView: View
lateinit var jumpUrl: String
lateinit var doctorId: String
var shouldShow: Boolean? = false
var uid:String?="0"
var uid: String? = null
fun showBottomSheetDialog(
activity: FragmentActivity,
jumpUrl: String,
doctorId: String,
shouldShow: Boolean = false
shouldShow: Boolean = false,
uid: String? = null
) {
arguments = Bundle().apply {
putString(KEY_JUMP_URL, jumpUrl)
putString(KEY_DOCTOR_ID, doctorId)
putBoolean(KEY_SHOULD_SHOW, shouldShow)
uid?.let { putString(KEY_UID, it) }
}
show(activity.supportFragmentManager, "confide_bottom_showdialog")
}
......@@ -84,6 +92,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.AppBottomSheet)
EventBus.getDefault().register(this)
}
override fun onCreateView(
......@@ -100,9 +109,11 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
jumpUrl = arguments?.getString(KEY_JUMP_URL) ?: ""
doctorId = arguments?.getString(KEY_DOCTOR_ID) ?: ""
shouldShow = arguments?.getBoolean(KEY_SHOULD_SHOW) ?: false
uid = arguments?.getString(KEY_UID)
onLoadDialStatus(doctorId)
// +
wv_content = view.findViewById<ProgressWebView>(com.ydl.webview.R.id.wv_content)
wv_content.progressbar.visibility = View.GONE
close_webview_Icon = view.findViewById<View>(R.id.close_webview_Icon)
text_title = view.findViewById<TextView>(R.id.text_title)
line = view.findViewById<View>(R.id.line)
......@@ -138,12 +149,13 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
private fun onShowReady(){
private fun onShowReady() {
itemView = LayoutInflater.from(context).inflate(R.layout.confide_bottom_two, null, false)
layoutCall = itemView.findViewById<View>(R.id.layoutCall)
layoutChange = itemView.findViewById<View>(R.id.layoutChange)
confideProgress = itemView.findViewById<View>(R.id.confide_progress)
layout_change_text = itemView.findViewById<View>(R.id.layout_change_text)
layoutBottom = itemView.findViewById<View>(R.id.layoutBottom)
tvCall = itemView.findViewById<TextView>(R.id.tvCall)
tvTime = itemView.findViewById<TextView>(R.id.tvTime)
first_order = itemView.findViewById<TextView>(R.id.first_order)
......@@ -151,7 +163,10 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
val isLogin = userService.isLogin()
first_order.visibility = if (isLogin) View.GONE else View.VISIBLE
layoutCall.setOnClickListener {
ActionCountUtils.record("ydl_experts_detail_popupwindows_page", "ydl_experts_detail_popupwindows_page_visit")
ActionCountUtils.record(
"ydl_experts_detail_popupwindows_page",
"ydl_experts_detail_popupwindows_page_visit"
)
if (!PhoneCallIn.loginByOneKeyLogin(requireContext(), true)) {
return@setOnClickListener
}
......@@ -196,7 +211,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
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 = resources.displayMetrics.heightPixels / 2
behavior.peekHeight = (resources.displayMetrics.heightPixels * 0.7F).roundToInt()
//true是跳过peekHeight,直接滑下去,false是可以滑动到顶部还可以保持peekHeight在滑下去
// behavior?.skipCollapsed=true
behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
......@@ -238,18 +253,31 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
}
}
fun updateChange(doctorId: String,title:String, uid: String) {
fun onEventMainThread(event: ConfideDialogEvent) {
// 第一位表示拨打按钮,第二位代表再换一位按钮
val show = event.show
layoutCall.visibility = if (show and 0x01 == 0x01) View.VISIBLE else View.GONE
layoutChange.visibility = if (show and 0x02 == 0x01) View.VISIBLE else View.GONE
}
fun onEventMainThread(event: ChangeAnotherExpertEvent) {
updateChange(event.doctorID, event.title, event.uid)
}
private fun updateChange(doctorId: String, title: String, uid: String) {
if (doctorId == "0") {//没有下一位了
layoutChange.visibility = View.GONE
return
}
this.uid=uid
text_title.text=title
confideProgress.visibility=View.GONE
layout_change_text.visibility=View.VISIBLE
this.uid = uid
text_title.text = title
confideProgress.visibility = View.GONE
layout_change_text.visibility = View.VISIBLE
onLoadDialStatus(doctorId)
callJsFun(wv_content,"setUnRead(${getUnReadByUid(uid =uid )})")
callJsFun(wv_content, "setUnRead(${getUnReadByUid(uid = uid)})")
}
@SuppressLint("ClickableViewAccessibility")
private fun webViewInit(wv_content: ProgressWebView) {
val setting: WebSettings = wv_content?.settings!!
......@@ -303,20 +331,14 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onProgressChanged(view: WebView, newProgress: Int) {
if (newProgress == 100) {
wv_content.progressbar.visibility = View.GONE
callJsFun(wv_content,"setUnRead(${uid?.let { getUnReadByUid(uid = it) }})")
} else {
if (wv_content.progressbar.visibility == View.GONE) {
wv_content.progressbar.visibility = View.VISIBLE
}
wv_content.progressbar.progress = newProgress
callJsFun(wv_content, "setUnRead(${uid?.let { getUnReadByUid(uid = it) }})")
}
super.onProgressChanged(view, newProgress)
}
override fun onReceivedTitle(view: WebView, title: String) {
super.onReceivedTitle(view, title)
text_title.text=title
text_title.text = title
}
// For Android < 3.0
......@@ -420,9 +442,10 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
}
fun getUnReadByUid(uid:String):Int{
fun getUnReadByUid(uid: String): Int {
return ARouter.getInstance().navigation(IImService::class.java).getUnReadByUid(uid)
}
@SuppressLint("CheckResult")
private fun onLoadDialStatus(doctorId: String) {
val confideApi = YDLHttpUtils.obtainApi(ConfideHomeApi::class.java)
......@@ -456,7 +479,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
tvCall.text = "继续倾诉"
layoutCall.background =
context?.getDrawable(R.drawable.confide_line_bg_1)
context?.getDrawable(R.drawable.confide_line_bg_1)
context?.getDrawable(R.drawable.confide_line_bg_1)
val t = resp?.data?.remainingTime?.remainingTime
if (t != null) {
tvTime.visibility = View.VISIBLE
......@@ -473,4 +496,10 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
}, { throwable -> throwable.printStackTrace() })
}
override fun onDestroy() {
super.onDestroy()
wv_content.destroy()
EventBus.getDefault().unregister(this)
}
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.fragment.app.FragmentActivity
......@@ -22,7 +21,6 @@ import com.ydl.confide.home.bean.ConfideHomeDataBean
import com.ydl.confide.home.bean.ConfideHomeFiterItemBean
import com.ydl.confide.home.config.IConfideHomeConfig
import com.ydl.confide.home.contract.IConfideHomeContract
import com.ydl.confide.home.event.ChangeAnotherExpertEvent
import com.ydl.confide.home.event.ConfideHomeEventImpl
import com.ydl.confide.home.event.IConfideHomeEvent
import com.ydl.confide.home.listener.ConfideHomeRecycleViewListener
......@@ -47,7 +45,6 @@ import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.im.api.service.IImService
import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus
import kotlinx.android.synthetic.main.confide_home_activity.*
import kotlinx.android.synthetic.main.confide_title_bar.*
......@@ -106,7 +103,7 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
//是否有下一页(用于判断为你推荐条数,如果首页返回少于10条 那么就可以认为没有下一页了) 默认有下一页
private var hasMore = true
private var dp48 = 0
private lateinit var bottomSheetDialogFragment:ConfideBottomSheetDialogFragment
private var bottomSheetDialogFragment: ConfideBottomSheetDialogFragment? = null
init {
//初始化参数
initParam()
......@@ -153,12 +150,6 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
recommendList(page + 1)
}
@SuppressLint("MissingSuperCall")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
EventBus.getDefault().register(this)
}
override fun recommendList(page: Int) {
//需要将当前列表已存在的老师uid数组发送到后端去重,因为排序实时变化
this.page = page
......@@ -280,14 +271,12 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
return@setOnClickListener
}
bottomSheetDialogFragment=ConfideBottomSheetDialogFragment()
bottomSheetDialogFragment.showBottomSheetDialog(this as FragmentActivity, HttpConfig.MH5_URL + ConfideRoute.h5ConfideIntro("0"),"0",true)
bottomSheetDialogFragment?.showBottomSheetDialog(this as FragmentActivity, HttpConfig.MH5_URL + ConfideRoute.h5ConfideIntro("0"),"0",true)
}
}
fun onEventMainThread(event: ChangeAnotherExpertEvent) {
bottomSheetDialogFragment.updateChange(event.doctorID,event.title,event.uid)
}
private fun initView() {
img_back.setOnClickListener {
finish()
......@@ -557,7 +546,6 @@ class ConfideHomeActivity : BaseLceActivity<IConfideHomeContract.View,IConfideHo
override fun onDestroy() {
super.onDestroy()
mConfideEvent!!.destoryPlayer()
EventBus.getDefault().unregister(this)
}
override fun onBackPressed() {
......
......@@ -69,7 +69,8 @@ class RecentConfideAdapter(val data: List<ItemVideoShowViewModel>, private val e
)
event.consultantClick(
itemVideoShowViewModel.doctorId,
itemVideoShowViewModel.confideId
itemVideoShowViewModel.confideId,
itemVideoShowViewModel.uid
)
}
}
......@@ -84,10 +85,11 @@ class ItemVideoShowViewModel {
val state = ObservableInt()
var doctorId: String? = null
var confideId: String? = null
var uid: String? = null
}
internal fun ItemVideoShowViewModel.mapOf(bean: ConfideHomeBodyBean): ItemVideoShowViewModel {
name.set(bean.confidedName)
name.set(bean.videoTitle ?: "")
coverUrl.set(bean.confidedIcon)
if (bean.coverVideoPicture.isNullOrBlank()) {
videoCoverUrl.set(bean.coverPicture)
......@@ -97,6 +99,7 @@ internal fun ItemVideoShowViewModel.mapOf(bean: ConfideHomeBodyBean): ItemVideoS
state.set(bean.confideLine ?: 0)
doctorId = bean.doctorId
confideId = bean.confidedId
uid = bean.uid?.toString()
return this
}
......
......@@ -19,7 +19,8 @@ data class ConfideHomeBodyBean(
//专家的uid
val uid : Int?,
//咨询师姓名
val confidedName : String?,
val confidedName: String?,
val videoTitle: String?,
//咨询师性别 1.男 2.女
val confideSex : Int = 1,
//对你留言
......
package com.ydl.confide.home.event
data class ChangeAnotherExpertEvent(
var doctorID:String,
var title:String,
var uid:String
)
\ No newline at end of file
var doctorID: String,
var title: String,
var uid: String
)
class ConfideDialogEvent(val show: Int)
\ No newline at end of file
......@@ -132,13 +132,13 @@ class ConfideHomeEventImpl(context: Context, var confideHomeView: IConfideHomeCo
* 最佳倾诉榜单--点我倾诉
* @param linkUrl 跳转地址
*/
override fun consultantClick(doctorId: String?, confideId: String?) {
override fun consultantClick(doctorId: String?, confideId: String?, uid: String?) {
confideId?.let {
ConfideBottomSheetDialogFragment()
.showBottomSheetDialog(
mContext as FragmentActivity,
HttpConfig.MH5_URL + ConfideRoute.h5ConfideIntro(it),
doctorId!!
doctorId!!, uid = uid
)
}
}
......
......@@ -73,7 +73,7 @@ interface IConfideHomeEvent {
* 咨询师推荐--点我倾诉
* @param linkUrl 跳转地址
*/
fun consultantClick(doctorId: String?, confideId: String?)
fun consultantClick(doctorId: String?, confideId: String?, uid: String?)
fun videoShowClick(index: Int, data: List<ConfideHomeBodyBean>?)
......
......@@ -243,7 +243,7 @@ class ConfideHomeRecommendExpertItemView(mContext: Context, private var confideH
private fun click(bodyBean: ConfideHomeBodyBean) {
when (bodyBean.confideLine) {//1在线 2离线 3通话中
1, 3, 4 -> {
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId)
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString())
}
2 -> {
//跳转私聊 并发送自定义消息
......
......@@ -94,7 +94,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con
"1"
)
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId)
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString())
}
img_head.setOnClickListener {
ActionCountUtils.record("listen_counselor_list_page", "head_portrait_click", "2")
......@@ -344,7 +344,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con
if (bodyBean.confideLine == 3) {
}
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId)
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString())
}
2 -> {
//跳转私聊 并发送自定义消息
......
......@@ -2,6 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layoutBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/platform_dp_15"
......
......@@ -79,6 +79,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="23dp"
android:maxHeight="8dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:progressDrawable="@drawable/confide_seekbar_style"
......
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