package com.yidianling.tests.router

import android.app.Activity
import android.content.Intent
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlUserInfo
import com.yidianling.router.RouterManager
import com.yidianling.router.im.IMRequestCallback
import com.yidianling.tests.api.service.ITestsApiService
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.service.IUserService

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

    fun getTestsImpl(): ITestsApiService {
        return ModularServiceManager.provide(ITestsApiService::class.java)
    }
    fun isLogin(): Boolean {
        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()
    }

    fun loginWayIntent(activity: Activity): Intent? {
        return  ModularServiceManager.provide(IUserService::class.java).loginWayIntent(activity)
    }

    fun publishTrendIntent(activity: Activity, url: String, cover: String, title: String): Intent? {
        return RouterManager.getDynamicRouter()?.publishTrendIntent(activity, url, cover, title)
    }

    fun sendTestResultMessage(uid : String,content : String,title: String?,head : String?,url : String?,id : Int,share_url : String?, callback: IMRequestCallback<Void>) {
        RouterManager.getImRouter().sendTestResultMessage(uid, content, title, head, url, id, share_url, callback)
    }

    /**
     * 跳转红包
     */
    fun myRedPockIntent(activity: Activity){
        activity.startActivity(RouterManager.getAppRouter()?.myRedPockIntent(activity))
    }
}