package com.zswc.creativity.component

import com.billy.cc.core.component.CC
import com.billy.cc.core.component.CCResult
import com.billy.cc.core.component.IComponent
import com.hwangjr.rxbus.RxBus
import com.zswc.creativity.config.ConfigRx
import com.zswc.creativity.utils.VerifyUtils
import com.ysnows.base.ccextension.BIComponent
import com.ysnows.base.model.PositionBean


open class CpApp() : IComponent, BIComponent() {


    fun setLogin(cc: CC, token: String): Boolean {


        RxBus.get().post(ConfigRx.ADD_ONELOGIN, token)

        CC.sendCCResult(cc.callId, CCResult.success())

        return false
    }


    fun setDatas(cc: CC, item: PositionBean): Boolean {

        var areaname = item.areaname

        RxBus.get().post(ConfigRx.ADD_POSITION, item)

        CC.sendCCResult(cc.callId, CCResult.success())

        return false
    }

    fun openMsgList(cc: CC, url: String): Boolean {//打开消息列表

        VerifyUtils.isAndroidUrl(url,cc.context,true)

//        try {
//            if (url.contains("?")) {
//
//                val i = Intent(cc.context, Class.forName(StringUtils.getPureUrl(url)))
//                val bundle = StringUtils.getUrlBundle(url)
//                i.putExtras(bundle!!)
//                i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
//                cc.context.startActivity(i)
//
//            } else {
//
//                val i = Intent(cc.context, Class.forName(url))
//                i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
//                cc.context.startActivity(i)
//
//
//            }
//        } catch (e: ClassNotFoundException) {
//            e.printStackTrace();
//        }

//        try {
//            //打开自定义的Activity
//            val i = Intent(cc.context, MsgActivity::class.java)
//            val bundle = Bundle()
//            i.putExtras(bundle)
//            //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
//            cc.context.startActivity(i)
//        } catch (throwable: Throwable) {
//        }


        CC.sendCCResult(cc.callId, CCResult.success())
        return false
    }


}
