DynamicIn.kt 5.11 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 11 12
import com.ydl.ydlcommon.actions.imagepicker.PickerCallback
import com.ydl.ydlcommon.actions.imagepicker.YdlImagePicker
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.modular.ModularServiceManager
konghaorui committed
13 14 15 16 17
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
18
import com.yidianling.user.api.bean.UserResponseBean
konghaorui committed
19
import com.yidianling.user.api.service.IAppService
konghaorui committed
20 21 22 23 24 25 26 27 28
import com.yidianling.user.api.service.IUserService

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

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

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

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

konghaorui committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    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
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
    /**
     * 获取专家主页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
86 87
    fun personalInfoIntent(activity: Activity){
        getAppService().personalInfoIntent(activity)
konghaorui committed
88 89 90 91 92 93
    }

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

    fun startPicker(activity: AppCompatActivity, openCamera: Boolean, callback: PickerCallback) {
        YdlImagePicker.startPicker(activity, openCamera, callback)
    }

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