package com.longtu.sample;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import com.acegameproject.burstshooter.R;
import com.bh.sdk.Interface.LTBaseSDK;

import java.util.HashMap;

/**
 * 测试游戏打点功能
 * 作者：liqingshuo on 2019-08-07 19:35
 *
 * @author liqingshuo
 */
public class LTBase_Demo_BITest extends Activity implements View.OnClickListener {


    private Button mRoleIncomeUpdate;
    private Button mRoleItemUpdate;
    private Button mRolePropUpdate;
    private Button mRoleItemPropUpdate;
    private Button mRoleCardPropUpdate;
    private Button mRoleTask;
    private Button mRoleStage;
    private Button mRoleAct;
    private Button mRoleInteract;

    private Button mResourceUpdateStart;
    private Button mResourceUpdateSuccess;
    private Button mResourceUpdateFail;
    private Button mResourceUnzipStart;
    private Button mResourceUnzipSuccess;
    private Button mResourceUnzipFail;

    private Button mGameSelectServerSuccess;
    private Button mGameSelectServerFail;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // 设置无标题(DEMO代码)
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        // // 设置全屏幕(DEMO代码)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        int currentApiVersion = Build.VERSION.SDK_INT;
        if (currentApiVersion >= 14) {
            WindowManager.LayoutParams params = getWindow().getAttributes();
            params.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
            getWindow().setAttributes(params);
        }

        // 强制使屏幕一直处于活动状态，不关闭背景光(DEMO代码)
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        setContentView(R.layout.longtu_demo_bitest);

        uiInit();
    }

    /**
     * 初始化button
     */
    private void uiInit() {
        this.mRoleIncomeUpdate = (Button) findViewById(R.id.role_income_update);
        this.mRoleItemUpdate = (Button) findViewById(R.id.role_item_update);
        this.mRolePropUpdate = (Button) findViewById(R.id.role_prop_update);
        this.mRoleItemPropUpdate = (Button) findViewById(R.id.role_item_prop_update);
        this.mRoleCardPropUpdate = (Button) findViewById(R.id.role_card_prop_update);
        this.mRoleTask = (Button) findViewById(R.id.role_task);
        this.mRoleStage = (Button) findViewById(R.id.role_stage);
        this.mRoleAct = (Button) findViewById(R.id.role_act);
        this.mRoleInteract = (Button) findViewById(R.id.role_interact);

        this.mResourceUpdateStart = (Button) findViewById(R.id.resource_update_start);

        this.mResourceUpdateSuccess = (Button) findViewById(R.id.resource_update_success);
        this.mResourceUpdateFail = (Button) findViewById(R.id.resource_update_fail);
        this.mResourceUnzipStart = (Button) findViewById(R.id.resource_unzip_start);
        this.mResourceUnzipSuccess = (Button) findViewById(R.id.resource_unzip_success);
        this.mResourceUnzipFail = (Button) findViewById(R.id.resource_unzip_fail);

        this.mGameSelectServerSuccess = (Button) findViewById(R.id.game_select_server_success);
        this.mGameSelectServerFail = (Button) findViewById(R.id.game_select_server_fail);

        this.mRoleIncomeUpdate.setOnClickListener(this);
        this.mRoleItemUpdate.setOnClickListener(this);
        this.mRolePropUpdate.setOnClickListener(this);
        this.mRoleItemPropUpdate.setOnClickListener(this);
        this.mRoleCardPropUpdate.setOnClickListener(this);
        this.mRoleTask.setOnClickListener(this);
        this.mRoleStage.setOnClickListener(this);
        this.mRoleAct.setOnClickListener(this);
        this.mRoleInteract.setOnClickListener(this);
        this.mResourceUpdateStart.setOnClickListener(this);
        this.mResourceUpdateSuccess.setOnClickListener(this);
        this.mResourceUpdateFail.setOnClickListener(this);
        this.mResourceUnzipStart.setOnClickListener(this);
        this.mResourceUnzipSuccess.setOnClickListener(this);
        this.mResourceUnzipFail.setOnClickListener(this);
        this.mGameSelectServerSuccess.setOnClickListener(this);
        this.mGameSelectServerFail.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v == this.mRoleIncomeUpdate) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", 111);
            map.put("roleVipLevel", 1222);
            map.put("updateType", "0");
            map.put("itemId", "diamond");
            map.put("itemName", "钻石");
            map.put("isPrecious", "1");
            map.put("itemCount", "100");
            map.put("remains", "2000");
            map.put("custom", "购买道具");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("91", "role-income-update", map);
//            HashMap<String, Object> map = new HashMap<String, Object>();
//            map.put("actId", "chstatus");
//            map.put("actName", "选择状态");
//            map.put("categoryId", "global_GDPR");
//            map.put("categoryName", "全球版 GDPR协议");
//            map.put("detail", "0");
//            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("5001", "sdkclient_global_GDPR", map);

        } else if (v == this.mRoleItemUpdate) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", "1");
            map.put("roleVipLevel", "0");
            map.put("updateType", "0");
            map.put("itemId", "diamond");
            map.put("itemName", "钻石");
            map.put("itemCount", "100");
            map.put("remains", "255");
            map.put("custom", "购买");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("9", "role-item-update", map);

        } else if (v == this.mRolePropUpdate) {
            HashMap<String, Object> map = new HashMap<String, Object>();

            map.put("roleLevel", "3");
            map.put("roleVipLevel", "0");
            map.put("propKey", "level");
            map.put("propValue", "3");
            map.put("rangeability", "2");
            map.put("custom", "");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("10", "role-prop-update", map);

        } else if (v == this.mRoleItemPropUpdate) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", "1");
            map.put("roleVipLevel", "0");
            map.put("itemId", "tank_m4");
            map.put("itemName", "M4谢尔曼中型坦克");
            map.put("propKey", "level");
            map.put("propValue", "3");
            map.put("rangeability", "1");
            map.put("custom", "强化装备");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("13", "role-item-prop-update", map);

        } else if (v == this.mRoleCardPropUpdate) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", "1");
            map.put("roleVipLevel", "0");
            map.put("cardId", "blr_man_001");
            map.put("cardName", "李星云");
            map.put("propKey", "level");
            map.put("newValue", "蓝+1");
            map.put("oldValue", "绿");
            map.put("custom", "强化装备");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("14", "role-card-prop-update", map);

        } else if (v == this.mRoleTask) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", 12333);
            map.put("roleVipLevel", 132321);
            map.put("taskId", "newbieguide1");
            map.put("taskName", "新手引导流程1");
            map.put("detail", "accept");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("1001", "role-task", map);

        } else if (v == this.mRoleStage) {

            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", "10");
            map.put("roleVipLevel", "2");
            map.put("stageId", "DeadminesIstanc");
            map.put("stageName", "死亡矿井");
            map.put("detail", "begin");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("1002", "role-stage", map);

        } else if (v == this.mRoleAct) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", "10");
            map.put("roleVipLevel", "2");
            map.put("actId", "fight.mineer");
            map.put("actName", "战斗.狗头人矿工");
            map.put("detail", "begin");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("1003", "role-act", map);

        } else if (v == this.mRoleInteract) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("roleLevel", "10");
            map.put("roleVipLevel", "2");
            map.put("interactId", "addfriend");
            map.put("interactName", "添加好友");
            map.put("targetType", "1");
            map.put("targetCode", "0010000067543");
            map.put("targetInfo", "珍妮佛");
            map.put("detail", "ENTER");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("2001", "role-interact", map);
        } else if (v == this.mResourceUpdateStart) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("actId", "0001");
            map.put("actName", "热更下载");
            map.put("dataName", "测试资源");
            map.put("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("dataCDNIP", "192.168.1.1");
            map.put("state", "1");
            map.put("detail", "测试下载开始");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4001", "resource-update-start", map);
        } else if (v == this.mResourceUpdateSuccess) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("actId", "0001");
            map.put("actName", "热更下载");
            map.put("dataName", "测试资源");
            map.put("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("dataCDNIP", "192.168.1.1");
            map.put("state", "2");
            map.put("detail", "success");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4002", "resource-update-success", map);
        } else if (v == this.mResourceUpdateFail) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("actId", "0001");
            map.put("actName", "热更下载");
            map.put("dataName", "测试资源");
            map.put("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("dataCDNIP", "192.168.1.1");
            map.put("state", "3");
            map.put("detail", "测试下载失败日志");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4003", "resource-update-fail", map);
        } else if (v == this.mResourceUnzipStart) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("actId", "0002");
            map.put("actName", "热更解压");
            map.put("dataName", "测试资源");
            map.put("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("dataCDNIP", "192.168.1.1");
            map.put("state", "1");
            map.put("detail", "解压开始");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4004", "resource-unzip-start", map);
        } else if (v == this.mResourceUnzipSuccess) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("actId", "0002");
            map.put("actName", "热更解压");
            map.put("dataName", "测试资源");
            map.put("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("dataCDNIP", "192.168.1.1");
            map.put("state", "2");
            map.put("detail", "success");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4005", "resource-unzip-success", map);
        } else if (v == this.mResourceUnzipFail) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("actId", "0002");
            map.put("actName", "热更解压");
            map.put("dataName", "测试资源");
            map.put("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("dataCDNIP", "192.168.1.1");
            map.put("state", "3");
            map.put("detail", "测试解压失败日志");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4006", "resource-unzip-fail", map);
        } else if (v == this.mGameSelectServerSuccess) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("uid", "0002");
            map.put("state", "2");
            map.put("detail", "success");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4007", "game-select-server", map);
        } else if (v == this.mGameSelectServerFail) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("uid", "0002");
            map.put("state", "3");
            map.put("detail", "测试选服失败日志");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4007", "game-select-server", map);
        }
    }


}
