TestsIn.kt 2.83 KB
Newer Older
konghaorui committed
1 2 3
package com.yidianling.tests.router

import android.app.Activity
4
import android.content.Context
konghaorui committed
5
import android.content.Intent
6 7
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlUserInfo
konghaorui committed
8 9 10
import com.yidianling.dynamic.api.IDynamicService
import com.yidianling.im.api.bean.IMRequestCallback
import com.yidianling.im.api.service.IImService
11 12
import com.yidianling.tests.api.service.ITestsApiService
import com.yidianling.user.api.bean.UserResponseBean
konghaorui committed
13
import com.yidianling.user.api.service.IAppService
14
import com.yidianling.user.api.service.IUserService
konghaorui committed
15 16 17 18 19 20 21 22

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

konghaorui committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    fun getUserService(): IUserService {
        return ModularServiceManager.provide(IUserService::class.java)
    }

    fun getImService(): IImService {
        return ModularServiceManager.provide(IImService::class.java)
    }

    fun getAppService(): IAppService {
        return ModularServiceManager.provide(IAppService::class.java)
    }

    fun getDynamicService(): IDynamicService {
        return ModularServiceManager.provide(IDynamicService::class.java)
    }

39 40 41
    fun getTestsImpl(): ITestsApiService {
        return ModularServiceManager.provide(ITestsApiService::class.java)
    }
konghaorui committed
42
    fun isLogin(): Boolean {
43 44 45 46 47 48 49 50 51
        return ModularServiceManager.provide(IUserService::class.java).isLogin()
    }

    fun getYDLUserInfo(): YdlUserInfo? {
        return ModularServiceManager.getPlatformUserService()?.getUser()
    }

    fun getUserInfo(): UserResponseBean.UserInfo? {
        return ModularServiceManager.provide(IUserService::class.java).getUserInfo()
konghaorui committed
52 53 54
    }

    fun loginWayIntent(activity: Activity): Intent? {
55
        return  ModularServiceManager.provide(IUserService::class.java).loginWayIntent(activity)
konghaorui committed
56 57 58
    }

    fun publishTrendIntent(activity: Activity, url: String, cover: String, title: String): Intent? {
konghaorui committed
59
        return getDynamicService()?.publishTrendIntent(activity, url, cover, title)
konghaorui committed
60 61 62
    }

    fun sendTestResultMessage(uid : String,content : String,title: String?,head : String?,url : String?,id : Int,share_url : String?, callback: IMRequestCallback<Void>) {
konghaorui committed
63
        getImService().sendTestResultMessage(uid, content, title, head, url, id, share_url, callback)
konghaorui committed
64 65 66 67 68 69
    }

    /**
     * 跳转红包
     */
    fun myRedPockIntent(activity: Activity){
konghaorui committed
70
        getAppService().myRedPockIntent(activity)
konghaorui committed
71
    }
72 73 74 75 76 77 78 79 80

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