Commit cfc16170 by fengquan

feat: Code Review代码调整

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