From 3bbd2c96b5f22c98cb0adef6378e75a9f404feaf Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期五, 07 三月 2025 12:10:27 +0800 Subject: [PATCH] 0312 官网新sdk --- Project/sp_sdk/src/game_spxjgame/java/com/secondworld/univeralsdk/H2EngineSDK.java | 106 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 69 insertions(+), 37 deletions(-) diff --git a/Project/sp_sdk/src/game_spxjgame/java/com/secondworld/univeralsdk/H2EngineSDK.java b/Project/sp_sdk/src/game_spxjgame/java/com/secondworld/univeralsdk/H2EngineSDK.java index 5cd663f..50d8623 100644 --- a/Project/sp_sdk/src/game_spxjgame/java/com/secondworld/univeralsdk/H2EngineSDK.java +++ b/Project/sp_sdk/src/game_spxjgame/java/com/secondworld/univeralsdk/H2EngineSDK.java @@ -33,6 +33,8 @@ private static final String TAG = "H2EngineSDK"; private static String APP_ID = ""; + private static boolean PushEnable = true; + public static void HandleUnityMessage(String json) { LogUtil.i(TAG, "鏀跺埌Unity鍙戞潵鐨勪俊鎭�: " + json); @@ -51,6 +53,9 @@ break; case CodeU2A.AssetCopy: FileUtil.copyAssets(_activity); + break; + case CodeU2A.CopyOneAsset: + FileUtil.copy(_activity,_json.getString("fileName")); break; case CodeU2A.BatteryListenStart: BatteryUtil.getInstance().start(_activity); @@ -87,7 +92,7 @@ case CodeU2A.FreePlatformSwitchAccount: break; case CodeU2A.FreePlatformLogout: - SpPlatformUtil.getInstance().logout(); + SpPlatformUtil.getInstance().logout(); break; case CodeU2A.FreePlatformPay: @@ -99,7 +104,7 @@ SpPlatformUtil.getInstance().pay(_activity, _json.getString("title"), _json.getString("cpInfo"), - (float)_json.getDouble("mount"), + (float) _json.getDouble("mount"), _extraData.toString()); break; @@ -110,9 +115,13 @@ SpPlatformUtil.getInstance().createRole(_json.getString("sid"), _json.getString("serverName"), _json.getString("roleID"), - _json.getString("roleName").trim().replace(" ",""), + _json.getString( + "roleName").trim().replace(" ", + ""), _json.getString("level"), - _json.getString("familyName").trim().replace(" ",""), + _json.getString( + "familyName").trim().replace( + " ", ""), _json.getString("gameName"), _json.getString("job"), _json.getString("vipLevel"), @@ -122,9 +131,13 @@ SpPlatformUtil.getInstance().enterWorld(_json.getString("sid"), _json.getString("serverName"), _json.getString("roleID"), - _json.getString("roleName").trim().replace(" ",""), + _json.getString( + "roleName").trim().replace(" ", + ""), _json.getString("level"), - _json.getString("familyName").trim().replace(" ",""), + _json.getString( + "familyName").trim().replace( + " ", ""), _json.getString("gameName"), _json.getString("job"), _json.getString("vipLevel"), @@ -134,9 +147,12 @@ SpPlatformUtil.getInstance().levelUp(_json.getString("sid"), _json.getString("serverName"), _json.getString("roleID"), - _json.getString("roleName").trim().replace(" ",""), + _json.getString("roleName").trim().replace( + " ", ""), _json.getString("level"), - _json.getString("familyName").trim().replace(" ",""), + _json.getString( + "familyName").trim().replace(" ", + ""), _json.getString("gameName"), _json.getString("job"), _json.getString("vipLevel"), @@ -154,6 +170,9 @@ case CodeU2A.JPushRemoveLocalMessage: removeNotification(_activity, _json.getInt("id")); break; + case CodeU2A.SendRegistEvent: + SpPlatformUtil.getInstance().SendRegisterEvent(); + break; } } catch (JSONException e) @@ -166,25 +185,31 @@ public static void addLocalNotification(Activity activity, int id, String title, String content, long fireTime) { - try + if (PushEnable) { - JPushLocalNotification ln = new JPushLocalNotification(); - ln.setBuilderId(0);// 璁剧疆鏍峰紡 - ln.setNotificationId(id);// id - ln.setTitle(title);// 鏍囬 + try + { + JPushLocalNotification ln = new JPushLocalNotification(); + ln.setBuilderId(0);// 璁剧疆鏍峰紡 + ln.setNotificationId(id);// id + ln.setTitle(title);// 鏍囬 - ln.setContent(content);// 鍐呭 - ln.setBroadcastTime(fireTime);// 绛夊緟鏃堕棿 - JPushInterface.addLocalNotification(activity, ln); - } catch (Exception e) - { - e.printStackTrace(); + ln.setContent(content);// 鍐呭 + ln.setBroadcastTime(fireTime);// 绛夊緟鏃堕棿 + JPushInterface.addLocalNotification(activity, ln); + } catch (Exception e) + { + e.printStackTrace(); + } } } public static void removeNotification(Activity activity, int id) { - JPushInterface.removeLocalNotification(activity, id); + if (PushEnable) + { + JPushInterface.removeLocalNotification(activity, id); + } } public static void GetExternalStorage() @@ -296,6 +321,8 @@ return; } + PushEnable = activity.getPackageName().equals("com.xjaz.sp"); + new Thread(new Runnable() { @Override @@ -319,31 +346,36 @@ UniversalUtil.sendMessageToUnity(_msgStruct); // ------------------------------- 鏋佸厜鎺ㄩ�� ------------------------------- - JPushInterface.setDebugMode(true); - JPushInterface.init(activity); - - final long _waitingTime = System.currentTimeMillis(); - - while (true) + String _registrationID = "0"; + if (PushEnable) { - // 绛夊緟鑾峰彇鏋佸厜registrationID - if (!JPushInterface.getRegistrationID(activity).equals("")) - { - break; - } + JPushInterface.setDebugMode(true); + JPushInterface.init(activity); - long _escapeTime = System.currentTimeMillis() - _waitingTime; + final long _waitingTime = System.currentTimeMillis(); - if (_escapeTime > 3000) + while (true) { - LogUtil.w(TAG, "绛夊緟鑾峰彇鏋佸厜鎺ㄩ�乺egistrationID瓒呮椂: 3绉�"); - break; + // 绛夊緟鑾峰彇鏋佸厜registrationID + if (!JPushInterface.getRegistrationID(activity).equals("")) + { + _registrationID = JPushInterface.getRegistrationID(activity); + break; + } + + long _escapeTime = System.currentTimeMillis() - _waitingTime; + + if (_escapeTime > 3000) + { + LogUtil.w(TAG, "绛夊緟鑾峰彇鏋佸厜鎺ㄩ�乺egistrationID瓒呮椂: 3绉�"); + break; + } } } _msgStruct.clear(); _msgStruct.put("code", CodeA2U.PushClientID); - _msgStruct.put("clientID", JPushInterface.getRegistrationID(activity)); + _msgStruct.put("clientID", _registrationID); UniversalUtil.sendMessageToUnity(_msgStruct); _msgStruct.clear(); @@ -412,7 +444,7 @@ { SPGameController.getInstance().onResume(activity); - if(SpPlatformUtil.getInstance().payProcessing) + if (SpPlatformUtil.getInstance().payProcessing) { Map<String, Object> _msgStruct = new HashMap<>(); _msgStruct.put("code", CodeA2U.FreePlatformPayCancel); -- Gitblit v1.8.0