package com.yidianling.user.route

import android.app.Activity
import android.content.Context
import android.content.Intent
import com.ydl.audioim.api.AudioImApi
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.router.RouterManager
import com.yidianling.router.im.IMLoginInfo
import com.yidianling.router.im.IMRequestCallback

/**
 * author : Zhangwenchao
 * e-mail : zhangwch@yidianling.com
 * time   : 2018/02/05
 */
object UserIn {

    fun mainIntent(activity: Activity): Intent? {
        return RouterManager.getAppRouter()?.mainIntent(activity)
    }
    fun mainIntent(context: Context, selectTab: Int): Intent? {
        return RouterManager.getAppRouter()?.mainIntent(context, selectTab, false)
    }

    fun imSetAccount(account: String) {
        RouterManager.getImRouter().setAccount(account)
    }


    fun splashIntent(activity: Activity): Intent? {
        return RouterManager.getAppRouter()?.splashIntent(activity)
    }

    fun setChattingAccountAll() {
        RouterManager.getImRouter().setChattingAccountAll()
    }

    fun setChattingAccountNone() {
        RouterManager.getImRouter().setChattingAccountNone()
    }

    fun imLogin(info: IMLoginInfo, callback: IMRequestCallback<IMLoginInfo>) {
        RouterManager.getImRouter().login(info, callback)
    }

    fun imLogout() {
        RouterManager.getImRouter().logout()
    }

    // 关闭音频播放
    fun closePlayer() {
        RouterManager.getCourseRouter()?.closePlayer()
        RouterManager.getFMRouter()?.closePlayer()
        RouterManager.getPhoneCallRouter()?.closePlayer()
    }

    // 清除 im 数据
    fun clearImData() {
        RouterManager.getImRouter().clear()
    }
    // 获取 声网 api
    fun getAvImApi(): AudioImApi{
        return ModularServiceManager.provide(AudioImApi::class.java)
    }

}