DynamicIn.kt 4.82 KB
Newer Older
konghaorui committed
1 2 3 4 5 6
package com.yidianling.dynamic.router

import android.app.Activity
import android.content.Intent
import android.support.v4.app.DialogFragment
import android.support.v7.app.AppCompatActivity
konghaorui committed
7 8
import com.ydl.confide.api.IConfideService
import com.ydl.course.api.ICourseService
konghaorui committed
9 10
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager
konghaorui committed
11 12 13 14 15
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
16
import com.yidianling.user.api.bean.UserResponseBean
konghaorui committed
17
import com.yidianling.user.api.service.IAppService
konghaorui committed
18 19 20 21 22 23 24 25 26
import com.yidianling.user.api.service.IUserService

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

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

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

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

konghaorui committed
39 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)
    }
  
konghaorui committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    /**
     * 获取专家主页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
84 85
    fun personalInfoIntent(activity: Activity){
        getAppService().personalInfoIntent(activity)
konghaorui committed
86 87 88 89 90 91
    }

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

    /**
     * 课程播放页
     */
    fun startCoursePlayPage(activity: Activity){
konghaorui committed
173
        getCourseService().startCoursePlayPage(activity,1)
konghaorui committed
174 175
    }
}