DynamicIn.kt 5.35 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
import android.content.Intent
YKai committed
6
import androidx.appcompat.app.AppCompatActivity
7
import androidx.fragment.app.DialogFragment
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
    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)
    }
63

konghaorui committed
64 65 66 67
    /**
     * 获取专家主页url
     */
    fun getExpertHost(): String {
68
        return HttpConfig.MH5_URL + "jy/experts/"
konghaorui committed
69 70 71
    }

    fun getShareExpertHost(): String {
72
        return HttpConfig.MH5_URL + "experts/"
konghaorui committed
73 74 75
    }

    fun isLogin(): Boolean {
76
        return getUserService().isLogin() ?: false
konghaorui committed
77 78 79 80 81 82 83 84
    }

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

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

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

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

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

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

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

110
    fun testResultH5(testResultId: Int) {
konghaorui committed
111
        getTestsService().testH5Result(testResultId.toString())
konghaorui committed
112 113
    }

114
    fun testDetailH5(testId: Int) {
konghaorui committed
115
        getTestsService().testDetailH5(testId.toString());
konghaorui committed
116 117 118
    }

    fun phoneCallIntent(activity: Activity): Intent? {
konghaorui committed
119
        return getConfideService().phoneCallIntent(activity)
konghaorui committed
120 121 122
    }

    fun fmDetailIntent(activity: Activity, fmId: Int): Intent? {
konghaorui committed
123
        return getFMService().fmDetailIntent(activity, fmId)
konghaorui committed
124 125 126
    }

    fun getFmId(): Int {
konghaorui committed
127
        return getFMService().getFmId() ?: 0
konghaorui committed
128 129
    }

130
    fun rechargeIntent(activity: Activity) {
konghaorui committed
131
        getAppService().rechargeIntent(activity)
konghaorui committed
132 133 134
    }

    fun phoneCallFragment(head: String, callId: String): DialogFragment? {
konghaorui committed
135
        return getConfideService().phoneCallFragment(head, callId)
konghaorui committed
136 137 138 139
    }


    fun startChat(activity: AppCompatActivity, toUid: String) {
konghaorui committed
140
        getImService().startP2PSession(activity, toUid)
konghaorui committed
141 142 143
    }

    fun isFmPlaying(): Boolean {
konghaorui committed
144
        return getFMService().isPlaying() ?: false
konghaorui committed
145 146 147
    }

    fun isCoursePlaying(): Boolean {
konghaorui committed
148
        return getCourseService().isPlaying() ?: false
konghaorui committed
149 150
    }

151 152
    fun playCourse() {
        if (!isCoursePlaying()) {
konghaorui committed
153
            getCourseService().play()
konghaorui committed
154 155 156
        }
    }

157 158
    fun pauseCourse() {
        if (isCoursePlaying()) {
konghaorui committed
159
            getCourseService().pause()
konghaorui committed
160 161 162
        }
    }

163
    fun rePlayFM() {
konghaorui committed
164
        getFMService().replay()
konghaorui committed
165 166
    }

167
    fun pauseFm() {
konghaorui committed
168
        getFMService().pause()
konghaorui committed
169 170 171
    }

    fun showSelector(activity: Activity, requestCode: Int) {
konghaorui committed
172
        getImService().showSelector(activity, requestCode)
konghaorui committed
173 174 175 176 177
    }

    /**
     * 课程播放页
     */
178 179
    fun startCoursePlayPage(activity: Activity) {
        getCourseService().startCoursePlayPage(activity, 1)
konghaorui committed
180
    }
181

182 183 184 185 186
    /**
     * 调用优先使用一键登录,并返回调用时的登录状态,
     * @param isOpenDialog true:一键登录使用弹窗展示 false:一键登录使用全屏模式
     * @return true:已登录,不触发登录跳转,false:未登录,优先一键登录
     * */
187 188
    fun loginByOneKeyLogin(context: Context, isOpenDialog: Boolean): Boolean {
        return getUserService().loginByOneKeyLogin(context, isOpenDialog)
189
    }
konghaorui committed
190
}