package com.abbidot.tracker.wxapi

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.FragmentActivity
import com.abbidot.tracker.util.ThirdPartyUtil
import com.tencent.mm.opensdk.modelbase.BaseReq
import com.tencent.mm.opensdk.modelbase.BaseResp
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler

/**
 *Created  by .yzq on 2022/7/11/011.
 * @link
 * @description:封装微信Activity类
 */
open class WXBaseActivity : FragmentActivity(), IWXAPIEventHandler {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ThirdPartyUtil.mApi.handleIntent(intent, this)
        initData()
    }

    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        ThirdPartyUtil.mApi.handleIntent(intent, this)
    }

    override fun onReq(baseReq: BaseReq?) {
        baseReq?.let {
            onWXReq(it)
        }
    }

    override fun onResp(baseResp: BaseResp?) {
        baseResp?.let {
            onWXResp(it)
        }
    }

    open fun initData() {}

    /**
     * 处理微信请求回调
     */
    open fun onWXReq(baseReq: BaseReq) {}

    /**
     * 处理微信请求后返回回调
     */
    open fun onWXResp(baseResp: BaseResp) {}
}