package com.longtu.sample;

import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;


import com.bh.sdk.Interface.LTBaseSDK;
import com.bh.sdk.LTGameUserData;
import com.longtu.sdk.base.LTBaseParam;
import com.longtu.sdk.base.Listener.LTBaseCallbackCode;
import com.longtu.sdk.base.Listener.LTBaseExtendListener;
import com.longtu.sdk.base.Listener.LTBaseSDKListener;
import com.longtu.sdk.base.Listener.LTBaseSDKNoticeListener;
import com.longtu.sdk.base.Listener.LTBaseSDKPushListener;
import com.longtu.sdk.base.Listener.LTBaseUserAgreementListener;
import com.longtu.sdk.base.view.LTToast;
import com.longtu.sdk.utils.Log.Logs;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Demo 主Activity。 用户调用SDK的初始化和各个生命周期。
 */
public class LTBase_Demo_MainActivity extends Activity implements OnClickListener {

    public final static String LOGTAG = "ltbase_demo";

    // 是否需要初始化完成以后 自动登录
    public static boolean AutoLogin = false;

    public static boolean canswitchaccount;
    public static boolean canlogout;
    public static boolean cangocenter;

    private final static String gameResVer = "1";
    public static String RoleLv = "100";
    public static String RoleVipLv = "6";
    public final static String ServerName = "DEMO测试";
    public static String ServerId = "1";

    public static String LONGTU_UserName;
    public static String LONGTU_UserId;

    public static LTBase_Demo_MainActivity mMainActivity;
    private LTBase_Demo_MainView mMainView;
    private LTBase_Demo_CreatUserView mCreatUserView;
    public static LTBase_Demo_PayView mPayView = null;


    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mMainActivity = this;
        // 设置无标题(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);
        // 设置打开日志输出，出正式包时务必注释掉(SDK接口)
        LTBaseSDK.getInstance(this).setLogs(true);

//        // 切换繁体
        LTBaseSDK.getInstance(this).
                LTBaseUpdateLocale(LTBaseParam.LOCALE_TRADITIONAL_CHINESE);

        Uri data = getIntent().getData();
        Logs.i(LOGTAG, " onCreate  data = " + data);
        if (data != null) {
            String scheme = data.getScheme();
            String Host = data.getHost();
            Logs.i(LOGTAG, " onCreate  scheme = " + scheme + "  Host = " + Host);

            List<String> params = data.getPathSegments();
            String PathSegments = "";
            for (int i = 0; i < params.size(); i++) {
                PathSegments = PathSegments + params.get(i);
            }
            Logs.i(LOGTAG, " onCreate  PathSegments = " + PathSegments);

            Toast.makeText(this, "scheme = " + scheme + "  Host = " + Host + " " + PathSegments, Toast.LENGTH_LONG);
        }

        // 初始化SDK
        LTBaseSDK.getInstance(this).LTBaseSDKInit(gameResVer, new LTBaseSDKListener() {

            @Override
            public void LTBaseSDKExitgameCallBack(int arg0, String arg1) {
                // TODO Auto-generated method stub
                LTBase_Demo_MainActivity.this.finish();
            }

            @Override
            public void LTBaseSDKInitCallBack(int code, String arg1) {
                // TODO Auto-generated method stub
                if (LTBaseCallbackCode.CODE_INIT_SUCCESS == code) {
                    // 游戏实现
                    Toast.makeText(LTBase_Demo_MainActivity.this, "初始化成功 , code ==" + code, Toast.LENGTH_LONG).show();

                    if (AutoLogin) {
                        LTBaseSDK.getInstance(LTBase_Demo_MainActivity.mMainActivity).LTBaseSDKShowLoginView();
                    }
                } else {
                    Toast.makeText(LTBase_Demo_MainActivity.this, "初始化失败, code == " + code, Toast.LENGTH_LONG).show();
                }
            }

            @Override
            public void LTBaseSDKLoginCallBack(int code, String msg, LTGameUserData arg2) {
                // TODO Auto-generated method stub
                if (code == LTBaseCallbackCode.CODE_LOGIN_SUCCESS) {
                    Logs.i(LOGTAG, "MainActivity, tokenId == " + msg + ", user data == " + arg2.toString());

                    LTBase_Demo_MainActivity.LONGTU_UserId = arg2.getUid();
                    Toast.makeText(LTBase_Demo_MainActivity.this, "登陆成功", Toast.LENGTH_LONG).show();
                    // 初始化角色选择界面，游戏不需要关注
                    initGameChooseRole();
                } else {
                    Toast.makeText(LTBase_Demo_MainActivity.this, "登陆失败了, code == " + code, Toast.LENGTH_LONG).show();
                }
            }

            @Override
            public void LTBaseSDKSwitchLoginCallBack(int code, String msg, LTGameUserData userData) {
                if (code == LTBaseCallbackCode.CODE_LOGIN_SUCCESS) {
                    Logs.i(LOGTAG, "MainActivity, tokenId == " + msg + ", user data == " + userData.toString());
                    Toast.makeText(LTBase_Demo_MainActivity.this, "切换账号登陆成功", Toast.LENGTH_LONG).show();
                    // 初始化角色选择界面，游戏不需要关注
                    LTBase_Demo_MainActivity.LONGTU_UserId = userData.getUid();
                    initGameChooseRole();
                } else {
                    Toast.makeText(LTBase_Demo_MainActivity.this, "切换账号 登陆失败了, code == " + code, Toast.LENGTH_LONG).show();
                }
            }

            @Override
            public void LTBaseSDKLogoutCallBack(int arg0, String arg1) {
                // TODO Auto-generated method stub
                Toast.makeText(LTBase_Demo_MainActivity.this, "注销成功", Toast.LENGTH_SHORT).show();
                // 返回登录界面，DEMO逻辑，游戏无需关注
                initGameLogin();
            }

            @Override
            public void LTBaseSDKPayCallBack(int code, String pbid, String orderID) {
                // TODO Auto-generated method stub
                if (code == LTBaseCallbackCode.CODE_PAY_SUCCESS) {
                    Logs.i(LOGTAG, "CODE_PAY_SUCCESS code == " + code + " , pbid = " + pbid + " ,orderID = " + orderID);
                    Toast.makeText(LTBase_Demo_MainActivity.this, "花钱成功了。。。*_*", Toast.LENGTH_SHORT).show();
                } else if (code == LTBaseCallbackCode.CODE_PAY_FAIL) {
                    Logs.i(LOGTAG, "CODE_PAY_FAIL code == " + code + " , pbid = " + pbid + " ,orderID = " + orderID);
                    Toast.makeText(LTBase_Demo_MainActivity.this, "支付失败了", Toast.LENGTH_SHORT).show();
                } else if (code == LTBaseCallbackCode.CODE_PAY_CANCEL) {
                    Logs.i(LOGTAG, "CODE_PAY_CANCEL code == " + code + " , pbid = " + pbid + " ,orderID = " + orderID);
                    Toast.makeText(LTBase_Demo_MainActivity.this, "支付取消了", Toast.LENGTH_SHORT).show();
                } else if (code == LTBaseCallbackCode.CODE_PAY_UNKNOWN) {
                    Logs.i(LOGTAG, "CODE_PAY_UNKNOWN code == " + code + " , pbid = " + pbid + " ,orderID = " + orderID);
                    Toast.makeText(LTBase_Demo_MainActivity.this, "下单成功", Toast.LENGTH_SHORT).show();
                }
            }
        });


        // 设置登录公告和游戏内活动公告事件回调
        LTBaseSDK.getInstance(this).LTBaseSetSDKNoticeListener(mLTBaseSDKNoticeListener);


        // 用户协议回调注册
        LTBaseSDK.getInstance(LTBase_Demo_MainActivity.mMainActivity).LTBaseSetAgreementListener(mLTBaseUserAgreementListener);

        // 获取当前渠道SDK可选接口中哪些接口需要调用,必须放到SDK初始化后调用(SDK接口)
        canlogout = LTBaseSDK.getInstance(this).isLogoutEnable();
        canswitchaccount = LTBaseSDK.getInstance(this).isSwitchAccountEnable();
        cangocenter = LTBaseSDK.getInstance(this).isUserCenterEnable();

        // 游戏实现
        // 初始化游戏登陆界面
        initGameLogin();

        //设置 育碧 dnaid
        LTBaseSDK.getInstance(this).LTBaseSDKSetUbiDnaId("ubidnaID:1111111");


    }


    /**
     * 扩展功能回调
     */
    private LTBaseExtendListener mLTBaseExtendListener = new LTBaseExtendListener() {

        @Override
        public void extendListener(String id, String... data) {

            if (id.equals("getPayCurrency")) {
                if (data[0] == null || data[0].equals("")) {
                    Logs.i(LOGTAG, "获取道具信息 失败，拿不到实际支付获取货币 ");
                } else {

                    Logs.i(LOGTAG,
                            " 当前谷歌需要支付的货币 = " + data[0]);
                }
            } else if (id.equals("SkuDetails")) {
                if (data[0] != null || !data[0].equals("")) {
                    Logs.i(LOGTAG,
                            " SkuDetails 当前谷歌需要支付的货币列表 = " + data[0]);
                    try {
                        JSONArray propList = new JSONArray(data[0]);

                        for (int i = 0; i < propList.length(); i++) {
                            JSONObject prop = propList.getJSONObject(i);
                            String productId = prop.getString("productId");
                            String price = prop.getString("price");
                            String title = prop.getString("title");
                            String gscProductId = prop.getString("gscProductId");
                            String currency = prop.getString("currency");
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    Toast.makeText(LTBase_Demo_MainActivity.this, data[0], Toast.LENGTH_SHORT).show();

                } else {
                    Logs.i(LOGTAG, "SkuDetails 获取道具信息 失败，拿不到实际支付获取货币 ");
                }
            } else if (id.equals("LTMethodName_WeMixSign")) {
                if (data[0].equals("100")) {
                    // 签名成功
                    Logs.i(LOGTAG, "  签名成功:" + data[1]);

                    try {
                        JSONObject signJson = new JSONObject(data[1]);
                        //
                        String accessToken = signJson.getString("accessToken");
                        String address = signJson.getString("address");
                        String sign = signJson.getString("sign");
                        String userID = signJson.getString("userID");

                        Log.i(LOGTAG, " accessToken:" + accessToken + " address:" + address
                                + " sign:" + sign + " userID:" + userID);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }


                    LTToast.makeText(LTBase_Demo_MainActivity.mMainActivity, "签名成功:" + data[0], Toast.LENGTH_LONG);
                } else {
                    // 签名失败
                    Logs.i(LOGTAG, "  签名失败:" + data[1]);
                    LTToast.makeText(LTBase_Demo_MainActivity.mMainActivity, "签名失败:" + data[0], Toast.LENGTH_LONG);
                }
            } else if ("LTMethodName_CheckBindWemix".equals(id)) {
                Logs.i(LOGTAG, "  检查绑定关系:" + data[0]);

                if ("100".equals(data[0])) {
                    String wemixData = data[1];

                    Logs.i(LOGTAG,
                            " LTMethodName_CheckBindWemix 查询绑定成功 失败 ");
                    try {
                        JSONObject wemixJsonData = new JSONObject(wemixData);
                        boolean isBing = wemixJsonData.getBoolean("wemixBind");
                        String wemixAddres = wemixJsonData.getString("address");
                        if (isBing == true) {
                            LTToast.makeText(mMainActivity, "当前用户已绑定 wemixAddres:" + wemixAddres, Toast.LENGTH_SHORT);
                        } else {
                            LTToast.makeText(mMainActivity, "当前用户未绑定", Toast.LENGTH_SHORT);
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                } else {
                    Logs.i(LOGTAG,
                            " LTMethodName_CheckBindWemix 查询绑定结果 失败 ");
                    LTToast.makeText(mMainActivity, " 查询绑定结果 失败  ", Toast.LENGTH_SHORT);
                }

            } else if ("LTMethodName_BindWemix".equals(id)) {
                Logs.i(LOGTAG, "  绑定结果:" + data[0]);
                if ("100".equals(data[0])) {
                    String wemixData = data[1];
                    Logs.i(LOGTAG,
                            " LTMethodName_BindWemix 查询绑定成功 失败 ");
                    try {
                        JSONObject wemixJsonData = new JSONObject(wemixData);
                        String wemixAddres = wemixJsonData.getString("address");
                        String accessToken = wemixJsonData.getString("accessToken");
                        LTToast.makeText(mMainActivity, "当前用户已绑定 wemixAddres:" + wemixAddres
                                + " accessToken:" + accessToken, Toast.LENGTH_SHORT);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                } else {
                    Logs.i(LOGTAG,
                            " LTMethodName_BindWemix 绑定结果 失败 ");
                    LTToast.makeText(mMainActivity, "绑定结果 失败", Toast.LENGTH_SHORT);
                }

            }

        }
    };


    /**
     * 用户协议。
     */
    private LTBaseUserAgreementListener mLTBaseUserAgreementListener = new LTBaseUserAgreementListener() {

        @Override
        public void UserAgreementOpen() {

        }

        @Override
        public void UserAgreementResult(boolean b, JSONObject jsonObject) {
            Log.i(LOGTAG, "UserAgreementResult: b = " + b + " jsonObject = " + jsonObject);
        }
    };


    /**
     * 获取当前需要支付货币，只适用于谷歌。
     *
     * @param data
     */
    private void explainSkuDetails(String data) {
        Logs.i(LOGTAG,
                " sku  getPayCurrency = " + data);

    }

    /**
     * 登录公告和游戏内活动公告打开关闭事件
     */
    private LTBaseSDKNoticeListener mLTBaseSDKNoticeListener = new LTBaseSDKNoticeListener() {

        /**
         * 登录公告打开事件，只有页面存在的时候，才会有打开的效果
         */
        @Override
        public void LTBaseSDKLoginNoticeStart() {
            Toast.makeText(LTBase_Demo_MainActivity.this, " 登录公告打开事件 ", Toast.LENGTH_SHORT).show();
        }

        /**
         * 登录公告关闭事件
         */
        @Override
        public void LTBaseSDKLoginNoticeClose() {
            Toast.makeText(LTBase_Demo_MainActivity.this, " 登录公告关闭事件 ", Toast.LENGTH_SHORT).show();
        }

        /**
         * 登录公告不存在，
         * 调用打开公告接口的时候，发现公告不存在的时候被调用
         */
        @Override
        public void LTBaseSDKNoLoginNotice() {
            Toast.makeText(LTBase_Demo_MainActivity.this, " 登录公告不存在 ", Toast.LENGTH_SHORT).show();
        }

        /**
         * 活动公告打开事件，只有页面存在的时候，才会有打开的效果
         */
        @Override
        public void LTBaseSDKActivityNoticeStart() {
            Toast.makeText(LTBase_Demo_MainActivity.this, " 活动公告打开事件 ", Toast.LENGTH_SHORT).show();
        }

        /**
         * 活动公告关闭事件
         */
        @Override
        public void LTBaseSDKNoActivityNotice() {
            Toast.makeText(LTBase_Demo_MainActivity.this, " 活动公告不存在 ", Toast.LENGTH_SHORT).show();
        }

        /**
         * 活动公告不存在，
         * 调用打开公告接口的时候，发现公告不存在的时候被调用
         */
        @Override
        public void LTBaseSDKActivityNoticeClose(String data) {
            Toast.makeText(LTBase_Demo_MainActivity.this, " 活动公告关闭事件 ", Toast.LENGTH_SHORT).show();
        }
    };

    /**
     * 初始化登陆界面
     */
    private void initGameLogin() {
        System.gc();
        mMainView = new LTBase_Demo_MainView(this);
        setContentView(mMainView);
        LTBaseSDK.getInstance(this).LTBaseSendGameProcess(LTBaseParam.GAME_PROCESS_EVENT_TYPE_IN_SELECT_SERVERLIST);
        if (mPayView != null) {
            mPayView.removeAllViews();
            mPayView = null;
        }
        if (mCreatUserView != null) {
            mCreatUserView.removeAllViews();
            mCreatUserView = null;
        }

    }

    /**
     * 初始化选择角色界面
     */
    private void initGameChooseRole() {
        System.gc();
        mCreatUserView = new LTBase_Demo_CreatUserView(this, new LTBase_Demo_CreatUserView.InGameCallback() {

            @Override
            public void InGame() {
                // TODO Auto-generated method stub
                initInGame();
            }
        });
        setContentView(mCreatUserView);

        if (mPayView != null) {
            mPayView.removeAllViews();
            mPayView = null;

            // 从主页面回来的，直接回到了 切换角色页面，所以这里也做一个选择角色服务器的事件
            LTBaseSDK.getInstance(this).LTBaseSendGameProcess(LTBaseParam.GAME_PROCESS_EVENT_TYPE_IN_SELECT_SERVERLIST);
        }
        if (mMainView != null) {
            mMainView.removeAllViews();
            mMainView = null;
        }

    }

    /**
     * 初始化游戏中
     */
    private void initInGame() {
        System.gc();
        mPayView = new LTBase_Demo_PayView(this);
        setContentView(mPayView);
        LTBaseSDK.getInstance(this).LTBaseSendGameProcess(LTBaseParam.GAME_PROCESS_EVENT_TYPE_OUT_SELECT_SERVERLIST);
        if (mMainView != null) {
            mMainView.removeAllViews();
            mMainView = null;
        }
        if (mCreatUserView != null) {
            mCreatUserView.removeAllViews();
            mCreatUserView = null;
        }

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub
        Logs.i(LOGTAG, "onKeyDown  keyCode = " + keyCode + " event getRepeatCount = " + event.getRepeatCount());
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            // (SDK接口)
            if (mPayView != null && mPayView.mAnalyticslayout != null) {
                mPayView.mAnalyticslayout.onKeyDown(keyCode, event);
            } else if (mPayView != null && mPayView.mShareView != null) {
                mPayView.mShareView.onKeyDown(keyCode, event);
            } else {
                LTBaseSDK.getInstance(this).LTBaseSDKExitGame();
            }

            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onClick(View view) {
        // TODO Auto-generated method stub

    }

    /**
     * 保存数据到应用手机内存，DEMO使用的方法
     *
     * @param context
     * @param b
     * @param filename
     */
    public static boolean SaveDataToPhone(Context context, byte[] b, String filename) {
        try {
            FileOutputStream fos = context.openFileOutput(filename, Context.MODE_APPEND);
            DataOutputStream dos = new DataOutputStream(fos);
            try {
                dos.write(b);
                dos.close();
                fos.close();
                return true;
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Logs.i(LOGTAG, "SaveDataToPhone is err , e == " + e);
            }
            dos = null;
            fos = null;
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Logs.i(LOGTAG, "SaveDataToPhone is err , e == " + e);
        }
        return false;
    }

    /**
     * 从应用手机内存中获取数据，DEMO使用的方法
     *
     * @param context
     * @param filename
     * @return
     */
    public static byte[] GetDataFromPhone(Context context, String filename) {
        byte[] b = null;
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            FileInputStream fis = context.openFileInput(filename);
            DataInputStream dis = new DataInputStream(fis);
            try {
                int a = -1;
                while ((a = dis.read()) != -1) {
                    bos.write(a);
                }
                if (bos.size() > 0) {
                    b = bos.toByteArray();
                }
                bos.close();
                dis.close();
                fis.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Logs.i(LOGTAG, "GetDataFromPhone is err , e == " + e);
            }
            bos = null;
            dis = null;
            fis = null;
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            Logs.i(LOGTAG, "GetDataFromPhone is err , e == " + e);
        }
        return b;
    }

    // ////////////////////////////////////一下为Activity生命周期的调用//////////////////////

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        Logs.i(LOGTAG, "onPause");
        // 必须调用
        LTBaseSDK.getInstance(this).onPause();
    }

    @Override
    protected void onRestart() {
        // TODO Auto-generated method stub
        super.onRestart();
        Logs.i(LOGTAG, "onRestart");
        // 必须调用
        LTBaseSDK.getInstance(this).onRestart();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        Logs.i(LOGTAG, "onResume");
        // 必须调用
        LTBaseSDK.getInstance(this).onResume();

        // 设置扩展功能回调
        LTBaseSDK.getInstance(this).LTBaseSDKSetExtendListener(mLTBaseExtendListener);
    }

    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
        Logs.i(LOGTAG, "onStart");
        // 必须调用
        LTBaseSDK.getInstance(this).onStart();
    }

    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        Logs.i(LOGTAG, "onStop");
        // 必须调用
        LTBaseSDK.getInstance(this).onStop();
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
        Logs.i(LOGTAG, "onDestroy");
        // 必须调用
        LTBaseSDK.getInstance(this).onDestroy();
        // 杀掉进程（游戏可以在onDestroy方法中杀掉进程）
        android.os.Process.killProcess(android.os.Process.myPid());
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        Logs.i(LOGTAG, "onActivityResult");

        // 图片选择完成
        if (requestCode == 12345 && resultCode == RESULT_OK) {
            Uri uri = data.getData();
            Logs.i(LOGTAG, " uri =  " + LTBase_Demo_ImagePath.getPath(LTBase_Demo_MainActivity.this, uri));
            PhotoShare(LTBase_Demo_ImagePath.getPath(LTBase_Demo_MainActivity.this, uri));
        } else if (requestCode == LTBase_Demo_ShareView.Image_requestCode && resultCode == RESULT_OK) {
            if (mPayView != null && mPayView.mShareView != null) {
                Uri uri = data.getData();
                mPayView.mShareView.share_image(LTBase_Demo_ImagePath.getPath(LTBase_Demo_MainActivity.this, uri));
            }

        } else {
            Logs.i(LOGTAG, "onActivityResult");
            // 必须调用
            LTBaseSDK.getInstance(this).onActivityResult(requestCode, resultCode, data);
        }
    }

    private void PhotoShare(String imagepath) {


    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        // TODO Auto-generated method stub
        super.onConfigurationChanged(newConfig);
        Logs.i(LOGTAG, "onConfigurationChanged");
        // 必须调用
        LTBaseSDK.getInstance(this).onConfigurationChanged(newConfig);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        // TODO Auto-generated method stub
        super.onNewIntent(intent);
        Logs.i(LOGTAG, "onNewIntent");
        // 必须调用
        LTBaseSDK.getInstance(this).onNewIntent(intent);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        LTBaseSDK.getInstance(this).onBackPressed();
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        // TODO Auto-generated method stub
        super.attachBaseContext(newBase);
        LTBaseSDK.getInstance(this).attachBaseContext(newBase);
    }


    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        LTBaseSDK.getInstance(this).onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}
