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.bh.sdk.Interface.LTBaseSDK;
import com.longtugame.globalsample.R;

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;

    @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.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);

    }

    @Override
    public void onClick(View v) {
        if (v == this.mRoleIncomeUpdate) {
            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("isPrecious", "1");
            map.put("itemCount", "100");
            map.put("remains", "2000");
            map.put("custom", "购买道具");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("91", "role-income-update", 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", "10");
            map.put("roleVipLevel", "2");
            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("dataPath", "https://www.longtubus.com/xxxx.zip");
            map.put("detail", "update");
            LTBaseSDK.getInstance(this).LTBaseSDKSendGameInfoLog("4001", "resource-update-start", map);
        }
    }


}
