package prj.chameleon.huawei;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;

import com.huawei.gamebox.buoy.sdk.IGameCallBack;
import com.huawei.gamebox.buoy.sdk.UpdateInfo;
import com.huawei.gamebox.buoy.sdk.util.DebugConfig;

import prj.chameleon.channelapi.Constants;
import prj.chameleon.channelapi.IDispatcherCb;

class GameCallback implements IGameCallBack {

    private Context mContext = null;
    private IDispatcherCb mCb = null;

    protected GameCallback(Context activity, IDispatcherCb cb) {
        mContext = activity;
        mCb = cb;
    }

    @Override
    public void onInitStarted() {
        //mCb.onFinished(Constants.ErrorCode.ERR_OK, null);
    }

    @Override
    public void onInitFailed(int errorCode) {
        mCb.onFinished(Constants.ErrorCode.ERR_FAIL, null);
    }

    /**
     * 初始化成功类
     */
    @Override
    public void onInitSuccessed() {
        mCb.onFinished(Constants.ErrorCode.ERR_OK, null);
    }

    @Override
    public void onValidFail() {

    }

    @Override
    public void onShowSuccssed() {
    }

    @Override
    public void onShowFailed(int errorCode) {
        Log.e(Constants.TAG, "Fail to show window " + errorCode);
    }

    @Override
    public void onHidenSuccessed() {
    }

    @Override
    public void onHidenFailed(int errorCode) {
        Log.e(Constants.TAG, "Fail to hide window " + errorCode);
    }

    @Override
    public void onDestoryed() {
    }

    /**
     * 应用更新检查回调函数
     */
    @Override
    public void onUpdateCheckFinished(UpdateInfo info) {
        // 根据业务需要设置，demo中只在登录界面展示更新信息
        if (null == info) {
            DebugConfig.d(Constants.TAG, "IGameCallBack onUpdateCheckFinished:无更新信息");
            return;
        }
        DebugConfig.d(Constants.TAG, "IGameCallBack onUpdateCheckFinished:UpdateInfo="
                + info.toString());

        // 如有需要则提示用户是否更新，可针对提示方式和界面自行修改，如不需要SDK更新则忽略此逻辑不处理即可
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        dialog.setTitle("更新提示")
                .setMessage("更新内容：" + info.toString())
                .setPositiveButton("更新", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        // 通知SDK进行更新
                        if (null != GlobalParams.hwBuoy) {
                            GlobalParams.hwBuoy.updateApp(
                                    mContext.getApplicationContext(),
                                    GameCallback.this);
                        }
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).create().show();

        dialog.show();
    }

    @Override
    public void onUpdateError(int arg0) {
    }

}

@@ -1622,1427 +1622,8 @@
 ) %7B%0A
-        // %E6%A0%B9%E6%8D%AE%E4%B8%9A%E5%8A%A1%E9%9C%80%E8%A6%81%E8%AE%BE%E7%BD%AE%EF%BC%8Cdemo%E4%B8%AD%E5%8F%AA%E5%9C%A8%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2%E5%B1%95%E7%A4%BA%E6%9B%B4%E6%96%B0%E4%BF%A1%E6%81%AF%0A        if (null == info) %7B%0A            DebugConfig.d(Constants.TAG, %22IGameCallBack onUpdateCheckFinished:%E6%97%A0%E6%9B%B4%E6%96%B0%E4%BF%A1%E6%81%AF%22);%0A            return;%0A        %7D%0A        DebugConfig.d(Constants.TAG, %22IGameCallBack onUpdateCheckFinished:UpdateInfo=%22%0A                + info.toString());%0A%0A        // %E5%A6%82%E6%9C%89%E9%9C%80%E8%A6%81%E5%88%99%E6%8F%90%E7%A4%BA%E7%94%A8%E6%88%B7%E6%98%AF%E5%90%A6%E6%9B%B4%E6%96%B0%EF%BC%8C%E5%8F%AF%E9%92%88%E5%AF%B9%E6%8F%90%E7%A4%BA%E6%96%B9%E5%BC%8F%E5%92%8C%E7%95%8C%E9%9D%A2%E8%87%AA%E8%A1%8C%E4%BF%AE%E6%94%B9%EF%BC%8C%E5%A6%82%E4%B8%8D%E9%9C%80%E8%A6%81SDK%E6%9B%B4%E6%96%B0%E5%88%99%E5%BF%BD%E7%95%A5%E6%AD%A4%E9%80%BB%E8%BE%91%E4%B8%8D%E5%A4%84%E7%90%86%E5%8D%B3%E5%8F%AF%0A        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);%0A        dialog.setTitle(%22%E6%9B%B4%E6%96%B0%E6%8F%90%E7%A4%BA%22)%0A                .setMessage(%22%E6%9B%B4%E6%96%B0%E5%86%85%E5%AE%B9%EF%BC%9A%22 + info.toString())%0A                .setPositiveButton(%22%E6%9B%B4%E6%96%B0%22, new DialogInterface.OnClickListener() %7B%0A%0A                    @Override%0A                    public void onClick(DialogInterface dialog, int which) %7B%0A                        dialog.dismiss();%0A                        // %E9%80%9A%E7%9F%A5SDK%E8%BF%9B%E8%A1%8C%E6%9B%B4%E6%96%B0%0A                        if (null != GlobalParams.hwBuoy) %7B%0A                            GlobalParams.hwBuoy.updateApp(%0A                                    mContext.getApplicationContext(),%0A                                    GameCallback.this);%0A                        %7D%0A                    %7D%0A                %7D)%0A                .setNegativeButton(%22%E5%8F%96%E6%B6%88%22, new DialogInterface.OnClickListener() %7B%0A%0A                    @Override%0A                    public void onClick(DialogInterface dialog, int which) %7B%0A                        dialog.dismiss();%0A                    %7D%0A                %7D).create().show();%0A%0A        dialog.show();%0A
     

remove the update check for huawei