|  |  |  | 
|---|
|  |  |  | import android.provider.Settings; | 
|---|
|  |  |  | import android.widget.Toast; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.snowfish.cn.ganga.helper.SFOnlineExitListener; | 
|---|
|  |  |  | import com.snowfish.cn.ganga.helper.SFOnlineHelper; | 
|---|
|  |  |  | import com.unity3d.player.UnityPlayer; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public class H2EngineSDK | 
|---|
|  |  |  | { | 
|---|
|  |  |  | private static final String TAG = "H2EngineSDK"; | 
|---|
|  |  |  | private static String APP_ID = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static boolean PushEnable = true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | switch (_code) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | case CodeU2A.Init: | 
|---|
|  |  |  | APP_ID = _json.getString("appID"); | 
|---|
|  |  |  | init(_activity); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case CodeU2A.CopyOneAsset: | 
|---|
|  |  |  | 
|---|
|  |  |  | case CodeU2A.FreePlatformPay: | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JSONObject _extraData = new JSONObject(); | 
|---|
|  |  |  | _extraData.put("appid", APP_ID); | 
|---|
|  |  |  | String _yjAppID = UniversalUtil.getMetaString(_activity, "yj_appid"); | 
|---|
|  |  |  | _extraData.put("appid", _yjAppID); | 
|---|
|  |  |  | _extraData.put("cpinfo", _json.getString("cpInfo")); | 
|---|
|  |  |  | _extraData.put("cporderid", _json.getString("orderId")); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //                        YJPlatformUtil.getInstance().payExtend(_activity, | 
|---|
|  |  |  | //                                                         _json.getString("title"), | 
|---|
|  |  |  | //                                                         _json.getString("cpInfo"), | 
|---|
|  |  |  | //                                                         (float) _json.getDouble("mount"), | 
|---|
|  |  |  | //                                                         URLEncoder.encode(_extraData.toString(), | 
|---|
|  |  |  | //                                                                           "utf-8")); | 
|---|
|  |  |  | if (_yjAppID.contains("mzgame") | 
|---|
|  |  |  | || _yjAppID.contains("ucgame") | 
|---|
|  |  |  | || _yjAppID.contains("yybgame")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | YJPlatformUtil.getInstance().pay(_activity, | 
|---|
|  |  |  | _json.getString("title"), | 
|---|
|  |  |  | _json.getString("cpInfo"), | 
|---|
|  |  |  | (float) _json.getDouble("mount"), | 
|---|
|  |  |  | URLEncoder.encode( | 
|---|
|  |  |  | _extraData.toString(), | 
|---|
|  |  |  | "utf-8")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | YJPlatformUtil.getInstance().charge(_activity, | 
|---|
|  |  |  | _json.getString("title"), | 
|---|
|  |  |  | (float) _json.getDouble("mount"), | 
|---|
|  |  |  | URLEncoder.encode( | 
|---|
|  |  |  | _extraData.toString(), | 
|---|
|  |  |  | "utf-8")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | YJPlatformUtil.getInstance().pay(_activity, | 
|---|
|  |  |  | _json.getString("title"), | 
|---|
|  |  |  | _json.getString("cpInfo"), | 
|---|
|  |  |  | (float) _json.getDouble("mount"), | 
|---|
|  |  |  | URLEncoder.encode( _extraData.toString(),"utf-8")); | 
|---|
|  |  |  | }catch (UnsupportedEncodingException e) | 
|---|
|  |  |  | } catch (UnsupportedEncodingException e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | _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("createTime"), | 
|---|
|  |  |  | _json.getString("levelUpTime"), | 
|---|
|  |  |  | _json.getString("vipLevel"), | 
|---|
|  |  |  | _json.getString("money")); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | _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("createTime"), | 
|---|
|  |  |  | _json.getString("levelUpTime"), | 
|---|
|  |  |  | _json.getString("familyName").trim() | 
|---|
|  |  |  | .replace(" ", ""), | 
|---|
|  |  |  | _json.getString("vipLevel"), | 
|---|
|  |  |  | _json.getString("money")); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | _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("createTime"), | 
|---|
|  |  |  | _json.getString("levelUpTime"), | 
|---|
|  |  |  | _json.getString("vipLevel"), | 
|---|
|  |  |  | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case CodeU2A.JPushRemoveLocalMessage: | 
|---|
|  |  |  | removeNotification(_activity, _json.getInt("id")); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case CodeU2A.TencentLogin: | 
|---|
|  |  |  | YJPlatformUtil.getInstance().loginTencent(_activity, _json.getString("param")); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case CodeU2A.SendRegistEvent: | 
|---|
|  |  |  | YJPlatformUtil.getInstance().SendRegisterEvent(); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | _msgStruct.clear(); | 
|---|
|  |  |  | _msgStruct.put("code", CodeA2U.SdkInitComplete); | 
|---|
|  |  |  | _msgStruct.put("channelPlatform", "yj"); | 
|---|
|  |  |  | _msgStruct.put("yj_appid", UniversalUtil.getMetaString(activity,"yj_appid")); | 
|---|
|  |  |  | _msgStruct.put("yj_spid", UniversalUtil.getMetaString(activity,"yj_spid")); | 
|---|
|  |  |  | String _appid = UniversalUtil.getMetaString(activity, "yj_appid"); | 
|---|
|  |  |  | _msgStruct.put("yj_appid", _appid); | 
|---|
|  |  |  | _msgStruct.put("yj_spid", UniversalUtil.getMetaString(activity, "yj_spid")); | 
|---|
|  |  |  | _msgStruct.put("yj_branch", UniversalUtil.getMetaInt(activity, "yj_branch")); | 
|---|
|  |  |  | _msgStruct.put("banhao", activity.getResources().getString(R.string.banhao)); | 
|---|
|  |  |  | UniversalUtil.sendMessageToUnity(_msgStruct); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LogUtil.i(TAG, "初始化执行完毕"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void onWindowFocusChanged(boolean b) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //        if (MrPlatformUtil.getInstance().payProcessing) | 
|---|
|  |  |  | //        { | 
|---|
|  |  |  | //            if (b) | 
|---|
|  |  |  | //            { | 
|---|
|  |  |  | //                Map<String, Object> _msgStruct = new HashMap<>(); | 
|---|
|  |  |  | //                _msgStruct.put("code", CodeA2U.FreePlatformPayCancel); | 
|---|
|  |  |  | //                UniversalUtil.sendMessageToUnity(_msgStruct); | 
|---|
|  |  |  | //                MrPlatformUtil.getInstance().payProcessing = false; | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if (b) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (YJPlatformUtil.getInstance().payProcessing) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Map<String, Object> _msgStruct = new HashMap<>(); | 
|---|
|  |  |  | _msgStruct.put("code", CodeA2U.FreePlatformPayCancel); | 
|---|
|  |  |  | UniversalUtil.sendMessageToUnity(_msgStruct); | 
|---|
|  |  |  | YJPlatformUtil.getInstance().payProcessing = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | m_IsFocus = b; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void onNewIntent(final Activity activity, final Intent intent) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | SFOnlineHelper.onNewIntent(activity, intent); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void onActivityResult(int requestCode, | 
|---|
|  |  |  | 
|---|
|  |  |  | final Intent data, | 
|---|
|  |  |  | final Activity activity) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | SFOnlineHelper.onActivityResult(activity, requestCode, resultCode, data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void onConfigurationChanged(final Configuration newConfig) {} | 
|---|