package com.yythird.base;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;

import com.yyrh.constant.RoleInfo;
import com.yyrh.utils.ResourceUtil;

import org.json.JSONObject;

import java.util.HashMap;

public class BaseSDK {
    protected BaseSDK() {
    }

    private Activity mActivity;

    private ChannelSdkCallback callback;

    //SDK用户操作
    public void SDKInit(Activity activity, ChannelSdkCallback sdkCallback) {
        mActivity = activity;
        callback = sdkCallback;
    }

    public void SDKLogin(Activity activity, ChannelSdkCallback sdkCallback) {
    }

    public void setSDKLogoutListener(Activity activity, ChannelSdkCallback sdkCallback) {
    }

    public void SDKLogout() {
        getSdkCallback().onLogOutCallback("game logout");
    }

    ;

    public void SDKPay(Activity activity, HashMap<String, Object> map, ChannelSdkCallback sdkCallback) {
    }

    public String SDKGetOrderExt() {
        return "";
    }

    public String SDKGetPkgExt(Context context) {
        return "";
    }

    public void SDKGetOaid() {
        getSdkCallback().onGetOaidCallback(false, "");
    }

    public boolean SDKGetPstatus() {
        return false;
    }

    public void SDKInitSuccess(String msg) {
    }

    public void SDKInitFail(String msg) {
    }

    public void SDKLoginChannelFail(String msg) {
    }

    public void SDKLoginChannelSuccess(String msg) {
    }

    public void SDKUploadInfo(String type, Activity activity, RoleInfo roleInfo) {
    }

    public void SDKReportAdInfo(String event, JSONObject json) {

    }

    public void SDKExit(Activity activity, final ChannelSdkCallback sdkCallback) {
        String tip = activity.getString(ResourceUtil.getStringId(activity, "yyrh_exit_tip"));
        String message = activity.getString(ResourceUtil.getStringId(activity, "yyrh_issure_exit"));
        String left = activity.getString(ResourceUtil.getStringId(activity, "yyrh_sure"));
        String right = activity.getString(ResourceUtil.getStringId(activity, "yyrh_cancel"));
        new AlertDialog.Builder(activity)
                .setTitle(tip)
                .setMessage(message)
                .setPositiveButton(left, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        sdkCallback.onExiGameCallback(true, "");
                    }
                })
                .setNegativeButton(right, null)
                .show();
    }

    //生命周期
    public void onCreate(Activity activity, Bundle savedInstanceState) {
    }

    public void onNewIntent(Activity activity, Intent intent) {
    }

    public void onStart(Activity activity) {
    }

    public void onStop(Activity activity) {
    }

    public void onPause(Activity activity) {
    }

    public void onResume(Activity activity) {
    }

    public void onRestart(Activity activity) {
    }

    public void onDestroy(Activity activity) {
    }

    public void onConfigurationChanged(Configuration newConfigs) {
    }

    public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
    }

    public void onWindowFocusChanged(Activity activity, boolean hasFocus) {
    }

    public void onGetChannelRealNameInfo(Activity activity) {
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    }

    final public ChannelSdkCallback getSdkCallback() {
        return callback;
    }

    final public Activity getActivity() {
        return mActivity;
    }

}
