Commit fd5e7e89 by 徐健

导医代码封装

parent 29831a89
ext {
kotlin_version = '1.3.21'
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......
......@@ -15,7 +15,7 @@ modular {
groupId = "com.ydl"
artifactId = "m-consultant-module-ydl"
// 上报的 壹点灵 业务模块 aar 包的版本号
version = "0.0.15"
version = "0.0.18"
}
}
......@@ -24,7 +24,7 @@ modular {
groupId = "com.ydl"
artifactId = "m-consultant-api"
//开发时注释掉版本号,发布api时打开
version = "0.0.1"
version = "0.0.2"
// API 层打包时需要引入的依赖
apiDependencies {
implementation "com.google.code.gson:gson:2.8.2"
......
......@@ -46,11 +46,11 @@ import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.adapter.ExpertSearchAdapter
import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.dialog.ConsultAssistantDialog
import com.yidianling.consultant.listener.OnCategoriesSelectedListener
import com.yidianling.consultant.listener.OnFilterConfirmListener
import com.yidianling.consultant.listener.OnSortItemSelectedListener
import com.yidianling.consultant.model.bean.*
import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
import com.yidianling.consultant.modular.utils.TempH5RouteUtils
import com.yidianling.consultant.router.ConsultantIn
import com.yidianling.consultant.ui.view.AreaPopupWindow
......@@ -188,7 +188,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
private var hasSelectedArea = false //是否选择过地区
private var hasSelectedSort = false //是否选择过排序
private var consultAssistantDialog: ConsultAssistantDialog? = null
override fun createPresenter(): ExpertSearchPresenter = ExpertSearchPresenter()
......@@ -998,15 +997,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
}
consultAssistantDialog?.let {
consultAssistantDialog?.show()
}
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list")
}
filterPopupWindow.isClippingEnabled = false
filterPopupWindow.showAtLocation(viewSep2.rootView, Gravity.TOP + Gravity.RIGHT, 0, 0)
consultAssistantDialog?.let {
consultAssistantDialog?.hide()
}
ConsultAssistantDialogUtils.INSTANCE.hide()
filterPopupWindow.onFilterConfirmListener = this
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
// viewDim.visibility = View.VISIBLE
......@@ -1473,30 +1468,14 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
super.onResume()
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_PAGE_VISIT)
//登录状态且是普通用户且是华为渠道,上述条件成立的情况下,调用接口判断是否展示咨询助理按钮
//todo xujian 条件添加完整
if (ConsultantIn.isLogin() &&
ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1
/** WalleChannelReader.getChannel(BaseApp.Companion.getApp()) == "android_huawei" */
) {
getPresenter().requestConsultAssistantBtnShown()
}
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list")
}
override fun showConsultAssistantDialog() {
Observable.timer(10000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe {
if (null == consultAssistantDialog) {
consultAssistantDialog = ConsultAssistantDialog(this, object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
getPresenter().requestConsultAssistantUid()
}
})
consultAssistantDialog?.show()
}
}
}override fun jumpToChat(uid: Long) {
ConsultantIn.startP2PSession(this, uid.toString())
override fun onDestroy() {
super.onDestroy()
ConsultAssistantDialogUtils.INSTANCE.hide()
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
}
}
......@@ -26,38 +26,6 @@ import io.reactivex.schedulers.Schedulers
*/
class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
/**
* 请求接口判断导医咨询助理按钮是否展示
*/
fun requestConsultAssistantBtnShown() {
SearchApi.instance
SearchApi.getSearchApi().getConsultAssistantRequest("doctor_list")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
if (it.data) {
mView.showConsultAssistantDialog()
}
}
}
/**
* 请求接口获取咨询助理的uid
*/
fun requestConsultAssistantUid() {
SearchApi.getSearchApi().getConsultAssistantUidRequest()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
if (it.code == "200" && it.data != 0.toLong()) {
mView.jumpToChat(it.data)
}else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
}
}
}
@SuppressLint("CheckResult")
fun fetchListHead() {
SearchApi.getSearchApi()
......
......@@ -39,13 +39,4 @@ interface IExpertSearchView : IView {
*/
fun showImage(url : String?, imgView : ImageView, ops : SimpleImageOpConfiger)
/**
* 导医
*/
fun showConsultAssistantDialog()
/**
* 跳去私聊
*/
fun jumpToChat(uid: Long)
}
\ No newline at end of file
......@@ -15,12 +15,15 @@ class ConsultantServiceImp: IConsultantService {
override fun init(context: Context?) {
}
/**
* 首页咨询助理入口
*/
override fun showConsultAssistantDialog(activity: Activity) {
ConsultAssistantDialogUtils.INSTANCE.showDialog(activity)
ConsultAssistantDialogUtils.INSTANCE.fitRequest(activity, "home_index")
}
override fun hideConsultAssistantDialog() {
ConsultAssistantDialogUtils.INSTANCE.hideDialog()
ConsultAssistantDialogUtils.INSTANCE.hide()
}
}
\ No newline at end of file
package com.yidianling.consultant.modular.singlton
import android.app.Activity
import android.content.Context
import android.support.v7.app.AppCompatActivity
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.dialog.ConsultAssistantDialog
......@@ -9,6 +8,7 @@ import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.router.ConsultantIn
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.*
/**
* Created by xj on 2019/11/14.
......@@ -20,7 +20,64 @@ class ConsultAssistantDialogUtils private constructor(){
}
var consultAssistantDialog: ConsultAssistantDialog? = null
var expertSearchPageHasShown: Boolean = false // 专家咨询列表页面是否已经展示
var timer: Timer? = null
/**
*判断是否符合代码展示逻辑
* origin 展示请求来源 首页 home_index 咨询列表 doctor_list
*/
fun fitRequest(activity: Activity, origin: String) {
if (ConsultantIn.isLogin() &&
ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1
/** WalleChannelReader.getChannel(BaseApp.Companion.getApp()) == "android_huawei" */
) {
shouldShowDialog(activity, origin)
}
}
/**
* 判断是否符合接口展示逻辑
*/
private fun shouldShowDialog(activity: Activity, origin: String, isDelay: Boolean = false) {
// 请求接口判断导医咨询助理按钮是否展示
SearchApi.getSearchApi().getConsultAssistantRequest(origin)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
if (it.data) {
if (origin == "home_index") {
show(activity, false)
}else if (origin == "doctor_list") {
show(activity, true)
}
}
}
}
/**
* 展示
* isDelay 是否延迟展示
*/
fun show(activity: Activity, isDelay: Boolean) {
if (isDelay && !expertSearchPageHasShown && timer == null) {
timer = Timer()
timer!!.schedule(object : TimerTask() {
override fun run() {
showDialog(activity)
expertSearchPageHasShown = true
}
}, 10000)
}else {
showDialog(activity)
}
}
/**
* 展示浮层
*/
fun showDialog(activity: Activity) {
if (consultAssistantDialog == null) {
consultAssistantDialog = ConsultAssistantDialog(activity, object : ConsultAssistantDialog.OnConsultAssistantClickListener {
......@@ -34,12 +91,25 @@ class ConsultAssistantDialogUtils private constructor(){
consultAssistantDialog!!.show()
}
fun hideDialog() {
consultAssistantDialog?.dismiss()
consultAssistantDialog = null
/**
* 隐藏
*/
fun hide() {
consultAssistantDialog?.hide()
}
/**
* 重置本单例关于专家咨询列表页面得状态
*/
fun resetStatus() {
timer?.cancel()
timer = null
expertSearchPageHasShown = false
}
private fun getConsultAssistantUid(activity: Activity) {
// 请求接口获取咨询助理的uid
SearchApi.getSearchApi().getConsultAssistantUidRequest()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
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