1.福建初始化相关sdk(Topdraw、NewTV、局方埋点)
Showing
7 changed files
with
213 additions
and
151 deletions
| ... | @@ -5,17 +5,17 @@ | ... | @@ -5,17 +5,17 @@ |
| 5 | 5 | ||
| 6 | <uses-feature android:glEsVersion="0x00020000" /> | 6 | <uses-feature android:glEsVersion="0x00020000" /> |
| 7 | 7 | ||
| 8 | <uses-permission android:name="android.permission.INTERNET"/> | 8 | <uses-permission android:name="android.permission.INTERNET" /> |
| 9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | 9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| 10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | 10 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
| 11 | 11 | ||
| 12 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> | 12 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> |
| 13 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> | 13 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> |
| 14 | 14 | ||
| 15 | <uses-permission android:name="android.permission.READ_PHONE_STATE"/> | 15 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 16 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> | 16 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> |
| 17 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | 17 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> |
| 18 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | 18 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
| 19 | <uses-permission android:name="android.permission.RESTART_PACKAGES" /> | 19 | <uses-permission android:name="android.permission.RESTART_PACKAGES" /> |
| 20 | <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> | 20 | <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" /> |
| 21 | 21 | ||
| ... | @@ -27,18 +27,20 @@ | ... | @@ -27,18 +27,20 @@ |
| 27 | 27 | ||
| 28 | <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | 28 | <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> |
| 29 | <uses-permission android:name="com.hiveview.cloudscreen.user.READPROVIDER" /> | 29 | <uses-permission android:name="com.hiveview.cloudscreen.user.READPROVIDER" /> |
| 30 | <uses-permission android:name="com.hiveview.cloudscreen.user.WRITE_USERINFO_DB"/> | 30 | <uses-permission android:name="com.hiveview.cloudscreen.user.WRITE_USERINFO_DB" /> |
| 31 | 31 | ||
| 32 | <application | 32 | <application |
| 33 | android:allowBackup="true" | ||
| 34 | android:name="com.topdraw.melody.MelodyApplication" | 33 | android:name="com.topdraw.melody.MelodyApplication" |
| 35 | android:label="@string/app_name" | 34 | android:allowBackup="true" |
| 36 | android:icon="@mipmap/icon"> | 35 | android:icon="@mipmap/icon" |
| 36 | android:label="@string/app_name"> | ||
| 37 | 37 | ||
| 38 | <!-- Tell Cocos2dxActivity the name of our .so --> | 38 | <!-- Tell Cocos2dxActivity the name of our .so --> |
| 39 | <meta-data android:name="android.app.lib_name" | 39 | <meta-data |
| 40 | android:name="android.app.lib_name" | ||
| 40 | android:value="cocos2djs" /> | 41 | android:value="cocos2djs" /> |
| 41 | 42 | ||
| 43 | <!-- TopdrawSDK --> | ||
| 42 | <activity | 44 | <activity |
| 43 | android:name="com.topdraw.sdk.TopdrawActivity" | 45 | android:name="com.topdraw.sdk.TopdrawActivity" |
| 44 | android:process=":plugin" | 46 | android:process=":plugin" |
| ... | @@ -46,26 +48,42 @@ | ... | @@ -46,26 +48,42 @@ |
| 46 | 48 | ||
| 47 | <meta-data | 49 | <meta-data |
| 48 | android:name="TOPDRAW.PLATFORM" | 50 | android:name="TOPDRAW.PLATFORM" |
| 49 | android:value="CMCC.HaiNan" /> | 51 | android:value="FJ.CMCC" /> |
| 50 | <meta-data | 52 | <meta-data |
| 51 | android:name="TOPDRAW.PLATFORM_SERVER" | 53 | android:name="TOPDRAW.PLATFORM_SERVER" |
| 52 | android:value="http://melody.hi.a170.ottcn.com/hyperion.chimera" /> | 54 | android:value="http://eastcity.fj.a176.ottcn.com:81/clutch" /> |
| 53 | <meta-data | 55 | <meta-data |
| 54 | android:name="TOPDRAW.APPID" | 56 | android:name="TOPDRAW.APPID" |
| 55 | android:value="td71b187fedb257ac0" /> | 57 | android:value="EastCity" /> |
| 58 | |||
| 59 | <!-- 移动埋点SDK --> | ||
| 60 | <meta-data | ||
| 61 | android:name="CMCC.APPKEY" | ||
| 62 | android:value="13e71c3ecc4d4b96f1b5b0e5141bd3e6" /> | ||
| 63 | |||
| 64 | <!-- 未来NewTV --> | ||
| 56 | <meta-data | 65 | <meta-data |
| 57 | android:name="TOPDRAW.APPSECRET" | 66 | android:name="NewTV.APPID" |
| 58 | android:value="432f53029ae58eef34ec9a6794975443" /> | 67 | android:value="0e0777adb659479" /> |
| 68 | <meta-data | ||
| 69 | android:name="NewTV.channelCode" | ||
| 70 | android:value="\2626035001" /> | ||
| 71 | <meta-data | ||
| 72 | android:name="NewTV.Appkey" | ||
| 73 | android:value="df4fc19c4673bf9b5e70a7a56ece35e5" /> | ||
| 74 | <meta-data | ||
| 75 | android:name="NewTV.AppSecret" | ||
| 76 | android:value="ec695c7b7371db8dbd84a6d01e4c66a9" /> | ||
| 59 | 77 | ||
| 60 | <activity | 78 | <activity |
| 61 | android:name="org.cocos2dx.javascript.AppActivity" | 79 | android:name="org.cocos2dx.javascript.AppActivity" |
| 62 | android:screenOrientation="sensorLandscape" | ||
| 63 | android:configChanges="orientation|keyboardHidden|screenSize" | 80 | android:configChanges="orientation|keyboardHidden|screenSize" |
| 64 | android:label="@string/app_name" | 81 | android:label="@string/app_name" |
| 65 | android:usesCleartextTraffic="true" | ||
| 66 | android:theme="@style/ImageSplashStyle" | ||
| 67 | android:launchMode="singleTask" | 82 | android:launchMode="singleTask" |
| 68 | android:taskAffinity="" > | 83 | android:screenOrientation="sensorLandscape" |
| 84 | android:taskAffinity="" | ||
| 85 | android:theme="@style/ImageSplashStyle" | ||
| 86 | android:usesCleartextTraffic="true"> | ||
| 69 | <intent-filter> | 87 | <intent-filter> |
| 70 | <action android:name="android.intent.action.MAIN" /> | 88 | <action android:name="android.intent.action.MAIN" /> |
| 71 | 89 | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | //package com.topdraw.component; | 1 | package com.topdraw.component; |
| 2 | // | 2 | |
| 3 | //import android.content.Context; | 3 | import android.content.Context; |
| 4 | //import android.util.Log; | 4 | import android.util.Log; |
| 5 | //import android.webkit.JavascriptInterface; | 5 | import android.webkit.JavascriptInterface; |
| 6 | // | 6 | |
| 7 | //import tv.icntv.logsdk.logSDK; | 7 | import tv.icntv.logsdk.logSDK; |
| 8 | // | 8 | |
| 9 | //public class NativeLogReporterNewTV { | 9 | public class NativeLogReporterNewTV { |
| 10 | // | 10 | |
| 11 | // private static final String TAG = NativeLogReporterNewTV.class.getSimpleName(); | 11 | private static final String TAG = NativeLogReporterNewTV.class.getSimpleName(); |
| 12 | // | 12 | |
| 13 | // private static NativeLogReporterNewTV instance; | 13 | private static NativeLogReporterNewTV instance; |
| 14 | // | 14 | |
| 15 | // private static logSDK sdk; | 15 | private static logSDK sdk; |
| 16 | // | 16 | |
| 17 | // private Context context; | 17 | private Context context; |
| 18 | // | 18 | |
| 19 | // private NativeLogReporterNewTV(Context context, logSDK sdk) { | 19 | private NativeLogReporterNewTV(Context context, logSDK sdk) { |
| 20 | // this.context = context; | 20 | this.context = context; |
| 21 | // this.sdk = sdk; | 21 | this.sdk = sdk; |
| 22 | // } | 22 | } |
| 23 | // | 23 | |
| 24 | // public static NativeLogReporterNewTV getInstance(Context context, logSDK sdk) { | 24 | public static NativeLogReporterNewTV getInstance(Context context, logSDK sdk) { |
| 25 | // Log.d(TAG, "初始化LogReporter..." + instance); | 25 | Log.d(TAG, "初始化LogReporter..." + instance); |
| 26 | // if (null == instance) { | 26 | if (null == instance) { |
| 27 | // instance = new NativeLogReporterNewTV(context, sdk); | 27 | instance = new NativeLogReporterNewTV(context, sdk); |
| 28 | // } | 28 | } |
| 29 | // return instance; | 29 | return instance; |
| 30 | // } | 30 | } |
| 31 | // | 31 | |
| 32 | // public static void report(int i, String msg) { | 32 | public static void report(int i, String msg) { |
| 33 | // if (null != sdk) { | 33 | if (null != sdk) { |
| 34 | // Log.d(TAG, "log report | " + i + " " + msg); | 34 | Log.d(TAG, "log report | " + i + " " + msg); |
| 35 | // sdk.logUpload(i, null != msg ? msg : ""); | 35 | sdk.logUpload(i, null != msg ? msg : ""); |
| 36 | // } | 36 | } |
| 37 | // } | 37 | } |
| 38 | // | 38 | |
| 39 | //} | 39 | } | ... | ... |
This diff is collapsed.
Click to expand it.
| 1 | package com.topdraw.melody; | 1 | package com.topdraw.melody; |
| 2 | 2 | ||
| 3 | //import android.app.Application; | ||
| 4 | |||
| 5 | import android.content.Context; | 3 | import android.content.Context; |
| 6 | import android.os.Handler; | ||
| 7 | import android.util.Log; | 4 | import android.util.Log; |
| 8 | import android.widget.Toast; | 5 | import android.widget.Toast; |
| 9 | |||
| 10 | import com.topdraw.sdk.*; | ||
| 11 | import com.topdraw.sdk.ITopdrawSDK; | 6 | import com.topdraw.sdk.ITopdrawSDK; |
| 12 | import com.topdraw.sdk.TopdrawApplication; | 7 | import com.topdraw.sdk.TopdrawApplication; |
| 13 | import com.topdraw.sdk.TopdrawSDK; | ||
| 14 | 8 | ||
| 15 | import org.cocos2dx.javascript.AppActivity; | 9 | import org.cocos2dx.javascript.AppActivity; |
| 16 | 10 | ||
| 17 | public class MelodyApplication extends TopdrawApplication { | 11 | public class MelodyApplication extends TopdrawApplication { |
| 18 | 12 | ||
| 19 | public static final String TAG = "MelodyApplication"; | 13 | public static final String TAG = "MelodyApplication"; |
| 20 | private static String apiToken = "Nothing"; | ||
| 21 | private static Context context; | 14 | private static Context context; |
| 22 | public static final String ROOT_DIR = "/mnt/sdcard/fun"; | ||
| 23 | public static ITopdrawSDK topdrawSDK; | ||
| 24 | public static AppActivity appActivity; | 15 | public static AppActivity appActivity; |
| 25 | public static boolean authResult = false; | ||
| 26 | private static MelodyApplication app; | 16 | private static MelodyApplication app; |
| 27 | public static String TOPDRAW_API_PATH = "http://demo.cloud.api.findfun.topdraw.cn:38081/findfun"; | 17 | public static boolean isSDKInited; |
| 28 | 18 | public static ITopdrawSDK sdk; | |
| 29 | private Handler mHandler = new Handler(); | ||
| 30 | 19 | ||
| 31 | @Override | 20 | @Override |
| 32 | public void onCreate() { | 21 | public void onCreate() { |
| 33 | super.onCreate(); | 22 | super.onCreate(); |
| 34 | |||
| 35 | app = this; | 23 | app = this; |
| 36 | this.context = this.getApplicationContext(); | 24 | this.context = this.getApplicationContext(); |
| 37 | Log.d(TAG, "初始化SDK:currentThreadId" + Thread.currentThread().getId()); | ||
| 38 | |||
| 39 | TopdrawSDK.init(context, "td71b187fedb257ac0", "432f53029ae58eef34ec9a6794975443", initListener); | ||
| 40 | |||
| 41 | PluginLoader.getInstance().init(getApplicationContext(), mHandler, TOPDRAW_API_PATH, "/plugin/plugin.json"); | ||
| 42 | PluginLoader.getInstance().start(); | ||
| 43 | |||
| 44 | OBiPluginLoader.getInstance().init(getApplicationContext()); | ||
| 45 | |||
| 46 | //CrashHandler crashHandler = CrashHandler.getInstance(); | ||
| 47 | //crashHandler.setCustomCrashHanler(getApplicationContext()); | ||
| 48 | //MobclickAgent.UMAnalyticsConfig kk = new MobclickAgent.UMAnalyticsConfig(this,"5a168338a40fa377b500012b","amt"); | ||
| 49 | //MobclickAgent.startWithConfigure(kk); | ||
| 50 | //ReStartExceptionHandler.getInstance().initReStartExceptionHandler(this); | ||
| 51 | } | 25 | } |
| 52 | 26 | ||
| 53 | /** | 27 | /** |
| ... | @@ -69,65 +43,8 @@ public class MelodyApplication extends TopdrawApplication { | ... | @@ -69,65 +43,8 @@ public class MelodyApplication extends TopdrawApplication { |
| 69 | return app; | 43 | return app; |
| 70 | } | 44 | } |
| 71 | 45 | ||
| 72 | public static String getAPIToken() { | ||
| 73 | Log.d(TAG, "getAPIToken:[" + apiToken + "]"); | ||
| 74 | return apiToken; | ||
| 75 | } | ||
| 76 | |||
| 77 | public static String getUserId() { | ||
| 78 | return topdrawSDK.getUserID(); | ||
| 79 | } | ||
| 80 | |||
| 81 | public static Context getAppContext() { | 46 | public static Context getAppContext() { |
| 82 | return context; | 47 | return context; |
| 83 | } | 48 | } |
| 84 | 49 | ||
| 85 | /** | ||
| 86 | * 初始化apk所使用的listener | ||
| 87 | */ | ||
| 88 | private ITopdrawResultListener initListener = new ITopdrawResultListener() { | ||
| 89 | @Override | ||
| 90 | public void onResult(int i, String s, Object o) { | ||
| 91 | Log.d(TAG, "TopdrawSDK inited:[" + i + "]" + s); | ||
| 92 | if (i == 0) { | ||
| 93 | topdrawSDK = (ITopdrawSDK) o; | ||
| 94 | apiToken = topdrawSDK.getToken(); | ||
| 95 | Log.d(TAG, "API Token: " + apiToken); | ||
| 96 | //topdrawSDK.auth(MelodyApplication.getAppContext(),apiToken,null,authListener); | ||
| 97 | } else { | ||
| 98 | apiToken = "Unreachable"; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | }; | ||
| 102 | |||
| 103 | /** | ||
| 104 | * 认证所使用的Listener\ | ||
| 105 | */ | ||
| 106 | private ITopdrawResultListener authListener = new ITopdrawResultListener() { | ||
| 107 | @Override | ||
| 108 | public void onResult(int i, String s, Object o) { | ||
| 109 | Log.d(TAG, "TopdrawSDK authed:[" + i + "]" + s); | ||
| 110 | if (i == 10) { | ||
| 111 | Log.d(TAG, "auth success"); | ||
| 112 | authResult = true; | ||
| 113 | } else if (i == -2010) { | ||
| 114 | authResult = false; | ||
| 115 | System.out.println("auth failed"); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | }; | ||
| 120 | |||
| 121 | private ITopdrawResultListener orderListener = new ITopdrawResultListener() { | ||
| 122 | @Override | ||
| 123 | public void onResult(int i, String s, Object o) { | ||
| 124 | Log.d(TAG, "TopdrawSDK ordered:[" + i + "]" + s); | ||
| 125 | if (i == 20) { | ||
| 126 | authResult = true; | ||
| 127 | Log.d(TAG, "order success"); | ||
| 128 | } else { | ||
| 129 | Log.d(TAG, "order failed"); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | }; | ||
| 133 | } | 50 | } | ... | ... |
| ... | @@ -63,11 +63,11 @@ public class TopdrawSDKWrapper { | ... | @@ -63,11 +63,11 @@ public class TopdrawSDKWrapper { |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | public static String getAPIToken() { | 65 | public static String getAPIToken() { |
| 66 | return MelodyApplication.getAPIToken(); | 66 | return MelodyApplication.sdk.getToken(); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | public static String getUserId() { | 69 | public static String getUserId() { |
| 70 | return MelodyApplication.getUserId(); | 70 | return MelodyApplication.sdk.getUserID(); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /** | 73 | /** | ... | ... |
| ... | @@ -33,6 +33,9 @@ import android.content.BroadcastReceiver; | ... | @@ -33,6 +33,9 @@ import android.content.BroadcastReceiver; |
| 33 | import android.content.Context; | 33 | import android.content.Context; |
| 34 | import android.content.DialogInterface; | 34 | import android.content.DialogInterface; |
| 35 | import android.content.IntentFilter; | 35 | import android.content.IntentFilter; |
| 36 | import android.content.pm.ApplicationInfo; | ||
| 37 | import android.content.pm.PackageInfo; | ||
| 38 | import android.content.pm.PackageManager; | ||
| 36 | import android.os.Bundle; | 39 | import android.os.Bundle; |
| 37 | 40 | ||
| 38 | import android.content.Intent; | 41 | import android.content.Intent; |
| ... | @@ -45,6 +48,8 @@ import android.view.KeyEvent; | ... | @@ -45,6 +48,8 @@ import android.view.KeyEvent; |
| 45 | import android.view.LayoutInflater; | 48 | import android.view.LayoutInflater; |
| 46 | import android.view.View; | 49 | import android.view.View; |
| 47 | import android.view.WindowManager; | 50 | import android.view.WindowManager; |
| 51 | import android.webkit.CookieManager; | ||
| 52 | import android.webkit.JavascriptInterface; | ||
| 48 | import android.webkit.WebView; | 53 | import android.webkit.WebView; |
| 49 | import android.webkit.WebViewClient; | 54 | import android.webkit.WebViewClient; |
| 50 | import android.widget.FrameLayout; | 55 | import android.widget.FrameLayout; |
| ... | @@ -52,12 +57,28 @@ import android.widget.ImageView; | ... | @@ -52,12 +57,28 @@ import android.widget.ImageView; |
| 52 | import android.widget.LinearLayout; | 57 | import android.widget.LinearLayout; |
| 53 | import android.widget.RelativeLayout; | 58 | import android.widget.RelativeLayout; |
| 54 | import android.widget.TextView; | 59 | import android.widget.TextView; |
| 60 | import android.widget.Toast; | ||
| 55 | 61 | ||
| 62 | import com.knowyou_jni.single.SDKUtil; | ||
| 56 | import com.topdraw.component.CocosMediaPlayer; | 63 | import com.topdraw.component.CocosMediaPlayer; |
| 64 | import com.topdraw.component.NewTVSDK; | ||
| 57 | import com.topdraw.forfun.R; | 65 | import com.topdraw.forfun.R; |
| 58 | import com.topdraw.melody.CommonUtils; | 66 | import com.topdraw.melody.CommonUtils; |
| 59 | import com.topdraw.melody.MelodyApplication; | 67 | import com.topdraw.melody.MelodyApplication; |
| 68 | import com.topdraw.melody.OBiPluginLoader; | ||
| 69 | import com.topdraw.melody.PluginLoader; | ||
| 60 | import com.topdraw.melody.TopdrawSDKWrapper; | 70 | import com.topdraw.melody.TopdrawSDKWrapper; |
| 71 | import com.topdraw.sdk.ITopdrawResultListener; | ||
| 72 | import com.topdraw.sdk.ITopdrawSDK; | ||
| 73 | import com.topdraw.sdk.TopdrawSDK; | ||
| 74 | |||
| 75 | import java.net.URLEncoder; | ||
| 76 | import java.util.HashMap; | ||
| 77 | import java.util.Map; | ||
| 78 | |||
| 79 | import tv.icntv.adsdk.AdSDK; | ||
| 80 | import tv.icntv.logsdk.logSDK; | ||
| 81 | import tv.icntv.ottlogin.loginSDK; | ||
| 61 | 82 | ||
| 62 | public class AppActivity extends Cocos2dxActivity { | 83 | public class AppActivity extends Cocos2dxActivity { |
| 63 | private static String TAG = "AppActivity"; | 84 | private static String TAG = "AppActivity"; |
| ... | @@ -71,13 +92,28 @@ public class AppActivity extends Cocos2dxActivity { | ... | @@ -71,13 +92,28 @@ public class AppActivity extends Cocos2dxActivity { |
| 71 | private RelativeLayout mRLSingleColor; | 92 | private RelativeLayout mRLSingleColor; |
| 72 | private RelativeLayout mOBiLayout; | 93 | private RelativeLayout mOBiLayout; |
| 73 | 94 | ||
| 95 | public static boolean baminSDKInited = false; | ||
| 96 | public static String APP_KEY; | ||
| 97 | public static String APP_NAME; | ||
| 98 | public static String APP_TYPE; | ||
| 99 | public static String USER_ID; | ||
| 100 | |||
| 101 | private static String TOPDRAW_PLATFORM; | ||
| 102 | private static String TOPDRAW_PLATFORM_SERVER; | ||
| 103 | private static String TOPDRAW_APPID; | ||
| 104 | private static String TOPDRAW_APPSECRET; | ||
| 105 | |||
| 106 | public static String TOPDRAW_API_PATH = "http://demo.cloud.api.findfun.topdraw.cn:38081/findfun"; | ||
| 107 | |||
| 108 | private final Handler mHandler = new Handler(); | ||
| 109 | |||
| 74 | @Override | 110 | @Override |
| 75 | protected void onCreate(Bundle savedInstanceState) { | 111 | protected void onCreate(Bundle savedInstanceState) { |
| 76 | super.onCreate(savedInstanceState); | 112 | super.onCreate(savedInstanceState); |
| 77 | Log.d(TAG, "判断APK是否安装。。。" + getExternalCacheDir().getPath()); | ||
| 78 | |||
| 79 | checkNetwork(); //检查网络 | 113 | checkNetwork(); //检查网络 |
| 80 | 114 | ||
| 115 | initSdkData(); | ||
| 116 | |||
| 81 | //----解决游戏页按返回退出时,背景图透明度过高,onPause和onResume中控制显示还是隐藏 | 117 | //----解决游戏页按返回退出时,背景图透明度过高,onPause和onResume中控制显示还是隐藏 |
| 82 | singleView = LayoutInflater.from(this).inflate(R.layout.activity_main_single_color, null); | 118 | singleView = LayoutInflater.from(this).inflate(R.layout.activity_main_single_color, null); |
| 83 | mRLSingleColor = singleView.findViewById(R.id.ll_single); | 119 | mRLSingleColor = singleView.findViewById(R.id.ll_single); |
| ... | @@ -135,6 +171,33 @@ public class AppActivity extends Cocos2dxActivity { | ... | @@ -135,6 +171,33 @@ public class AppActivity extends Cocos2dxActivity { |
| 135 | SDKWrapper.getInstance().init(this); | 171 | SDKWrapper.getInstance().init(this); |
| 136 | } | 172 | } |
| 137 | 173 | ||
| 174 | private void initSdkData() { | ||
| 175 | //init topdraw.jar----- | ||
| 176 | ApplicationInfo appInfo = null; | ||
| 177 | try { | ||
| 178 | PackageManager pm = getPackageManager(); | ||
| 179 | appInfo = pm.getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); | ||
| 180 | } catch (Exception e) { | ||
| 181 | |||
| 182 | } | ||
| 183 | TOPDRAW_PLATFORM = appInfo.metaData.getString("TOPDRAW.PLATFORM"); | ||
| 184 | TOPDRAW_PLATFORM_SERVER = appInfo.metaData.getString("TOPDRAW.PLATFORM_SERVER"); | ||
| 185 | TOPDRAW_APPID = appInfo.metaData.getString("TOPDRAW.APPID"); | ||
| 186 | TOPDRAW_APPSECRET = appInfo.metaData.getString("TOPDRAW.APPSECRET"); | ||
| 187 | TopdrawSDK.init(getApplicationContext(), TOPDRAW_PLATFORM, TOPDRAW_PLATFORM_SERVER, TOPDRAW_APPID, TOPDRAW_APPSECRET, initListener); | ||
| 188 | |||
| 189 | APP_KEY = appInfo.metaData.getString("CMCC.APPKEY"); | ||
| 190 | APP_NAME = getString(R.string.app_name); | ||
| 191 | |||
| 192 | //init NewTV | ||
| 193 | NewTVSDK.getInstence(this).init(); //注意防止loading图片覆盖掉开机广告 fix jerry | ||
| 194 | |||
| 195 | PluginLoader.getInstance().init(getApplicationContext(), mHandler, TOPDRAW_API_PATH, "/plugin/plugin.json"); | ||
| 196 | PluginLoader.getInstance().start(); | ||
| 197 | |||
| 198 | OBiPluginLoader.getInstance().init(getApplicationContext()); | ||
| 199 | } | ||
| 200 | |||
| 138 | //修改回默认主题,防止部分挖洞窗口有阴影 | 201 | //修改回默认主题,防止部分挖洞窗口有阴影 |
| 139 | @Override | 202 | @Override |
| 140 | public void setTheme(int resid) { | 203 | public void setTheme(int resid) { |
| ... | @@ -311,4 +374,68 @@ public class AppActivity extends Cocos2dxActivity { | ... | @@ -311,4 +374,68 @@ public class AppActivity extends Cocos2dxActivity { |
| 311 | public static void logInSceneE(String strLog) { | 374 | public static void logInSceneE(String strLog) { |
| 312 | Log.e("logInSceneE", strLog); | 375 | Log.e("logInSceneE", strLog); |
| 313 | } | 376 | } |
| 377 | |||
| 378 | private ITopdrawResultListener initListener = new ITopdrawResultListener() { | ||
| 379 | @Override | ||
| 380 | public void onResult(int result, String msg, Object obj) { | ||
| 381 | // LOG(TAG, "onResult " + result + " " + msg + " " + obj); | ||
| 382 | if (0 == result) { | ||
| 383 | MelodyApplication.sdk = (ITopdrawSDK) obj; | ||
| 384 | USER_ID = MelodyApplication.sdk.getOssUserID(); | ||
| 385 | MelodyApplication.isSDKInited = true; | ||
| 386 | |||
| 387 | //局方埋点 | ||
| 388 | try { | ||
| 389 | SDKUtil.isOpenLog = true; | ||
| 390 | int sdkResult = SDKUtil.getInstance().ky_initWithAppKey(AppActivity.this, APP_KEY, | ||
| 391 | getPackageManager().getPackageInfo(getPackageName(), 0).versionName); | ||
| 392 | baminSDKInited = (sdkResult == 0); | ||
| 393 | Map<String, Object> params = new HashMap<>(); | ||
| 394 | params.put("appId", TOPDRAW_APPID); | ||
| 395 | params.put("userId", MelodyApplication.sdk.getUserID()); | ||
| 396 | MelodyApplication.sdk.auth(AppActivity.this, MelodyApplication.sdk.getToken(), params, new ITopdrawResultListener() { | ||
| 397 | @Override | ||
| 398 | public void onResult(int i, String s, Object o) { | ||
| 399 | if (10 == i) { | ||
| 400 | NativeSystem.isAuthenticated = true; | ||
| 401 | } else { | ||
| 402 | NativeSystem.isAuthenticated = false; | ||
| 403 | } | ||
| 404 | if (baminSDKInited) { | ||
| 405 | HashMap<Object, Object> params = new HashMap<>(); | ||
| 406 | params.put("APP_NAME", APP_NAME); | ||
| 407 | params.put("APP_TYPE", APP_TYPE); | ||
| 408 | params.put("USER_LOGIN", "1"); | ||
| 409 | params.put("USER_ID", USER_ID); | ||
| 410 | params.put("USER_ORDER", NativeSystem.isAuthenticated ? "已订购" : "未订购"); | ||
| 411 | SDKUtil.getInstance().ky_trackCustom(params); | ||
| 412 | SDKUtil.getInstance().ky_userSignIn(USER_ID); | ||
| 413 | } | ||
| 414 | } | ||
| 415 | }); | ||
| 416 | } catch (Exception e) { | ||
| 417 | |||
| 418 | } | ||
| 419 | } else if (-1020 == result) { | ||
| 420 | Toast.makeText(AppActivity.this, "网络异常,请重试", Toast.LENGTH_LONG).show(); | ||
| 421 | finish(); | ||
| 422 | } else { | ||
| 423 | Toast.makeText(AppActivity.this, "启动异常,请重试", Toast.LENGTH_LONG).show(); | ||
| 424 | finish(); | ||
| 425 | } | ||
| 426 | } | ||
| 427 | }; | ||
| 428 | |||
| 429 | private static class NativeSystem { | ||
| 430 | |||
| 431 | public static boolean isAuthenticated = false; | ||
| 432 | |||
| 433 | @JavascriptInterface | ||
| 434 | public void set(String key, String value) { | ||
| 435 | // LOG(TAG, "js call set() key=" + key + " value=" + value); | ||
| 436 | if ("isAuthenticated".equals(key) && "true".equals(value)) { | ||
| 437 | isAuthenticated = true; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | } | ||
| 314 | } | 441 | } | ... | ... |
-
Please register or sign in to post a comment