Commit 13c8abee by konghaorui

Merge branch 'dev' of ssh://gitlab.yidianling.com:2224/app_android_lib/YDL-Component into dev

# Conflicts:
#	app/build.gradle
parents fe80751a 86325d4b
......@@ -173,6 +173,10 @@ dependencies {
api project(':m-consultant')
implementation modularPublication('com.ydl:m-consultant-api')
api project(':m-confide')
// api "com.ydl:m-consultant-api:0.0.2"
// api 'com.ydl:m-consultant-module-ydl:0.0.18@aar'
api (project(':ydl-platform')){
transitive = true
}
......
......@@ -173,6 +173,12 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
ModularServiceManager.provide(IConsultantService::class.java).showConsultAssistantDialog(this)
}
override fun onPause() {
super.onPause()
ModularServiceManager.provide(IConsultantService::class.java).hideConsultAssistantDialog()
}
// override fun onDestroy() {
// if (serviceConnection != null) {
......
......@@ -13,6 +13,7 @@ import android.support.v4.content.ContextCompat
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.WindowManager
......@@ -311,6 +312,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
// })
image_scroll_top.setOnClickListener(this)
// initStatus()
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list")
}
private fun initNetLossView() {
......@@ -1468,14 +1471,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
super.onResume()
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_PAGE_VISIT)
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list")
}
override fun onDestroy() {
super.onDestroy()
ConsultAssistantDialogUtils.INSTANCE.hide()
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
}
}
......@@ -23,7 +23,7 @@ class ConsultantServiceImp: IConsultantService {
}
override fun hideConsultAssistantDialog() {
ConsultAssistantDialogUtils.INSTANCE.hide()
ConsultAssistantDialogUtils.INSTANCE.hideFromHomePage()
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.dialog.ConsultAssistantDialog
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.router.ConsultantIn
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.*
......@@ -13,13 +14,14 @@ import java.util.*
/**
* Created by xj on 2019/11/14.
*/
class ConsultAssistantDialogUtils private constructor(){
class ConsultAssistantDialogUtils private constructor() {
companion object {
val INSTANCE by lazy { ConsultAssistantDialogUtils() }
}
var consultAssistantDialog: ConsultAssistantDialog? = null
var consultAssistantDialogFromHomePage: ConsultAssistantDialog? = null // 首页展示的dialog
var consultAssistantDialog: ConsultAssistantDialog? = null //咨询师列表页面展示的dialog
var expertSearchPageHasShown: Boolean = false // 专家咨询列表页面是否已经展示
var timer: Timer? = null
......@@ -45,78 +47,112 @@ class ConsultAssistantDialogUtils private constructor(){
SearchApi.getSearchApi().getConsultAssistantRequest(origin)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
.subscribe {
if (it.data) {
if (origin == "home_index") {
show(activity, false)
}else if (origin == "doctor_list") {
show(activity, true)
showFromYdlHome(activity)
} else if (origin == "doctor_list") {
show(activity)
}
}
}
}
////////////////////////////////////// 首页的展示隐藏逻辑 代码块start ///////////////////////////////////////////////////
/**
* 首页页展示
*/
fun showFromYdlHome(activity: Activity) {
consultAssistantDialogFromHomePage?.dismiss()
consultAssistantDialogFromHomePage = null
consultAssistantDialogFromHomePage = ConsultAssistantDialog(activity, object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
//获取用户uid
getConsultAssistantUid(activity)
}
})
consultAssistantDialogFromHomePage?.show()
}
/**
* 首页隐藏
*/
fun hideFromHomePage() {
consultAssistantDialogFromHomePage?.dismiss()
}
////////////////////////////////////// 首页的展示隐藏逻辑 代码块end ///////////////////////////////////////////////////
////////////////////////////////////// 咨询师列表页面的展示隐藏逻辑 代码块start ///////////////////////////////////////////////////
/**
* 展示
* isDelay 是否延迟展示
* 咨询师列表页展示
*/
fun show(activity: Activity, isDelay: Boolean) {
fun show(activity: Activity) {
if (isDelay && !expertSearchPageHasShown && timer == null) {
if (!expertSearchPageHasShown && timer == null) {
timer = Timer()
timer!!.schedule(object : TimerTask() {
override fun run() {
showDialog(activity)
expertSearchPageHasShown = true
Observable.just(1).observeOn(AndroidSchedulers.mainThread())
.subscribe {
showDialog(activity)
expertSearchPageHasShown = true
}
}
}, 10000)
}else {
} else {
showDialog(activity)
}
}
/**
* 展示浮层
* 咨询师列表页展示浮层
*/
fun showDialog(activity: Activity) {
if (consultAssistantDialog == null) {
consultAssistantDialog = ConsultAssistantDialog(activity, object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
//获取用户uid
getConsultAssistantUid(activity)
}
consultAssistantDialog?.dismiss()
consultAssistantDialog = null
consultAssistantDialog = ConsultAssistantDialog(activity, object : ConsultAssistantDialog.OnConsultAssistantClickListener {
override fun onClickAction() {
//获取用户uid
getConsultAssistantUid(activity)
}
})
}
consultAssistantDialog!!.show()
})
consultAssistantDialog?.show()
}
/**
* 隐藏
* 咨询师列表页隐藏
*/
fun hide() {
consultAssistantDialog?.hide()
consultAssistantDialog?.dismiss()
}
/**
* 重置本单例关于专家咨询列表页面得状态
* 咨询师列表页面使用的重置本单例关于专家咨询列表页面得状态
*/
fun resetStatus() {
consultAssistantDialog?.dismiss()
timer?.cancel()
timer = null
expertSearchPageHasShown = false
consultAssistantDialog = null
}
////////////////////////////////////// 咨询师列表页面的展示隐藏逻辑 代码块end ///////////////////////////////////////////////////
private fun getConsultAssistantUid(activity: Activity) {
// 请求接口获取咨询助理的uid
SearchApi.getSearchApi().getConsultAssistantUidRequest()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe{
.subscribe {
if (it.code == "200" && it.data != 0.toLong()) {
ConsultantIn.startP2PSession(activity as AppCompatActivity, it.data.toString())
}else {
} else {
ToastUtil.toastShort("咨询助理忙碌中,请稍后再试")
}
}
......
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