|  |  |  | 
|---|
|  |  |  | import com.cy.yyjia.sdk.listener.InitListener; | 
|---|
|  |  |  | import com.cy.yyjia.sdk.listener.LoginListener; | 
|---|
|  |  |  | import com.cy.yyjia.sdk.listener.LogoutListener; | 
|---|
|  |  |  | import com.cy.yyjia.sdk.listener.MarketListener; | 
|---|
|  |  |  | import com.cy.yyjia.sdk.listener.PayListener; | 
|---|
|  |  |  | import com.cy.yyjia.sdk.listener.ShareListener; | 
|---|
|  |  |  | import com.secondworld.sdk.utils.CallBackState; | 
|---|
|  |  |  | import com.secondworld.sdk.utils.CodeA2U; | 
|---|
|  |  |  | import com.secondworld.sdk.utils.LogUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.json.JSONException; | 
|---|
|  |  |  | import org.json.JSONObject; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class MySdkMgr extends PlatformSdkMgr { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onSuccess() { | 
|---|
|  |  |  | sdkInitState = SdkInitState.SUCCEED; | 
|---|
|  |  |  | LogUtil.debug("SdkManager", "成功"); | 
|---|
|  |  |  | LogUtil.debug("SdkManager", "初始化成功"); | 
|---|
|  |  |  | args.clear(); | 
|---|
|  |  |  | args.put("code", CodeA2U.PlatformInitOk); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onError(String msg) { | 
|---|
|  |  |  | sdkInitState = SdkInitState.FAILED; | 
|---|
|  |  |  | LogUtil.e("SdkManager", "失败:" + msg); | 
|---|
|  |  |  | LogUtil.e("SdkManager", "初始化失败:" + msg); | 
|---|
|  |  |  | args.clear(); | 
|---|
|  |  |  | args.put("code", CodeA2U.PlatformInitFail); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | 
|---|
|  |  |  | SdkManager.getInstance().setLoginListener(new LoginListener() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onSuccess() { | 
|---|
|  |  |  | LogUtil.e("SdkManager", "登录成功"); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | args.clear(); | 
|---|
|  |  |  | JSONObject info = new JSONObject(); | 
|---|
|  |  |  | info.put("account", SdkManager.getInstance().getUid()); | 
|---|
|  |  |  | info.put("game_id", SdkManager.getInstance().getGameId()); | 
|---|
|  |  |  | info.put("session_id", SdkManager.getInstance().getSessionId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | args.put("code", CodeA2U.PlatformLoginOk); | 
|---|
|  |  |  | args.put("info", info); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | } catch (JSONException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | LogUtil.e("SdkManager 登录成功", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //注册成功 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onSuccess(Boolean isNewReg, String reg_type) { | 
|---|
|  |  |  | LogUtil.e("SdkManager", "注册成功" + " isNewReg:" + isNewReg + "  type:" + reg_type); | 
|---|
|  |  |  | args.clear(); | 
|---|
|  |  |  | args.put("code", CodeA2U.PlatformLoginOk); | 
|---|
|  |  |  | args.put("account", SdkManager.getInstance().getUid()); | 
|---|
|  |  |  | args.put("game_id", SdkManager.getInstance().getGameId()); | 
|---|
|  |  |  | args.put("session_id", SdkManager.getInstance().getSessionId()); | 
|---|
|  |  |  | args.put("code", CodeA2U.PlatformRegisterOk); | 
|---|
|  |  |  | args.put("reg_type", reg_type); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onError(String s) { | 
|---|
|  |  |  | LogUtil.e("SdkManager", "登录失败:" + s); | 
|---|
|  |  |  | args.clear(); | 
|---|
|  |  |  | args.put("code", CodeA2U.PlatformLoginFail); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //分享回调 | 
|---|
|  |  |  | SdkManager.getInstance().setShareListener(new ShareListener() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onSuccess(String type) { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("code", CodeA2U.ShareState); | 
|---|
|  |  |  | args.put("state", CallBackState.Success); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | LogUtil.debug("分享回调", "onSuccess:" + type); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onError(String type, String msg) { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("code", CodeA2U.ShareState); | 
|---|
|  |  |  | args.put("state", CallBackState.Error); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | LogUtil.debug("分享回调", "type:" + type + ";msg:" + msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onCancel(String type) { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("code", CodeA2U.ShareState); | 
|---|
|  |  |  | args.put("state", CallBackState.Cancel); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | LogUtil.debug("分享回调", type + ":onCancel"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //评分回调 | 
|---|
|  |  |  | SdkManager.getInstance().setMarketListener(new MarketListener() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onSuccess() { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("code", CodeA2U.ReviewState); | 
|---|
|  |  |  | args.put("state", CallBackState.Success); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | LogUtil.debug("评分回调", "成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onError(String s) { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("code", CodeA2U.ReviewState); | 
|---|
|  |  |  | args.put("state", CallBackState.Error); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | LogUtil.debug("评分回调", "失败:" + s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onCancel() { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("code", CodeA2U.ReviewState); | 
|---|
|  |  |  | args.put("state", CallBackState.Cancel); | 
|---|
|  |  |  | UnityMsgHandler.sendMessageToUnity(args); | 
|---|
|  |  |  | LogUtil.debug("评分回调", "取消"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置dubug模式 | 
|---|
|  |  |  | SdkManager.getInstance().setDebug(BuildConfig.DEBUG); | 
|---|
|  |  |  | } | 
|---|