Commit cfc16170 by fengquan

feat: Code Review代码调整

parent 2e1cb369
...@@ -84,18 +84,18 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -84,18 +84,18 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
lateinit var layout_change_text: View lateinit var layout_change_text: View
lateinit var layoutBottom: View lateinit var layoutBottom: View
lateinit var itemView: View lateinit var itemView: View
var lineStatus:Int = 0 var lineStatus: Int = 0
var bottomSheet :FrameLayout?=null var bottomSheet: FrameLayout? = null
var mJtoJHandle:IJavascriptHandler?=null var mJtoJHandle: IJavascriptHandler? = null
private var behavior: BottomSheetBehavior<*>? = null private var behavior: BottomSheetBehavior<*>? = null
var isLogin : Boolean = false var isLogin: Boolean = false
lateinit var jumpUrl: String lateinit var jumpUrl: String
lateinit var doctorId: String lateinit var doctorId: String
lateinit var expertUrl:String lateinit var expertUrl: String
var shouldShow: Boolean? = false var shouldShow: Boolean? = false
var uid: String? = null var uid: String? = null
var listen_free : Boolean = false var listen_free: Boolean = false
fun showBottomSheetDialog( fun showBottomSheetDialog(
activity: FragmentActivity, activity: FragmentActivity,
jumpUrl: String, jumpUrl: String,
...@@ -103,15 +103,15 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -103,15 +103,15 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
shouldShow: Boolean = false, shouldShow: Boolean = false,
uid: String? = null, uid: String? = null,
listenFree: Boolean = false, listenFree: Boolean = false,
expertUrl:String = "" expertUrl: String = ""
) { ) {
arguments = Bundle().apply { arguments = Bundle().apply {
putString(KEY_JUMP_URL, jumpUrl) putString(KEY_JUMP_URL, jumpUrl)
putString(KEY_DOCTOR_ID, doctorId) putString(KEY_DOCTOR_ID, doctorId)
putBoolean(KEY_SHOULD_SHOW, shouldShow) putBoolean(KEY_SHOULD_SHOW, shouldShow)
putBoolean(KEY_LISTEN_FREE,listenFree) putBoolean(KEY_LISTEN_FREE, listenFree)
uid?.let { putString(KEY_UID, it) } uid?.let { putString(KEY_UID, it) }
putString(EXPERT_URL,expertUrl) putString(EXPERT_URL, expertUrl)
} }
show(activity.supportFragmentManager, "confide_bottom_showdialog") show(activity.supportFragmentManager, "confide_bottom_showdialog")
} }
...@@ -134,10 +134,13 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -134,10 +134,13 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
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"
)
jumpUrl = arguments?.getString(KEY_JUMP_URL) ?: "" jumpUrl = arguments?.getString(KEY_JUMP_URL) ?: ""
doctorId = arguments?.getString(KEY_DOCTOR_ID) ?: "" doctorId = arguments?.getString(KEY_DOCTOR_ID) ?: ""
expertUrl = arguments?.getString(EXPERT_URL) ?:"" expertUrl = arguments?.getString(EXPERT_URL) ?: ""
shouldShow = arguments?.getBoolean(KEY_SHOULD_SHOW) ?: false shouldShow = arguments?.getBoolean(KEY_SHOULD_SHOW) ?: false
uid = arguments?.getString(KEY_UID) uid = arguments?.getString(KEY_UID)
listen_free = arguments?.getBoolean(KEY_LISTEN_FREE) ?: false listen_free = arguments?.getBoolean(KEY_LISTEN_FREE) ?: false
...@@ -198,7 +201,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -198,7 +201,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
first_order.visibility = if (isLogin) View.GONE else View.VISIBLE first_order.visibility = if (isLogin) View.GONE else View.VISIBLE
val controller: DraweeController = Fresco.newDraweeControllerBuilder() val controller: DraweeController = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse("res://drawable/"+R.drawable.confide_first_order)) .setUri(Uri.parse("res://drawable/" + R.drawable.confide_first_order))
.setOldController(first_order.controller) .setOldController(first_order.controller)
.setAutoPlayAnimations(true) // 是否自动播放Gif动画 .setAutoPlayAnimations(true) // 是否自动播放Gif动画
.build() .build()
...@@ -227,12 +230,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -227,12 +230,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
return@setOnClickListener return@setOnClickListener
} }
when(lineStatus){ when (lineStatus) {
1,4 ->{ 1, 4 -> {
callJsFun(wv_content, "listenCallClick()") callJsFun(wv_content, "listenCallClick()")
} }
3,6 ->{ 3, 6 -> {
if (!uid.isNullOrBlank()) { if (!uid.isNullOrBlank()) {
activity?.let { it1 -> activity?.let { it1 ->
ARouter.getInstance().navigation(IImService::class.java) ARouter.getInstance().navigation(IImService::class.java)
...@@ -241,21 +244,25 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -241,21 +244,25 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
} }
} }
5->{ 5 -> {
if (!TextUtils.isEmpty(expertUrl)){ if (!TextUtils.isEmpty(expertUrl)) {
val linkUri = Uri.parse(expertUrl) val linkUri = Uri.parse(expertUrl)
if (linkUri != null) { if (linkUri != null) {
val host = linkUri.host val host = linkUri.host
if (!TextUtils.isEmpty(host) && host == "h5") { if (!TextUtils.isEmpty(host) && host == "h5") {
//如果是h5,跳转至NewH5Activity //如果是h5,跳转至NewH5Activity
try { try {
var params = URLDecoder.decode(linkUri.getQueryParameter("params"),"UTF-8") var params = URLDecoder.decode(
ARouter.getInstance().build("/new_h5/h5").withSerializable("routerParam", params).navigation() linkUri.getQueryParameter("params"),
}catch (e : NullPointerException){ "UTF-8"
)
ARouter.getInstance().build("/new_h5/h5")
.withSerializable("routerParam", params).navigation()
} catch (e: NullPointerException) {
LogUtil.e("params参数为空") LogUtil.e("params参数为空")
}catch (e : UnsupportedEncodingException){ } catch (e: UnsupportedEncodingException) {
LogUtil.e("解码错误") LogUtil.e("解码错误")
}catch (e : UnsupportedOperationException){ } catch (e: UnsupportedOperationException) {
LogUtil.e("这不是一个uri格式的地址") LogUtil.e("这不是一个uri格式的地址")
} }
} }
...@@ -272,6 +279,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -272,6 +279,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
} }
} }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
onShowReady() onShowReady()
...@@ -291,12 +299,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -291,12 +299,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
behavior = BottomSheetBehavior.from(bottomSheet!!) behavior = BottomSheetBehavior.from(bottomSheet!!)
behavior?.peekHeight = (resources.displayMetrics.heightPixels * 0.7F).roundToInt() behavior?.peekHeight = (resources.displayMetrics.heightPixels * 0.7F).roundToInt()
if (jumpUrl?.contains("payPage=1")){ if (jumpUrl?.contains("payPage=1")) {
//支付高度 //支付高度
setMaxHeight(RxImageTool.dp2px(450f)) setMaxHeight(RxImageTool.dp2px(450f))
behavior?.isHideable = false behavior?.isHideable = false
rl_title.visibility = View.GONE rl_title.visibility = View.GONE
}else{ } else {
setMaxHeight(resources.displayMetrics.heightPixels) setMaxHeight(resources.displayMetrics.heightPixels)
} }
//true是跳过peekHeight,直接滑下去,false是可以滑动到顶部还可以保持peekHeight在滑下去 //true是跳过peekHeight,直接滑下去,false是可以滑动到顶部还可以保持peekHeight在滑下去
...@@ -307,7 +315,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -307,7 +315,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
BottomSheetBehavior.STATE_EXPANDED -> { BottomSheetBehavior.STATE_EXPANDED -> {
bottomSheet.background = ColorDrawable(Color.WHITE) bottomSheet.background = ColorDrawable(Color.WHITE)
if (!jumpUrl?.contains("payPage=1")){ if (!jumpUrl?.contains("payPage=1")) {
rl_title.visibility = View.VISIBLE rl_title.visibility = View.VISIBLE
text_title.visibility = View.VISIBLE text_title.visibility = View.VISIBLE
close_webview_Icon.visibility = View.VISIBLE close_webview_Icon.visibility = View.VISIBLE
...@@ -337,10 +345,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -337,10 +345,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
} }
return dialog return dialog
} }
private fun setMaxHeight(height : Int){
private fun setMaxHeight(height: Int) {
bottomSheet?.layoutParams?.height = height bottomSheet?.layoutParams?.height = height
bottomSheet?.requestLayout() bottomSheet?.requestLayout()
} }
private fun callJsFun(wv_content: ProgressWebView, funcName: String) { private fun callJsFun(wv_content: ProgressWebView, funcName: String) {
val sb = StringBuffer("javascript:") val sb = StringBuffer("javascript:")
sb.append(funcName) sb.append(funcName)
...@@ -383,7 +393,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -383,7 +393,7 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
this.doctorId = doctorId this.doctorId = doctorId
onLoadDialStatus(doctorId) onLoadDialStatus(doctorId)
val confideHomeActivity = activity as ConfideHomeActivity val confideHomeActivity = activity as ConfideHomeActivity
expertUrl = confideHomeActivity.searchLinkUrlByUid(uid) expertUrl = confideHomeActivity?.searchLinkUrlByUid(uid) ?: ""
callJsFun(wv_content, "setUnRead(${getUnReadByUid(uid = uid)})") callJsFun(wv_content, "setUnRead(${getUnReadByUid(uid = uid)})")
} }
...@@ -571,15 +581,15 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -571,15 +581,15 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
layoutCall.visibility = View.VISIBLE layoutCall.visibility = View.VISIBLE
lineStatus = resp.data?.confideLine ?: 2 lineStatus = resp.data?.confideLine ?: 2
if (isLogin && listen_free){ if (isLogin && listen_free) {
free.visibility = View.VISIBLE free.visibility = View.VISIBLE
val controller: DraweeController = Fresco.newDraweeControllerBuilder() val controller: DraweeController = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse("res://drawable/"+R.drawable.confide_free)) .setUri(Uri.parse("res://drawable/" + R.drawable.confide_free))
.setOldController(free.controller) .setOldController(free.controller)
.setAutoPlayAnimations(true) // 是否自动播放Gif动画 .setAutoPlayAnimations(true) // 是否自动播放Gif动画
.build() .build()
free.controller = controller free.controller = controller
}else{ } else {
free.visibility = View.GONE free.visibility = View.GONE
} }
/* /*
...@@ -602,7 +612,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -602,7 +612,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
context?.getDrawable(R.drawable.confide_line_bg_2) context?.getDrawable(R.drawable.confide_line_bg_2)
if (showTip) { if (showTip) {
if (!uid.isNullOrBlank()) { if (!uid.isNullOrBlank()) {
findRouteService(IImService::class.java).startChat(requireActivity(), uid!!, 0, 0) findRouteService(IImService::class.java).startChat(
requireActivity(),
uid!!,
0,
0
)
} }
} }
} }
...@@ -616,7 +631,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -616,7 +631,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
if (showTip) { if (showTip) {
ToastUtil.toastShort("对方正在通话中,请稍后拨打") ToastUtil.toastShort("对方正在通话中,请稍后拨打")
if (!uid.isNullOrBlank()) { if (!uid.isNullOrBlank()) {
findRouteService(IImService::class.java).startChat(requireActivity(), uid!!, 0, 0) findRouteService(IImService::class.java).startChat(
requireActivity(),
uid!!,
0,
0
)
} }
} }
} }
...@@ -661,10 +681,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() { ...@@ -661,10 +681,12 @@ class ConfideBottomSheetDialogFragment : BottomSheetDialogFragment() {
wv_content.destroy() wv_content.destroy()
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
} }
//登录成功 //登录成功
fun onEvent(event: UserLoginEvent) { fun onEvent(event: UserLoginEvent) {
loadUrl() loadUrl()
} }
//绑定成功 //绑定成功
fun onEvent(event: UserBindPhoneEvent) { fun onEvent(event: UserBindPhoneEvent) {
loadUrl() loadUrl()
......
...@@ -666,7 +666,7 @@ class ConfideHomeActivity : ...@@ -666,7 +666,7 @@ class ConfideHomeActivity :
super.onBackPressed() super.onBackPressed()
} }
public fun searchLinkUrlByUid(uid : String):String{ fun searchLinkUrlByUid(uid : String):String{
cacheList?.forEach {confideHomeDataBean -> cacheList?.forEach {confideHomeDataBean ->
confideHomeDataBean.body?.forEach { confideHomeBodyBean -> confideHomeDataBean.body?.forEach { confideHomeBodyBean ->
if (uid == confideHomeBodyBean.uid.toString()){ if (uid == confideHomeBodyBean.uid.toString()){
......
...@@ -243,7 +243,7 @@ class ConfideHomeRecommendExpertItemView(mContext: Context, private var confideH ...@@ -243,7 +243,7 @@ class ConfideHomeRecommendExpertItemView(mContext: Context, private var confideH
private fun click(bodyBean: ConfideHomeBodyBean) { private fun click(bodyBean: ConfideHomeBodyBean) {
when (bodyBean.confideLine) {//1在线 2离线 3通话中 when (bodyBean.confideLine) {//1在线 2离线 3通话中
1, 3, 4 -> { 1, 3, 4 -> {
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString(),bodyBean.listenFree) confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString(), bodyBean.listenFree)
} }
2 -> { 2 -> {
//跳转私聊 并发送自定义消息 //跳转私聊 并发送自定义消息
......
...@@ -94,7 +94,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con ...@@ -94,7 +94,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con
"1" "1"
) )
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString(),bodyBean.listenFree,bodyBean.linkUrl) confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString(), bodyBean.listenFree,bodyBean.linkUrl)
} }
img_head.setOnClickListener { img_head.setOnClickListener {
...@@ -345,7 +345,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con ...@@ -345,7 +345,7 @@ class ConfideHomeRecommendView(var view: IConfideHomeContract.View, context: Con
if (bodyBean.confideLine == 3) { if (bodyBean.confideLine == 3) {
} }
confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString(),bodyBean.listenFree) confideHomeEvent.consultantClick(bodyBean.doctorId, bodyBean.confidedId, bodyBean.uid?.toString(), bodyBean.listenFree)
} }
2 -> { 2 -> {
//跳转私聊 并发送自定义消息 //跳转私聊 并发送自定义消息
......
...@@ -430,9 +430,9 @@ internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel { ...@@ -430,9 +430,9 @@ internal fun VideoViewModel.mapOf(bean: ConfideHomeBodyBean): VideoViewModel {
uid = bean.uid?.toString() uid = bean.uid?.toString()
doctorId = bean.doctorId doctorId = bean.doctorId
confideId = bean.confidedId confideId = bean.confidedId
if (bean.listenFree == null){ if (bean.listenFree == null) {
listenFree.set(false) listenFree.set(false)
}else{ } else {
listenFree.set(bean.listenFree!!) listenFree.set(bean.listenFree!!)
} }
return this return this
......
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