1.福建初始化相关sdk(Topdraw、NewTV、局方埋点)
Showing
7 changed files
with
579 additions
and
512 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 | ... | ... |
1 | //package com.topdraw.component; | 1 | package com.topdraw.component; |
2 | // | 2 | |
3 | //import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
4 | //import android.content.Context; | 4 | import android.content.Context; |
5 | //import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
6 | //import android.graphics.BitmapFactory; | 6 | import android.graphics.BitmapFactory; |
7 | //import android.graphics.Color; | 7 | import android.graphics.Color; |
8 | //import android.os.Handler; | 8 | import android.os.Handler; |
9 | //import android.os.Message; | 9 | import android.os.Message; |
10 | //import android.support.annotation.NonNull; | 10 | import android.util.AttributeSet; |
11 | //import android.support.annotation.Nullable; | 11 | import android.util.Log; |
12 | //import android.util.AttributeSet; | 12 | import android.view.Gravity; |
13 | //import android.util.Log; | 13 | import android.view.KeyEvent; |
14 | //import android.view.Gravity; | 14 | import android.view.View; |
15 | //import android.view.KeyEvent; | 15 | import android.widget.FrameLayout; |
16 | //import android.view.View; | 16 | import android.widget.ImageView; |
17 | //import android.widget.FrameLayout; | 17 | import android.widget.TextView; |
18 | //import android.widget.ImageView; | 18 | |
19 | //import android.widget.TextView; | 19 | import org.cocos2dx.javascript.AppActivity; |
20 | // | 20 | import org.json.JSONArray; |
21 | //import com.topdraw.melody.R; | 21 | import org.json.JSONException; |
22 | // | 22 | import org.json.JSONObject; |
23 | //import org.cocos2dx.javascript.AppActivity; | 23 | |
24 | //import org.json.JSONArray; | 24 | import java.io.BufferedInputStream; |
25 | //import org.json.JSONException; | 25 | import java.io.ByteArrayOutputStream; |
26 | //import org.json.JSONObject; | 26 | import java.io.IOException; |
27 | // | 27 | import java.net.HttpURLConnection; |
28 | //import java.io.BufferedInputStream; | 28 | import java.net.URL; |
29 | //import java.io.ByteArrayOutputStream; | 29 | import java.util.HashMap; |
30 | //import java.io.IOException; | 30 | import java.util.Map; |
31 | //import java.net.HttpURLConnection; | 31 | |
32 | //import java.net.URL; | 32 | import tv.icntv.adsdk.AdSDK; |
33 | //import java.util.HashMap; | 33 | |
34 | //import java.util.Map; | 34 | public class ADFrameLayout extends FrameLayout { |
35 | // | 35 | |
36 | //import tv.icntv.adsdk.AdSDK; | 36 | private static final String TAG = ADFrameLayout.class.getSimpleName(); |
37 | // | 37 | |
38 | //public class ADFrameLayout extends FrameLayout { | 38 | public static final String AD_TYPE_APP_OPEN = "open"; |
39 | // | 39 | |
40 | // private static final String TAG = ADFrameLayout.class.getSimpleName(); | 40 | private static JSONArray jaOpenInfo = new JSONArray(); |
41 | // | 41 | private static JSONArray jaDeskInfo = new JSONArray(); |
42 | // public static final String AD_TYPE_APP_OPEN = "open"; | 42 | |
43 | // | 43 | private static final int EVENT_TIME = 0; |
44 | // private static JSONArray jaOpenInfo = new JSONArray(); | 44 | private static final int EVENT_PIC_DOWNLOAD_START = 1; |
45 | // private static JSONArray jaDeskInfo = new JSONArray(); | 45 | private static final int EVENT_PIC_DOWNLOAD_SUCCESS = 2; |
46 | // | 46 | private static final int EVENT_PIC_DOWNLOAD_FAILURE = 3; |
47 | // private static final int EVENT_TIME = 0; | 47 | |
48 | // private static final int EVENT_PIC_DOWNLOAD_START = 1; | 48 | private Context context; |
49 | // private static final int EVENT_PIC_DOWNLOAD_SUCCESS = 2; | 49 | private AdSDK adSDK; |
50 | // private static final int EVENT_PIC_DOWNLOAD_FAILURE = 3; | 50 | |
51 | // | 51 | private ImageView iv; |
52 | // private Context context; | 52 | private TextView tv; |
53 | // private AdSDK adSDK; | 53 | private int left = 0; |
54 | // | 54 | |
55 | // private ImageView iv; | 55 | private JSONObject joOpen; |
56 | // private TextView tv; | 56 | |
57 | // private int left = 0; | 57 | public ADFrameLayout(Context context) { |
58 | // | 58 | super(context); |
59 | // private JSONObject joOpen; | 59 | this.context = context; |
60 | // | 60 | setVisibility(View.INVISIBLE); |
61 | // public ADFrameLayout(@NonNull Context context) { | 61 | } |
62 | // super(context); | 62 | |
63 | // this.context = context; | 63 | public ADFrameLayout(Context context, AttributeSet attrs) { |
64 | // setVisibility(View.INVISIBLE); | 64 | super(context, attrs); |
65 | // } | 65 | this.context = context; |
66 | // | 66 | } |
67 | // public ADFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) { | 67 | |
68 | // super(context, attrs); | 68 | public void init(AdSDK adSDK, String adInfo) { |
69 | // this.context = context; | 69 | this.adSDK = adSDK; |
70 | // } | 70 | try { |
71 | // | 71 | JSONObject jo = new JSONObject(adInfo); |
72 | // public void init(AdSDK adSDK, String adInfo) { | 72 | if (1 == jo.getInt("status")) { |
73 | // this.adSDK = adSDK; | 73 | JSONObject joAdspaces = jo.getJSONObject("adspaces"); |
74 | // try { | 74 | if (null != joAdspaces) { |
75 | // JSONObject jo = new JSONObject(adInfo); | 75 | jaOpenInfo = joAdspaces.getJSONArray("open"); |
76 | // if (1 == jo.getInt("status")) { | 76 | } |
77 | // JSONObject joAdspaces = jo.getJSONObject("adspaces"); | 77 | } |
78 | // if (null != joAdspaces) { | 78 | } catch (JSONException e) { |
79 | // jaOpenInfo = joAdspaces.getJSONArray("open"); | 79 | e.printStackTrace(); |
80 | // } | 80 | } |
81 | // } | 81 | } |
82 | // } catch (JSONException e) { | 82 | |
83 | // e.printStackTrace(); | 83 | public void playPic(String type) { |
84 | // } | 84 | if (AD_TYPE_APP_OPEN.equals(type)) { |
85 | // } | 85 | playPic(jaOpenInfo); |
86 | // | 86 | } |
87 | // public void playPic(String type) { | 87 | } |
88 | // if (AD_TYPE_APP_OPEN.equals(type)) { | 88 | |
89 | // playPic(jaOpenInfo); | 89 | private boolean needShowPicAD = false; |
90 | // } | 90 | private Map<String, Object> playingAD = null; |
91 | // } | 91 | |
92 | // | 92 | private void playPic(JSONArray jaAdInfo) { |
93 | // private boolean needShowPicAD = false; | 93 | needShowPicAD = true; |
94 | // private Map<String, Object> playingAD = null; | 94 | |
95 | // | 95 | JSONObject joOpen = null; |
96 | // private void playPic(JSONArray jaAdInfo) { | 96 | final Object[] objs = new Object[2]; |
97 | // needShowPicAD = true; | 97 | String path = null; |
98 | // | 98 | int time = 0; |
99 | // JSONObject joOpen = null; | 99 | try { |
100 | // final Object[] objs = new Object[2]; | 100 | if (null != jaAdInfo && jaAdInfo.length() > 0) { |
101 | // String path = null; | 101 | joOpen = jaAdInfo.getJSONObject(0); |
102 | // int time = 0; | 102 | playingAD = new HashMap<>(); |
103 | // try { | 103 | playingAD.put("mid", joOpen.getInt("mid")); |
104 | // if (null != jaAdInfo && jaAdInfo.length() > 0) { | 104 | playingAD.put("aid", joOpen.getString("aid")); |
105 | // joOpen = jaAdInfo.getJSONObject(0); | 105 | playingAD.put("mtid", joOpen.getJSONArray("materials").getJSONObject(0).getString("id")); |
106 | // playingAD = new HashMap<>(); | 106 | path = joOpen.getJSONArray("materials").getJSONObject(0).getString("file_path"); |
107 | // playingAD.put("mid", joOpen.getInt("mid")); | 107 | time = joOpen.getJSONArray("materials").getJSONObject(0).getInt("play_time"); |
108 | // playingAD.put("aid", joOpen.getString("aid")); | 108 | objs[0] = path; |
109 | // playingAD.put("mtid", joOpen.getJSONArray("materials").getJSONObject(0).getString("id")); | 109 | objs[1] = time; |
110 | // path = joOpen.getJSONArray("materials").getJSONObject(0).getString("file_path"); | 110 | } |
111 | // time = joOpen.getJSONArray("materials").getJSONObject(0).getInt("play_time"); | 111 | } catch (Exception e) { |
112 | // objs[0] = path; | 112 | |
113 | // objs[1] = time; | 113 | } |
114 | // } | 114 | if (null == joOpen || null == path) { |
115 | // } catch (Exception e) { | 115 | return; |
116 | // | 116 | } |
117 | // } | 117 | |
118 | // if (null == joOpen || null == path) { | 118 | new Thread(new Runnable() { |
119 | // return; | 119 | @Override |
120 | // } | 120 | public void run() { |
121 | // | 121 | byte[] result = null; |
122 | // new Thread(new Runnable() { | 122 | BufferedInputStream bis = null; |
123 | // @Override | 123 | ByteArrayOutputStream baos = null; |
124 | // public void run() { | 124 | try { |
125 | // byte[] result = null; | 125 | URL url = new URL((String) objs[0]); |
126 | // BufferedInputStream bis = null; | 126 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); |
127 | // ByteArrayOutputStream baos = null; | 127 | conn.setConnectTimeout(3000); |
128 | // try { | 128 | conn.setReadTimeout(5000); |
129 | // URL url = new URL((String) objs[0]); | 129 | conn.connect(); |
130 | // HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | 130 | if (200 == conn.getResponseCode()) { |
131 | // conn.setConnectTimeout(3000); | 131 | bis = new BufferedInputStream(conn.getInputStream()); |
132 | // conn.setReadTimeout(5000); | 132 | baos = new ByteArrayOutputStream(); |
133 | // conn.connect(); | 133 | byte[] buffer = new byte[1024]; |
134 | // if (200 == conn.getResponseCode()) { | 134 | int len = -1; |
135 | // bis = new BufferedInputStream(conn.getInputStream()); | 135 | while ((len = bis.read(buffer)) > 0) { |
136 | // baos = new ByteArrayOutputStream(); | 136 | baos.write(buffer, 0, len); |
137 | // byte[] buffer = new byte[1024]; | 137 | } |
138 | // int len = -1; | 138 | result = baos.toByteArray(); |
139 | // while ((len = bis.read(buffer)) > 0) { | 139 | } |
140 | // baos.write(buffer, 0, len); | 140 | } catch (Exception e) { |
141 | // } | 141 | |
142 | // result = baos.toByteArray(); | 142 | } finally { |
143 | // } | 143 | if (null != bis) { |
144 | // } catch (Exception e) { | 144 | try { |
145 | // | 145 | bis.close(); |
146 | // } finally { | 146 | } catch (IOException e) { |
147 | // if (null != bis) { | 147 | e.printStackTrace(); |
148 | // try { | 148 | } |
149 | // bis.close(); | 149 | } |
150 | // } catch (IOException e) { | 150 | if (null != baos) { |
151 | // e.printStackTrace(); | 151 | try { |
152 | // } | 152 | baos.close(); |
153 | // } | 153 | } catch (IOException e) { |
154 | // if (null != baos) { | 154 | e.printStackTrace(); |
155 | // try { | 155 | } |
156 | // baos.close(); | 156 | } |
157 | // } catch (IOException e) { | 157 | } |
158 | // e.printStackTrace(); | 158 | |
159 | // } | 159 | if (null != result) { |
160 | // } | 160 | Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length); |
161 | // } | 161 | handler.obtainMessage(EVENT_PIC_DOWNLOAD_SUCCESS, (int) objs[1], 0, bitmap).sendToTarget(); |
162 | // | 162 | } else { |
163 | // if (null != result) { | 163 | handler.obtainMessage(EVENT_PIC_DOWNLOAD_FAILURE).sendToTarget(); |
164 | // Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length); | 164 | } |
165 | // handler.obtainMessage(EVENT_PIC_DOWNLOAD_SUCCESS, (int) objs[1], 0, bitmap).sendToTarget(); | 165 | } |
166 | // } else { | 166 | }).start(); |
167 | // handler.obtainMessage(EVENT_PIC_DOWNLOAD_FAILURE).sendToTarget(); | 167 | } |
168 | // } | 168 | |
169 | // } | 169 | @SuppressLint("HandlerLeak") |
170 | // }).start(); | 170 | private Handler handler = new Handler() { |
171 | // } | 171 | @Override |
172 | // | 172 | public void handleMessage(Message msg) { |
173 | // @SuppressLint("HandlerLeak") | 173 | super.handleMessage(msg); |
174 | // private Handler handler = new Handler() { | 174 | switch (msg.what) { |
175 | // @Override | 175 | case EVENT_PIC_DOWNLOAD_SUCCESS: |
176 | // public void handleMessage(Message msg) { | 176 | iv = new ImageView(context); |
177 | // super.handleMessage(msg); | 177 | LayoutParams lpiv = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
178 | // switch (msg.what) { | 178 | iv.setLayoutParams(lpiv); |
179 | // case EVENT_PIC_DOWNLOAD_SUCCESS: | 179 | addView(iv); |
180 | // iv = new ImageView(context); | 180 | |
181 | // LayoutParams lpiv = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); | 181 | tv = new TextView(context); |
182 | // iv.setLayoutParams(lpiv); | 182 | LayoutParams lptv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); |
183 | // addView(iv); | 183 | lptv.gravity = Gravity.END; |
184 | // | 184 | lptv.topMargin = 30; |
185 | // tv = new TextView(context); | 185 | lptv.rightMargin = 30; |
186 | // LayoutParams lptv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); | 186 | tv.setLayoutParams(lptv); |
187 | // lptv.gravity = Gravity.END; | 187 | tv.setTextColor(Color.WHITE); |
188 | // lptv.topMargin = 30; | 188 | tv.setTextSize(28); |
189 | // lptv.rightMargin = 30; | 189 | addView(tv); |
190 | // tv.setLayoutParams(lptv); | 190 | |
191 | // tv.setTextColor(Color.WHITE); | 191 | Bitmap bitmap = (Bitmap) msg.obj; |
192 | // tv.setTextSize(28); | 192 | iv.setImageBitmap(bitmap); |
193 | // addView(tv); | 193 | setVisibility(View.VISIBLE); |
194 | // | 194 | |
195 | // Bitmap bitmap = (Bitmap) msg.obj; | 195 | left = msg.arg1; |
196 | // iv.setImageBitmap(bitmap); | 196 | tv.setText("广告剩余 " + left + " 秒"); |
197 | // setVisibility(View.VISIBLE); | 197 | handler.sendEmptyMessageDelayed(EVENT_TIME, 1000); |
198 | // | 198 | break; |
199 | // left = msg.arg1; | 199 | case EVENT_PIC_DOWNLOAD_FAILURE: |
200 | // tv.setText("广告剩余 " + left + " 秒"); | 200 | break; |
201 | // handler.sendEmptyMessageDelayed(EVENT_TIME, 1000); | 201 | case EVENT_TIME: |
202 | // break; | 202 | left -= 1; |
203 | // case EVENT_PIC_DOWNLOAD_FAILURE: | 203 | if (left > 0) { |
204 | // break; | 204 | tv.setText("广告剩余 " + left + " 秒"); |
205 | // case EVENT_TIME: | 205 | handler.sendEmptyMessageDelayed(EVENT_TIME, 1000); |
206 | // left -= 1; | 206 | } else { |
207 | // if (left > 0) { | 207 | setVisibility(View.INVISIBLE); |
208 | // tv.setText("广告剩余 " + left + " 秒"); | 208 | needShowPicAD = false; |
209 | // handler.sendEmptyMessageDelayed(EVENT_TIME, 1000); | 209 | removeAllViews(); |
210 | // } else { | 210 | if (null != adSDK && null != playingAD) { |
211 | // setVisibility(View.INVISIBLE); | 211 | int mid = (int) playingAD.get("mid"); |
212 | // needShowPicAD = false; | 212 | String aid = (String) playingAD.get("aid"); |
213 | // removeAllViews(); | 213 | String mtid = (String) playingAD.get("mtid"); |
214 | // if (null != adSDK && null != playingAD) { | 214 | adSDK.report("" + mid, aid, mtid, "", "", "", ""); |
215 | // int mid = (int) playingAD.get("mid"); | 215 | } |
216 | // String aid = (String) playingAD.get("aid"); | 216 | } |
217 | // String mtid = (String) playingAD.get("mtid"); | 217 | break; |
218 | // adSDK.report("" + mid, aid, mtid, "", "", "", ""); | 218 | default: |
219 | // } | 219 | break; |
220 | // } | 220 | } |
221 | // break; | 221 | } |
222 | // default: | 222 | }; |
223 | // break; | 223 | |
224 | // } | 224 | //开屏广告响应返回键退出应用 fix jerry |
225 | // } | 225 | @Override |
226 | // }; | 226 | public boolean dispatchKeyEvent(KeyEvent event) { |
227 | // | 227 | if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { |
228 | // //开屏广告响应返回键退出应用 fix jerry | 228 | if (event.getAction() == KeyEvent.ACTION_DOWN) { //按键 按下和移开会有两个不同的事件所以需要区分 |
229 | // @Override | 229 | ((AppActivity) context).finish(); |
230 | // public boolean dispatchKeyEvent(KeyEvent event) { | 230 | } |
231 | // if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { | 231 | } |
232 | // if (event.getAction() == KeyEvent.ACTION_DOWN) { //按键 按下和移开会有两个不同的事件所以需要区分 | 232 | return super.dispatchKeyEvent(event); |
233 | // ((AppActivity) context).finish(); | 233 | } |
234 | // } | 234 | } |
235 | // } | ||
236 | // return super.dispatchKeyEvent(event); | ||
237 | // } | ||
238 | //} | ... | ... |
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 | } | ... | ... |
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.content.pm.PackageInfo; | 4 | import android.content.pm.ApplicationInfo; |
5 | //import android.content.pm.PackageManager; | 5 | import android.content.pm.PackageInfo; |
6 | //import android.os.Handler; | 6 | import android.content.pm.PackageManager; |
7 | //import android.view.WindowManager; | 7 | import android.os.Handler; |
8 | //import android.widget.FrameLayout; | 8 | import android.view.WindowManager; |
9 | //import android.widget.Toast; | 9 | import android.widget.FrameLayout; |
10 | // | 10 | import android.widget.Toast; |
11 | //import org.cocos2dx.javascript.AppActivity; | 11 | |
12 | // | 12 | import org.cocos2dx.javascript.AppActivity; |
13 | //import java.util.UUID; | 13 | |
14 | // | 14 | import java.util.UUID; |
15 | //import tv.icntv.adsdk.AdSDK; | 15 | |
16 | //import tv.icntv.logsdk.logSDK; | 16 | import tv.icntv.adsdk.AdSDK; |
17 | //import tv.icntv.ottlogin.loginSDK; | 17 | import tv.icntv.logsdk.logSDK; |
18 | // | 18 | import tv.icntv.ottlogin.loginSDK; |
19 | //public class NewTVSDK { | 19 | |
20 | // | 20 | public class NewTVSDK { |
21 | // private static NewTVSDK instence; | 21 | |
22 | // private Context context; | 22 | private static NewTVSDK instence; |
23 | // private PackageInfo packageInfo; | 23 | private Context context; |
24 | // | 24 | private PackageInfo packageInfo; |
25 | // private NewTVSDK(Context context) { | 25 | |
26 | // this.context = context; | 26 | private NewTVSDK(Context context) { |
27 | // | 27 | this.context = context; |
28 | // try { | 28 | |
29 | // PackageManager pm = context.getPackageManager(); | 29 | try { |
30 | // packageInfo = pm.getPackageInfo(context.getPackageName(), 0); | 30 | PackageManager pm = context.getPackageManager(); |
31 | // } catch (Exception e) { | 31 | packageInfo = pm.getPackageInfo(context.getPackageName(), 0); |
32 | // | 32 | } catch (Exception e) { |
33 | // } | 33 | |
34 | // } | 34 | } |
35 | // | 35 | } |
36 | // public static NewTVSDK getInstence(Context context) { | 36 | |
37 | // if (null == instence) { | 37 | public static NewTVSDK getInstence(Context context) { |
38 | // instence = new NewTVSDK(context); | 38 | if (null == instence) { |
39 | // } | 39 | instence = new NewTVSDK(context); |
40 | // return instence; | 40 | } |
41 | // } | 41 | return instence; |
42 | // | 42 | } |
43 | // public void init() { | 43 | |
44 | // loginSDK sdk = loginSDK.getInstance(); | 44 | public void init() { |
45 | // String newTVAPPID = "4bf34d0e9acf4aa"; | 45 | ApplicationInfo appInfo = null; |
46 | // String newTVChannelCode = "2626046001"; | 46 | try { |
47 | // String newTVAppkey = "2e535b79fc515eb17c3c2039517d6c27"; | 47 | PackageManager pm = context.getPackageManager(); |
48 | // String newTVAppSecret = "4160dcc2d67eecea0410dc770856d3ae"; | 48 | appInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); |
49 | // sdk.sdkInit(loginSDK.TYPE_COMMON, newTVChannelCode, newTVAppkey, newTVAppSecret, context); | 49 | } catch (Exception e) { |
50 | // String retDeviceLogin = sdk.deviceLogin(); | 50 | |
51 | // logSDK logsdk; | 51 | } |
52 | // AdSDK adsdk = null; | 52 | |
53 | // ADFrameLayout adfl = null; | 53 | loginSDK sdk = loginSDK.getInstance(); |
54 | // NativeLogReporterNewTV nlp = null; | 54 | String newTVAPPID = appInfo.metaData.getString("NewTV.APPID");; |
55 | // if ("1".equals(retDeviceLogin) || "766".equals(retDeviceLogin) || "777".equals(retDeviceLogin) || "891".equals(retDeviceLogin)) { | 55 | String newTVChannelCode = appInfo.metaData.getString("NewTV.channelCode"); |
56 | // StringBuffer sbDeviceID = new StringBuffer(); | 56 | String newTVAppkey = appInfo.metaData.getString("NewTV.Appkey"); |
57 | // int retDeviceID = sdk.getDeviceID(sbDeviceID); | 57 | String newTVAppSecret =appInfo.metaData.getString("NewTV.AppSecret"); |
58 | // if (0 == retDeviceID) { | 58 | sdk.sdkInit(loginSDK.TYPE_COMMON, newTVChannelCode, newTVAppkey, newTVAppSecret, context); |
59 | // StringBuffer sbLogServer = new StringBuffer(); | 59 | String retDeviceLogin = sdk.deviceLogin(); |
60 | // int getLogServer = sdk.getServerAddress("USER_LOG", sbLogServer); | 60 | logSDK logsdk; |
61 | // if (0 == getLogServer) { | 61 | AdSDK adsdk = null; |
62 | // logsdk = logSDK.getInstance(); | 62 | ADFrameLayout adfl = null; |
63 | // boolean logSDKInitRet = logsdk.sdkInit(sbLogServer.toString(), sbDeviceID.toString(), UUID.randomUUID().toString(), newTVChannelCode, newTVAppkey); | 63 | NativeLogReporterNewTV nlp = null; |
64 | // if (logSDKInitRet) { | 64 | if ("1".equals(retDeviceLogin) || "766".equals(retDeviceLogin) || "777".equals(retDeviceLogin) || "891".equals(retDeviceLogin)) { |
65 | // nlp = NativeLogReporterNewTV.getInstance(this.context, logsdk); | 65 | StringBuffer sbDeviceID = new StringBuffer(); |
66 | // nlp.report(88, "0," + packageInfo.versionName); | 66 | int retDeviceID = sdk.getDeviceID(sbDeviceID); |
67 | // StringBuffer versionType = new StringBuffer(); | 67 | if (0 == retDeviceID) { |
68 | // sdk.getValueByKey("EXT_VERSION_TYPE", versionType); | 68 | StringBuffer sbLogServer = new StringBuffer(); |
69 | // StringBuffer versionCode = new StringBuffer(); | 69 | int getLogServer = sdk.getServerAddress("USER_LOG", sbLogServer); |
70 | // sdk.getValueByKey("EXT_VERSION_CODE", versionCode); | 70 | if (0 == getLogServer) { |
71 | // nlp.report(10, "0," + versionType.toString() + "," + versionCode.toString()); | 71 | logsdk = logSDK.getInstance(); |
72 | // } | 72 | boolean logSDKInitRet = logsdk.sdkInit(sbLogServer.toString(), sbDeviceID.toString(), UUID.randomUUID().toString(), newTVChannelCode, newTVAppkey); |
73 | // } | 73 | if (logSDKInitRet) { |
74 | // | 74 | nlp = NativeLogReporterNewTV.getInstance(this.context, logsdk); |
75 | // StringBuffer sbAdServer = new StringBuffer(); | 75 | nlp.report(88, "0," + packageInfo.versionName); |
76 | // int getAdServer = sdk.getServerAddress("AD", sbAdServer); | 76 | StringBuffer versionType = new StringBuffer(); |
77 | // if (0 == getAdServer) { | 77 | sdk.getValueByKey("EXT_VERSION_TYPE", versionType); |
78 | // adsdk = AdSDK.getInstance(); | 78 | StringBuffer versionCode = new StringBuffer(); |
79 | // boolean adSDKInitRet = adsdk.init(sbAdServer.toString(), sbDeviceID.toString(), newTVAppkey, newTVChannelCode, null, context.getApplicationContext()); | 79 | sdk.getValueByKey("EXT_VERSION_CODE", versionCode); |
80 | // if (adSDKInitRet) { | 80 | nlp.report(10, "0," + versionType.toString() + "," + versionCode.toString()); |
81 | // StringBuffer sbAdData = new StringBuffer(); | 81 | } |
82 | // int adSDKGetADRet = adsdk.getAD("open", null, null, null, null, null, sbAdData); | 82 | } |
83 | // if (0 == adSDKGetADRet) { | 83 | |
84 | // String adInfo = sbAdData.toString(); | 84 | StringBuffer sbAdServer = new StringBuffer(); |
85 | //// fl_ad = findViewById(R.id.fl_ad); | 85 | int getAdServer = sdk.getServerAddress("AD", sbAdServer); |
86 | //// adfl = new ADFrameLayout(this); | 86 | if (0 == getAdServer) { |
87 | //// fl_ad.addView(adfl); | 87 | adsdk = AdSDK.getInstance(); |
88 | //// adfl.init(adsdk, adInfo); | 88 | boolean adSDKInitRet = adsdk.init(sbAdServer.toString(), sbDeviceID.toString(), newTVAppkey, newTVChannelCode, null, context.getApplicationContext()); |
89 | //// adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN); | 89 | if (adSDKInitRet) { |
90 | // | 90 | StringBuffer sbAdData = new StringBuffer(); |
91 | //// adfl = new ADFrameLayout(context); | 91 | int adSDKGetADRet = adsdk.getAD("open", null, null, null, null, null, sbAdData); |
92 | //// ((AppActivity) context).addContentView(adfl, new WindowManager.LayoutParams( | 92 | if (0 == adSDKGetADRet) { |
93 | //// FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); | 93 | String adInfo = sbAdData.toString(); |
94 | //// adfl.init(adsdk, adInfo); | 94 | // fl_ad = findViewById(R.id.fl_ad); |
95 | //// adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN); | 95 | // adfl = new ADFrameLayout(this); |
96 | // | 96 | // fl_ad.addView(adfl); |
97 | // //顶层窗口,覆盖Activity | 97 | // adfl.init(adsdk, adInfo); |
98 | // adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN); | ||
99 | |||
98 | // adfl = new ADFrameLayout(context); | 100 | // adfl = new ADFrameLayout(context); |
99 | // final WindowManager mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | 101 | // ((AppActivity) context).addContentView(adfl, new WindowManager.LayoutParams( |
100 | // WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(); | 102 | // FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); |
101 | // mWm.addView(adfl, mParams); | ||
102 | // adfl.init(adsdk, adInfo); | 103 | // adfl.init(adsdk, adInfo); |
103 | // adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN); | 104 | // adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN); |
104 | // } | 105 | |
105 | // } | 106 | //顶层窗口,覆盖Activity |
106 | // } | 107 | adfl = new ADFrameLayout(context); |
107 | // } else { | 108 | final WindowManager mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); |
108 | // Toast.makeText(context, "获取设备信息失败 " + retDeviceID, Toast.LENGTH_LONG).show(); | 109 | WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(); |
109 | // new Handler().postDelayed(new Runnable() { | 110 | mWm.addView(adfl, mParams); |
110 | // @Override | 111 | adfl.init(adsdk, adInfo); |
111 | // public void run() { | 112 | adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN); |
112 | // ((AppActivity) context).finish(); | 113 | } |
113 | // } | 114 | } |
114 | // }, 3000); | 115 | } |
115 | // } | 116 | } else { |
116 | // } else { | 117 | Toast.makeText(context, "获取设备信息失败 " + retDeviceID, Toast.LENGTH_LONG).show(); |
117 | // Toast.makeText(context, "认证失败 " + retDeviceLogin, Toast.LENGTH_LONG).show(); | 118 | new Handler().postDelayed(new Runnable() { |
118 | // new Handler().postDelayed(new Runnable() { | 119 | @Override |
119 | // @Override | 120 | public void run() { |
120 | // public void run() { | 121 | ((AppActivity) context).finish(); |
121 | // ((AppActivity) context).finish(); | 122 | } |
122 | // } | 123 | }, 3000); |
123 | // }, 3000); | 124 | } |
124 | // } | 125 | } else { |
125 | // } | 126 | Toast.makeText(context, "认证失败 " + retDeviceLogin, Toast.LENGTH_LONG).show(); |
126 | //} | 127 | new Handler().postDelayed(new Runnable() { |
128 | @Override | ||
129 | public void run() { | ||
130 | ((AppActivity) context).finish(); | ||
131 | } | ||
132 | }, 3000); | ||
133 | } | ||
134 | } | ||
135 | } | ... | ... |
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