Commit e16c56dc by 徐健

增加咨询师列表activity的导医逻辑

parent 528664e0
......@@ -312,7 +312,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
image_scroll_top.setOnClickListener(this)
// initStatus()
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list")
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list", true)
}
private fun initNetLossView() {
......@@ -999,7 +999,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
}
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list")
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list", true)
}
filterPopupWindow.isClippingEnabled = false
filterPopupWindow.showAtLocation(viewSep2.rootView, Gravity.TOP + Gravity.RIGHT, 0, 0)
......@@ -1478,6 +1478,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun onDestroy() {
super.onDestroy()
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
ConsultAssistantDialogUtils.INSTANCE.expertSearchResetStatus()
}
}
......@@ -21,16 +21,19 @@ class ConsultAssistantDialogUtils private constructor() {
}
var consultAssistantDialogFromHomePage: ConsultAssistantDialog? = null // 首页展示的dialog
var consultAssistantDialog: ConsultAssistantDialog? = null //咨询师列表页面展示的dialog
var expertSearchPageHasShown: Boolean = false // 专家咨询列表页面是否已经展示
var consultAssistantFragmentDialog: ConsultAssistantDialog? = null //咨询师列表fragment页面展示的dialog
var expertSearchPageHasShown: Boolean = false // 专家咨询列表fragment页面是否已经展示
var consultAssistantActivityDialog: ConsultAssistantDialog? = null //咨询师列表activity页面展示的dialog
var expertSearchActivityPageHasShown: Boolean = false // 专家咨询列表activity页面是否已经展示
var timer: Timer? = null
/**
*判断是否符合代码展示逻辑
* origin 展示请求来源 首页 home_index 咨询列表 doctor_list
* fromActivity 默认不是来自于咨询师列表activity
*/
fun fitRequest(activity: Activity, origin: String) {
fun fitRequest(activity: Activity, origin: String, fromActivity: Boolean = false) {
when (origin) {
"home_index" -> {
if (ConsultantIn.isLogin() &&
......@@ -40,7 +43,7 @@ class ConsultAssistantDialogUtils private constructor() {
}
}
"doctor_list" -> {
shouldShowDialog(activity, origin)
shouldShowDialog(activity, origin, fromActivity = fromActivity)
}
}
......@@ -49,7 +52,7 @@ class ConsultAssistantDialogUtils private constructor() {
/**
* 判断是否符合接口展示逻辑
*/
private fun shouldShowDialog(activity: Activity, origin: String, isDelay: Boolean = false) {
private fun shouldShowDialog(activity: Activity, origin: String, isDelay: Boolean = false, fromActivity: Boolean = false) {
// 请求接口判断导医咨询助理按钮是否展示
SearchApi.getSearchApi().getConsultAssistantRequest(origin)
.subscribeOn(Schedulers.io())
......@@ -59,7 +62,7 @@ class ConsultAssistantDialogUtils private constructor() {
if (origin == "home_index") {
showFromYdlHome(activity)
} else if (origin == "doctor_list") {
show(activity)
show(activity, fromActivity)
}
}
}
......@@ -100,46 +103,85 @@ class ConsultAssistantDialogUtils private constructor() {
/**
* 咨询师列表页展示
*/
fun show(activity: Activity) {
if (!expertSearchPageHasShown && timer == null) {
timer = Timer()
timer!!.schedule(object : TimerTask() {
override fun run() {
Observable.just(1).observeOn(AndroidSchedulers.mainThread())
.subscribe {
expertSearchPageHasShown = true
showDialog(activity)
}
}
}, 5000)
} else {
showDialog(activity)
fun show(activity: Activity, fromActivity: Boolean = false) {
// 来自于fragment咨询师列表
if (!fromActivity) {
if (!expertSearchPageHasShown && timer == null) {
timer = Timer()
timer!!.schedule(object : TimerTask() {
override fun run() {
Observable.just(1).observeOn(AndroidSchedulers.mainThread())
.subscribe {
expertSearchPageHasShown = true
showDialog(activity)
}
}
}, 5000)
} else {
showDialog(activity)
}
}else {// 来自于activity咨询师列表
if (!expertSearchActivityPageHasShown && timer == null) {
timer = Timer()
timer!!.schedule(object : TimerTask() {
override fun run() {
Observable.just(1).observeOn(AndroidSchedulers.mainThread())
.subscribe {
expertSearchActivityPageHasShown = true
showDialog(activity, true)
}
}
}, 5000)
} else {
showDialog(activity, true)
}
}
}
/**
* 咨询师列表页展示浮层
*/
fun showDialog(activity: Activity) {
if (!activity.isFinishing) {
if (consultAssistantDialog == null) {
consultAssistantDialog = ConsultAssistantDialog(
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
// 咨询师列表页面且未登录情况下,跳转登录页面
if (!ConsultantIn.isLogin()) {
ConsultantIn.toLogin(activity)
} else {
//获取用户uid
getConsultAssistantUid(activity)
fun showDialog(activity: Activity, fromActivity: Boolean = false) {
if (!fromActivity) {
if (!activity.isFinishing) {
if (consultAssistantFragmentDialog == null) {
consultAssistantFragmentDialog = ConsultAssistantDialog(
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
// 咨询师列表页面且未登录情况下,跳转登录页面
if (!ConsultantIn.isLogin()) {
ConsultantIn.toLogin(activity)
} else {
//获取用户uid
getConsultAssistantUid(activity)
}
}
}
})
})
}
consultAssistantFragmentDialog?.show()
}
}else {
if (!activity.isFinishing) {
if (consultAssistantActivityDialog == null) {
consultAssistantActivityDialog = ConsultAssistantDialog(
activity,
object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
// 咨询师列表页面且未登录情况下,跳转登录页面
if (!ConsultantIn.isLogin()) {
ConsultantIn.toLogin(activity)
} else {
//获取用户uid
getConsultAssistantUid(activity)
}
}
})
}
consultAssistantActivityDialog?.show()
}
consultAssistantDialog?.show()
}
}
......@@ -148,20 +190,36 @@ class ConsultAssistantDialogUtils private constructor() {
* 咨询师列表页隐藏
*/
fun hide() {
consultAssistantDialog?.hide()
consultAssistantFragmentDialog?.hide()
}
/**
* 咨询师列表页面使用的重置本单例关于专家咨询列表页面得状态
* 释放本单例所有资源(咨询师列表fragmnet在MainActivity,
* 且在MainActivity销毁的时候,会先执行咨询师列表fragmnet
* 的ondeatroy,所以这边直接在该专家咨询列表碎片执行该方法)
*/
fun resetStatus() {
consultAssistantDialogFromHomePage?.dismiss()
consultAssistantDialog?.dismiss()
consultAssistantFragmentDialog?.dismiss()
consultAssistantActivityDialog?.dismiss()
timer?.cancel()
timer = null
expertSearchPageHasShown = false
expertSearchActivityPageHasShown = false
consultAssistantDialogFromHomePage = null
consultAssistantDialog = null
consultAssistantFragmentDialog = null
consultAssistantActivityDialog = null
}
/**
* 咨询师列表activity页面使用的重置本单例关于专家咨询列表页面得状态
*/
fun expertSearchResetStatus() {
consultAssistantActivityDialog?.dismiss()
timer?.cancel()
timer = null
expertSearchActivityPageHasShown = false
consultAssistantActivityDialog = null
}
////////////////////////////////////// 咨询师列表页面的展示隐藏逻辑 代码块end ///////////////////////////////////////////////////
......
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