package com.fq.channel.sdk.api;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.fq.channel.sdk.api.bean.LoginInfo;
import com.fq.channel.sdk.api.bean.PaymentInfo;
import com.fq.channel.sdk.base.utils.FqLog;
import com.fq.channel.sdk.core.JointManager;
import com.fq.channel.sdk.core.invoke.ApiPlugin;

/**
 * @Description: 提供给CP访问的接口类
 * @Author: FLuty
 * @CreateDate: 2020/3/24 11:21
 */
public class FqGame {

    private static final String TAG = "FqGame";

    /**
     * 提过给CP调用的初始化接口
     *
     * @param activity
     * @param resultInit
     */
    public static void init(@NonNull Activity activity, final IResult<String> resultInit) {
        FqLog.i(TAG, "init");
        FqGameHander.init(activity,resultInit);
    }

    /**
     * 提供给CP调用登录的接口
     *
     * @param activity
     */
    public static void login(@NonNull Activity activity, final IResult<LoginInfo> resultLoginInfo) {
        FqLog.i(TAG, "login");
        FqGameHander.login(activity,resultLoginInfo);
    }

    /**
     * 提供给CP调用的支付接口
     *
     * @param activity
     * @param paymentInfo CP传入的订单信息
     * @param resultPay
     */
    public static void pay(@NonNull Activity activity, @NonNull final PaymentInfo paymentInfo, final IResult<String> resultPay) {
        FqLog.i(TAG, "pay");
        FqGameHander.pay(activity, paymentInfo, resultPay);
    }

    /**
     * 提供给CP调用角色信息上报的接口
     *
     * @param activity
     * @param result
     */
    public static void exit(Activity activity,IExit result){
        FqGameHander.exit(activity,result);
    }

    /**
     * 提供给CP调用角色信息上报的接口
     *
     * @param mBundle
     */
    public static void setRoleInfo(Bundle mBundle){
        JointManager.getInstance().setRoleInfo(mBundle);
    }

    /**
     * onRequestPermissionsResult
     *
     */
    public static void onRequestPermissionsResult(int requestCode,
                                                  String[] permissions, int[] grantResults){
        FqGameHander.onRequestPermissionsResult(requestCode,permissions,grantResults);
        ApiPlugin.getInstace().onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    public  static void onCreate(Bundle savedInstanceState) {
        FqLog.i(TAG, "onCreate: ");
        ApiPlugin.getInstace().onCreate(savedInstanceState);
    }

    public static void onRestart() {
        FqLog.i(TAG, "onRestart: ");
        ApiPlugin.getInstace().onRestart();
    }

    public static void onStart() {
        FqLog.i(TAG, "onStart: ");
        ApiPlugin.getInstace().onStart();
    }

    public static void onResume() {
        FqLog.i(TAG, "onResume: ");
        ApiPlugin.getInstace().onResume();
    }

    public static void onPause() {
        FqLog.i(TAG, "onPause: ");
        ApiPlugin.getInstace().onPause();

    }

    public static void onStop() {
        FqLog.i(TAG, "onStop: ");
        ApiPlugin.getInstace().onStop();
    }

    public static void onDestroy() {
        FqLog.i(TAG, "onDestroy: ");
        ApiPlugin.getInstace().onDestroy();
    }

    public static void onSaveInstanceState(Bundle outState) {
        FqLog.i(TAG, "onSaveInstanceState: ");
        ApiPlugin.getInstace().onSaveInstanceState(outState);
    }

    public static void onNewIntent(Intent intent) {
        FqLog.i(TAG, "onNewIntent: ");
        ApiPlugin.getInstace().onNewIntent(intent);
    }

    public static void onActivityResult(int requestCode, int resultCode, Intent data) {
        FqLog.i(TAG, "onActivityResult: ");
        ApiPlugin.getInstace().onActivityResult(requestCode, resultCode, data);
    }

}
