DynamicIn.kt 5.29 KB
Newer Older
konghaorui committed
1 2 3
package com.yidianling.dynamic.router

import android.app.Activity
4
import android.content.Context
konghaorui committed
5 6 7
import android.content.Intent
import android.support.v4.app.DialogFragment
import android.support.v7.app.AppCompatActivity
konghaorui committed
8 9
import com.ydl.confide.api.IConfideService
import com.ydl.course.api.ICourseService
konghaorui committed
10 11
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager
konghaorui committed
12 13 14 15 16
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.dynamic.api.IDynamicService
import com.yidianling.fm.api.service.IFMService
import com.yidianling.im.api.service.IImService
import com.yidianling.tests.api.service.ITestsApiService
konghaorui committed
17
import com.yidianling.user.api.bean.UserResponseBean
konghaorui committed
18
import com.yidianling.user.api.service.IAppService
konghaorui committed
19 20 21 22 23 24 25 26 27
import com.yidianling.user.api.service.IUserService

/**
 * author : Zhangwenchao
 * e-mail : zhangwch@yidianling.com
 * time   : 2018/04/25
 */
object DynamicIn {

konghaorui committed
28 29 30 31 32 33 34
    fun getImService(): IImService {
        return ModularServiceManager.provide(IImService::class.java)
    }

    fun getAppService(): IAppService {
        return ModularServiceManager.provide(IAppService::class.java)
    }
konghaorui committed
35 36 37 38 39

    fun getUserService(): IUserService {
        return ModularServiceManager.provide(IUserService::class.java)
    }

konghaorui committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    fun getDynamicService(): IDynamicService {
        return ModularServiceManager.provide(IDynamicService::class.java)
    }

    fun getCourseService(): ICourseService {
        return ModularServiceManager.provide(ICourseService::class.java)
    }

    fun getTestsService(): ITestsApiService {
        return ModularServiceManager.provide(ITestsApiService::class.java)
    }

    fun getFMService(): IFMService {
        return ModularServiceManager.provide(IFMService::class.java)
    }

    fun getConsultService(): IConsultantService {
        return ModularServiceManager.provide(IConsultantService::class.java)
    }

    fun getConfideService(): IConfideService {
        return ModularServiceManager.provide(IConfideService::class.java)
    }
  
konghaorui committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    /**
     * 获取专家主页url
     */
    fun getExpertHost(): String {
        return  HttpConfig.H5_URL + "experts/"
    }

    fun getShareExpertHost(): String {
        return  HttpConfig.MH5_URL+ "experts/"
    }

    fun isLogin(): Boolean {
        return getUserService().isLogin()?:false
    }

    fun getUserInfo(): UserResponseBean.UserInfo? = getUserService().getUserInfo()

    fun loginWayIntent(activity: Activity): Intent? {
        return getUserService().loginWayIntent(activity)
    }

konghaorui committed
85 86
    fun personalInfoIntent(activity: Activity){
        getAppService().personalInfoIntent(activity)
konghaorui committed
87 88 89 90 91 92
    }

    fun inputPhoneIntent(activity: Activity, smsAction: String): Intent? {
        return getUserService().inputPhoneIntent(activity, smsAction)
    }

konghaorui committed
93 94
    fun mainIntent(activity: Activity){
        getAppService().mainIntent(activity)
konghaorui committed
95 96
    }

konghaorui committed
97 98
    fun mainIntent(activity: Activity,tab :Int){
        getAppService().mainIntent(activity,tab,false)
konghaorui committed
99 100
    }

konghaorui committed
101 102
    fun expertSearchIntent(activity: Activity, category: Int, showType: Int, isInitShowHot: Boolean): Intent? {
        return getConsultService().expertSearchIntent(activity, category, showType, isInitShowHot)
konghaorui committed
103 104 105
    }

    fun testResultH5(testResultId: Int){
konghaorui committed
106
        getTestsService().testH5Result(testResultId.toString())
konghaorui committed
107 108 109
    }

    fun testDetailH5(testId: Int){
konghaorui committed
110
        getTestsService().testDetailH5(testId.toString());
konghaorui committed
111 112 113
    }

    fun phoneCallIntent(activity: Activity): Intent? {
konghaorui committed
114
        return getConfideService().phoneCallIntent(activity)
konghaorui committed
115 116 117
    }

    fun fmDetailIntent(activity: Activity, fmId: Int): Intent? {
konghaorui committed
118
        return getFMService().fmDetailIntent(activity, fmId)
konghaorui committed
119 120 121
    }

    fun getFmId(): Int {
konghaorui committed
122
        return getFMService().getFmId() ?: 0
konghaorui committed
123 124
    }

konghaorui committed
125 126
    fun rechargeIntent(activity: Activity){
        getAppService().rechargeIntent(activity)
konghaorui committed
127 128 129
    }

    fun phoneCallFragment(head: String, callId: String): DialogFragment? {
konghaorui committed
130
        return getConfideService().phoneCallFragment(head, callId)
konghaorui committed
131 132 133 134
    }


    fun startChat(activity: AppCompatActivity, toUid: String) {
konghaorui committed
135
        getImService().startP2PSession(activity, toUid)
konghaorui committed
136 137 138
    }

    fun isFmPlaying(): Boolean {
konghaorui committed
139
        return getFMService().isPlaying() ?: false
konghaorui committed
140 141 142
    }

    fun isCoursePlaying(): Boolean {
konghaorui committed
143
        return getCourseService().isPlaying() ?: false
konghaorui committed
144 145 146 147
    }

    fun playCourse(){
        if (!isCoursePlaying()){
konghaorui committed
148
            getCourseService().play()
konghaorui committed
149 150 151 152 153
        }
    }

    fun pauseCourse(){
        if (isCoursePlaying()){
konghaorui committed
154
            getCourseService().pause()
konghaorui committed
155 156 157 158
        }
    }

    fun rePlayFM(){
konghaorui committed
159
        getFMService().replay()
konghaorui committed
160 161 162
    }

    fun pauseFm(){
konghaorui committed
163
        getFMService().pause()
konghaorui committed
164 165 166
    }

    fun showSelector(activity: Activity, requestCode: Int) {
konghaorui committed
167
        getImService().showSelector(activity, requestCode)
konghaorui committed
168 169 170 171 172 173
    }

    /**
     * 课程播放页
     */
    fun startCoursePlayPage(activity: Activity){
konghaorui committed
174
        getCourseService().startCoursePlayPage(activity,1)
konghaorui committed
175
    }
176 177 178 179 180 181 182 183
    /**
     * 调用优先使用一键登录,并返回调用时的登录状态,
     * @param isOpenDialog true:一键登录使用弹窗展示 false:一键登录使用全屏模式
     * @return true:已登录,不触发登录跳转,false:未登录,优先一键登录
     * */
    fun loginByOneKeyLogin(context: Context, isOpenDialog: Boolean) :Boolean{
        return getUserService().loginByOneKeyLogin(context,isOpenDialog)
    }
konghaorui committed
184
}