Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
apk_product
/
ForFun
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
2da9e428
...
2da9e4280e8085993d83b4b57ee54d21b3f01179
authored
2020-04-07 16:58:27 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.福建初始化相关sdk(Topdraw、NewTV、局方埋点)
1 parent
da0357d4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
583 additions
and
516 deletions
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/component/ADFrameLayout.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/component/NativeLogReporterNewTV.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/component/NewTVSDK.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/MelodyApplication.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/TopdrawSDKWrapper.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml
View file @
2da9e42
...
...
@@ -5,17 +5,17 @@
<uses-feature
android:glEsVersion=
"0x00020000"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.CHANGE_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.RESTART_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.KILL_BACKGROUND_PROCESSES"
/>
...
...
@@ -27,18 +27,20 @@
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"com.hiveview.cloudscreen.user.READPROVIDER"
/>
<uses-permission
android:name=
"com.hiveview.cloudscreen.user.WRITE_USERINFO_DB"
/>
<uses-permission
android:name=
"com.hiveview.cloudscreen.user.WRITE_USERINFO_DB"
/>
<application
android:allowBackup=
"true"
android:name=
"com.topdraw.melody.MelodyApplication"
android:label=
"@string/app_name"
android:icon=
"@mipmap/icon"
>
android:allowBackup=
"true"
android:icon=
"@mipmap/icon"
android:label=
"@string/app_name"
>
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data
android:name=
"android.app.lib_name"
android:value=
"cocos2djs"
/>
<meta-data
android:name=
"android.app.lib_name"
android:value=
"cocos2djs"
/>
<!-- TopdrawSDK -->
<activity
android:name=
"com.topdraw.sdk.TopdrawActivity"
android:process=
":plugin"
...
...
@@ -46,26 +48,42 @@
<meta-data
android:name=
"TOPDRAW.PLATFORM"
android:value=
"
CMCC.HaiNan
"
/>
android:value=
"
FJ.CMCC
"
/>
<meta-data
android:name=
"TOPDRAW.PLATFORM_SERVER"
android:value=
"http://
melody.hi.a170.ottcn.com/hyperion.chimera
"
/>
android:value=
"http://
eastcity.fj.a176.ottcn.com:81/clutch
"
/>
<meta-data
android:name=
"TOPDRAW.APPID"
android:value=
"td71b187fedb257ac0"
/>
android:value=
"EastCity"
/>
<!-- 移动埋点SDK -->
<meta-data
android:name=
"CMCC.APPKEY"
android:value=
"13e71c3ecc4d4b96f1b5b0e5141bd3e6"
/>
<!-- 未来NewTV -->
<meta-data
android:name=
"NewTV.APPID"
android:value=
"0e0777adb659479"
/>
<meta-data
android:name=
"TOPDRAW.APPSECRET"
android:value=
"432f53029ae58eef34ec9a6794975443"
/>
android:name=
"NewTV.channelCode"
android:value=
"\2626035001"
/>
<meta-data
android:name=
"NewTV.Appkey"
android:value=
"df4fc19c4673bf9b5e70a7a56ece35e5"
/>
<meta-data
android:name=
"NewTV.AppSecret"
android:value=
"ec695c7b7371db8dbd84a6d01e4c66a9"
/>
<activity
android:name=
"org.cocos2dx.javascript.AppActivity"
android:screenOrientation=
"sensorLandscape"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:label=
"@string/app_name"
android:usesCleartextTraffic=
"true"
android:theme=
"@style/ImageSplashStyle"
android:launchMode=
"singleTask"
android:taskAffinity=
""
>
android:screenOrientation=
"sensorLandscape"
android:taskAffinity=
""
android:theme=
"@style/ImageSplashStyle"
android:usesCleartextTraffic=
"true"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -73,5 +91,5 @@
</intent-filter>
</activity>
</application>
</manifest>
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/component/ADFrameLayout.java
View file @
2da9e42
//package com.topdraw.component;
//
//import android.annotation.SuppressLint;
//import android.content.Context;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.graphics.Color;
//import android.os.Handler;
//import android.os.Message;
//import android.support.annotation.NonNull;
//import android.support.annotation.Nullable;
//import android.util.AttributeSet;
//import android.util.Log;
//import android.view.Gravity;
//import android.view.KeyEvent;
//import android.view.View;
//import android.widget.FrameLayout;
//import android.widget.ImageView;
//import android.widget.TextView;
//
//import com.topdraw.melody.R;
//
//import org.cocos2dx.javascript.AppActivity;
//import org.json.JSONArray;
//import org.json.JSONException;
//import org.json.JSONObject;
//
//import java.io.BufferedInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.util.HashMap;
//import java.util.Map;
//
//import tv.icntv.adsdk.AdSDK;
//
//public class ADFrameLayout extends FrameLayout {
//
// private static final String TAG = ADFrameLayout.class.getSimpleName();
//
// public static final String AD_TYPE_APP_OPEN = "open";
//
// private static JSONArray jaOpenInfo = new JSONArray();
// private static JSONArray jaDeskInfo = new JSONArray();
//
// private static final int EVENT_TIME = 0;
// private static final int EVENT_PIC_DOWNLOAD_START = 1;
// private static final int EVENT_PIC_DOWNLOAD_SUCCESS = 2;
// private static final int EVENT_PIC_DOWNLOAD_FAILURE = 3;
//
// private Context context;
// private AdSDK adSDK;
//
// private ImageView iv;
// private TextView tv;
// private int left = 0;
//
// private JSONObject joOpen;
//
// public ADFrameLayout(@NonNull Context context) {
// super(context);
// this.context = context;
// setVisibility(View.INVISIBLE);
// }
//
// public ADFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// this.context = context;
// }
//
// public void init(AdSDK adSDK, String adInfo) {
// this.adSDK = adSDK;
// try {
// JSONObject jo = new JSONObject(adInfo);
// if (1 == jo.getInt("status")) {
// JSONObject joAdspaces = jo.getJSONObject("adspaces");
// if (null != joAdspaces) {
// jaOpenInfo = joAdspaces.getJSONArray("open");
// }
// }
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
//
// public void playPic(String type) {
// if (AD_TYPE_APP_OPEN.equals(type)) {
// playPic(jaOpenInfo);
// }
// }
//
// private boolean needShowPicAD = false;
// private Map<String, Object> playingAD = null;
//
// private void playPic(JSONArray jaAdInfo) {
// needShowPicAD = true;
//
// JSONObject joOpen = null;
// final Object[] objs = new Object[2];
// String path = null;
// int time = 0;
// try {
// if (null != jaAdInfo && jaAdInfo.length() > 0) {
// joOpen = jaAdInfo.getJSONObject(0);
// playingAD = new HashMap<>();
// playingAD.put("mid", joOpen.getInt("mid"));
// playingAD.put("aid", joOpen.getString("aid"));
// playingAD.put("mtid", joOpen.getJSONArray("materials").getJSONObject(0).getString("id"));
// path = joOpen.getJSONArray("materials").getJSONObject(0).getString("file_path");
// time = joOpen.getJSONArray("materials").getJSONObject(0).getInt("play_time");
// objs[0] = path;
// objs[1] = time;
// }
// } catch (Exception e) {
//
// }
// if (null == joOpen || null == path) {
// return;
// }
//
// new Thread(new Runnable() {
// @Override
// public void run() {
// byte[] result = null;
// BufferedInputStream bis = null;
// ByteArrayOutputStream baos = null;
// try {
// URL url = new URL((String) objs[0]);
// HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// conn.setConnectTimeout(3000);
// conn.setReadTimeout(5000);
// conn.connect();
// if (200 == conn.getResponseCode()) {
// bis = new BufferedInputStream(conn.getInputStream());
// baos = new ByteArrayOutputStream();
// byte[] buffer = new byte[1024];
// int len = -1;
// while ((len = bis.read(buffer)) > 0) {
// baos.write(buffer, 0, len);
// }
// result = baos.toByteArray();
// }
// } catch (Exception e) {
//
// } finally {
// if (null != bis) {
// try {
// bis.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// if (null != baos) {
// try {
// baos.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// if (null != result) {
// Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length);
// handler.obtainMessage(EVENT_PIC_DOWNLOAD_SUCCESS, (int) objs[1], 0, bitmap).sendToTarget();
// } else {
// handler.obtainMessage(EVENT_PIC_DOWNLOAD_FAILURE).sendToTarget();
// }
// }
// }).start();
// }
//
// @SuppressLint("HandlerLeak")
// private Handler handler = new Handler() {
// @Override
// public void handleMessage(Message msg) {
// super.handleMessage(msg);
// switch (msg.what) {
// case EVENT_PIC_DOWNLOAD_SUCCESS:
// iv = new ImageView(context);
// LayoutParams lpiv = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
// iv.setLayoutParams(lpiv);
// addView(iv);
//
// tv = new TextView(context);
// LayoutParams lptv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
// lptv.gravity = Gravity.END;
// lptv.topMargin = 30;
// lptv.rightMargin = 30;
// tv.setLayoutParams(lptv);
// tv.setTextColor(Color.WHITE);
// tv.setTextSize(28);
// addView(tv);
//
// Bitmap bitmap = (Bitmap) msg.obj;
// iv.setImageBitmap(bitmap);
// setVisibility(View.VISIBLE);
//
// left = msg.arg1;
// tv.setText("广告剩余 " + left + " 秒");
// handler.sendEmptyMessageDelayed(EVENT_TIME, 1000);
// break;
// case EVENT_PIC_DOWNLOAD_FAILURE:
// break;
// case EVENT_TIME:
// left -= 1;
// if (left > 0) {
// tv.setText("广告剩余 " + left + " 秒");
// handler.sendEmptyMessageDelayed(EVENT_TIME, 1000);
// } else {
// setVisibility(View.INVISIBLE);
// needShowPicAD = false;
// removeAllViews();
// if (null != adSDK && null != playingAD) {
// int mid = (int) playingAD.get("mid");
// String aid = (String) playingAD.get("aid");
// String mtid = (String) playingAD.get("mtid");
// adSDK.report("" + mid, aid, mtid, "", "", "", "");
// }
// }
// break;
// default:
// break;
// }
// }
// };
//
// //开屏广告响应返回键退出应用 fix jerry
// @Override
// public boolean dispatchKeyEvent(KeyEvent event) {
// if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
// if (event.getAction() == KeyEvent.ACTION_DOWN) { //按键 按下和移开会有两个不同的事件所以需要区分
// ((AppActivity) context).finish();
// }
// }
// return super.dispatchKeyEvent(event);
// }
//}
package
com
.
topdraw
.
component
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Color
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
org.cocos2dx.javascript.AppActivity
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.BufferedInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.Map
;
import
tv.icntv.adsdk.AdSDK
;
public
class
ADFrameLayout
extends
FrameLayout
{
private
static
final
String
TAG
=
ADFrameLayout
.
class
.
getSimpleName
();
public
static
final
String
AD_TYPE_APP_OPEN
=
"open"
;
private
static
JSONArray
jaOpenInfo
=
new
JSONArray
();
private
static
JSONArray
jaDeskInfo
=
new
JSONArray
();
private
static
final
int
EVENT_TIME
=
0
;
private
static
final
int
EVENT_PIC_DOWNLOAD_START
=
1
;
private
static
final
int
EVENT_PIC_DOWNLOAD_SUCCESS
=
2
;
private
static
final
int
EVENT_PIC_DOWNLOAD_FAILURE
=
3
;
private
Context
context
;
private
AdSDK
adSDK
;
private
ImageView
iv
;
private
TextView
tv
;
private
int
left
=
0
;
private
JSONObject
joOpen
;
public
ADFrameLayout
(
Context
context
)
{
super
(
context
);
this
.
context
=
context
;
setVisibility
(
View
.
INVISIBLE
);
}
public
ADFrameLayout
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
this
.
context
=
context
;
}
public
void
init
(
AdSDK
adSDK
,
String
adInfo
)
{
this
.
adSDK
=
adSDK
;
try
{
JSONObject
jo
=
new
JSONObject
(
adInfo
);
if
(
1
==
jo
.
getInt
(
"status"
))
{
JSONObject
joAdspaces
=
jo
.
getJSONObject
(
"adspaces"
);
if
(
null
!=
joAdspaces
)
{
jaOpenInfo
=
joAdspaces
.
getJSONArray
(
"open"
);
}
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
public
void
playPic
(
String
type
)
{
if
(
AD_TYPE_APP_OPEN
.
equals
(
type
))
{
playPic
(
jaOpenInfo
);
}
}
private
boolean
needShowPicAD
=
false
;
private
Map
<
String
,
Object
>
playingAD
=
null
;
private
void
playPic
(
JSONArray
jaAdInfo
)
{
needShowPicAD
=
true
;
JSONObject
joOpen
=
null
;
final
Object
[]
objs
=
new
Object
[
2
];
String
path
=
null
;
int
time
=
0
;
try
{
if
(
null
!=
jaAdInfo
&&
jaAdInfo
.
length
()
>
0
)
{
joOpen
=
jaAdInfo
.
getJSONObject
(
0
);
playingAD
=
new
HashMap
<>();
playingAD
.
put
(
"mid"
,
joOpen
.
getInt
(
"mid"
));
playingAD
.
put
(
"aid"
,
joOpen
.
getString
(
"aid"
));
playingAD
.
put
(
"mtid"
,
joOpen
.
getJSONArray
(
"materials"
).
getJSONObject
(
0
).
getString
(
"id"
));
path
=
joOpen
.
getJSONArray
(
"materials"
).
getJSONObject
(
0
).
getString
(
"file_path"
);
time
=
joOpen
.
getJSONArray
(
"materials"
).
getJSONObject
(
0
).
getInt
(
"play_time"
);
objs
[
0
]
=
path
;
objs
[
1
]
=
time
;
}
}
catch
(
Exception
e
)
{
}
if
(
null
==
joOpen
||
null
==
path
)
{
return
;
}
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
byte
[]
result
=
null
;
BufferedInputStream
bis
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
{
URL
url
=
new
URL
((
String
)
objs
[
0
]);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setConnectTimeout
(
3000
);
conn
.
setReadTimeout
(
5000
);
conn
.
connect
();
if
(
200
==
conn
.
getResponseCode
())
{
bis
=
new
BufferedInputStream
(
conn
.
getInputStream
());
baos
=
new
ByteArrayOutputStream
();
byte
[]
buffer
=
new
byte
[
1024
];
int
len
=
-
1
;
while
((
len
=
bis
.
read
(
buffer
))
>
0
)
{
baos
.
write
(
buffer
,
0
,
len
);
}
result
=
baos
.
toByteArray
();
}
}
catch
(
Exception
e
)
{
}
finally
{
if
(
null
!=
bis
)
{
try
{
bis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
null
!=
baos
)
{
try
{
baos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
if
(
null
!=
result
)
{
Bitmap
bitmap
=
BitmapFactory
.
decodeByteArray
(
result
,
0
,
result
.
length
);
handler
.
obtainMessage
(
EVENT_PIC_DOWNLOAD_SUCCESS
,
(
int
)
objs
[
1
],
0
,
bitmap
).
sendToTarget
();
}
else
{
handler
.
obtainMessage
(
EVENT_PIC_DOWNLOAD_FAILURE
).
sendToTarget
();
}
}
}).
start
();
}
@SuppressLint
(
"HandlerLeak"
)
private
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
EVENT_PIC_DOWNLOAD_SUCCESS:
iv
=
new
ImageView
(
context
);
LayoutParams
lpiv
=
new
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
LayoutParams
.
MATCH_PARENT
);
iv
.
setLayoutParams
(
lpiv
);
addView
(
iv
);
tv
=
new
TextView
(
context
);
LayoutParams
lptv
=
new
LayoutParams
(
LayoutParams
.
WRAP_CONTENT
,
LayoutParams
.
WRAP_CONTENT
);
lptv
.
gravity
=
Gravity
.
END
;
lptv
.
topMargin
=
30
;
lptv
.
rightMargin
=
30
;
tv
.
setLayoutParams
(
lptv
);
tv
.
setTextColor
(
Color
.
WHITE
);
tv
.
setTextSize
(
28
);
addView
(
tv
);
Bitmap
bitmap
=
(
Bitmap
)
msg
.
obj
;
iv
.
setImageBitmap
(
bitmap
);
setVisibility
(
View
.
VISIBLE
);
left
=
msg
.
arg1
;
tv
.
setText
(
"广告剩余 "
+
left
+
" 秒"
);
handler
.
sendEmptyMessageDelayed
(
EVENT_TIME
,
1000
);
break
;
case
EVENT_PIC_DOWNLOAD_FAILURE:
break
;
case
EVENT_TIME:
left
-=
1
;
if
(
left
>
0
)
{
tv
.
setText
(
"广告剩余 "
+
left
+
" 秒"
);
handler
.
sendEmptyMessageDelayed
(
EVENT_TIME
,
1000
);
}
else
{
setVisibility
(
View
.
INVISIBLE
);
needShowPicAD
=
false
;
removeAllViews
();
if
(
null
!=
adSDK
&&
null
!=
playingAD
)
{
int
mid
=
(
int
)
playingAD
.
get
(
"mid"
);
String
aid
=
(
String
)
playingAD
.
get
(
"aid"
);
String
mtid
=
(
String
)
playingAD
.
get
(
"mtid"
);
adSDK
.
report
(
""
+
mid
,
aid
,
mtid
,
""
,
""
,
""
,
""
);
}
}
break
;
default
:
break
;
}
}
};
//开屏广告响应返回键退出应用 fix jerry
@Override
public
boolean
dispatchKeyEvent
(
KeyEvent
event
)
{
if
(
event
.
getKeyCode
()
==
KeyEvent
.
KEYCODE_BACK
)
{
if
(
event
.
getAction
()
==
KeyEvent
.
ACTION_DOWN
)
{
//按键 按下和移开会有两个不同的事件所以需要区分
((
AppActivity
)
context
).
finish
();
}
}
return
super
.
dispatchKeyEvent
(
event
);
}
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/component/NativeLogReporterNewTV.java
View file @
2da9e42
//
package com.topdraw.component;
//
//
import android.content.Context;
//
import android.util.Log;
//
import android.webkit.JavascriptInterface;
//
//
import tv.icntv.logsdk.logSDK;
//
//
public class NativeLogReporterNewTV {
//
//
private static final String TAG = NativeLogReporterNewTV.class.getSimpleName();
//
//
private static NativeLogReporterNewTV instance;
//
//
private static logSDK sdk;
//
//
private Context context;
//
//
private NativeLogReporterNewTV(Context context, logSDK sdk) {
//
this.context = context;
//
this.sdk = sdk;
//
}
//
//
public static NativeLogReporterNewTV getInstance(Context context, logSDK sdk) {
//
Log.d(TAG, "初始化LogReporter..." + instance);
//
if (null == instance) {
//
instance = new NativeLogReporterNewTV(context, sdk);
//
}
//
return instance;
//
}
//
//
public static void report(int i, String msg) {
//
if (null != sdk) {
//
Log.d(TAG, "log report | " + i + " " + msg);
//
sdk.logUpload(i, null != msg ? msg : "");
//
}
//
}
//
//
}
package
com
.
topdraw
.
component
;
import
android.content.Context
;
import
android.util.Log
;
import
android.webkit.JavascriptInterface
;
import
tv.icntv.logsdk.logSDK
;
public
class
NativeLogReporterNewTV
{
private
static
final
String
TAG
=
NativeLogReporterNewTV
.
class
.
getSimpleName
();
private
static
NativeLogReporterNewTV
instance
;
private
static
logSDK
sdk
;
private
Context
context
;
private
NativeLogReporterNewTV
(
Context
context
,
logSDK
sdk
)
{
this
.
context
=
context
;
this
.
sdk
=
sdk
;
}
public
static
NativeLogReporterNewTV
getInstance
(
Context
context
,
logSDK
sdk
)
{
Log
.
d
(
TAG
,
"初始化LogReporter..."
+
instance
);
if
(
null
==
instance
)
{
instance
=
new
NativeLogReporterNewTV
(
context
,
sdk
);
}
return
instance
;
}
public
static
void
report
(
int
i
,
String
msg
)
{
if
(
null
!=
sdk
)
{
Log
.
d
(
TAG
,
"log report | "
+
i
+
" "
+
msg
);
sdk
.
logUpload
(
i
,
null
!=
msg
?
msg
:
""
);
}
}
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/component/NewTVSDK.java
View file @
2da9e42
//package com.topdraw.component;
//
//import android.content.Context;
//import android.content.pm.PackageInfo;
//import android.content.pm.PackageManager;
//import android.os.Handler;
//import android.view.WindowManager;
//import android.widget.FrameLayout;
//import android.widget.Toast;
//
//import org.cocos2dx.javascript.AppActivity;
//
//import java.util.UUID;
//
//import tv.icntv.adsdk.AdSDK;
//import tv.icntv.logsdk.logSDK;
//import tv.icntv.ottlogin.loginSDK;
//
//public class NewTVSDK {
//
// private static NewTVSDK instence;
// private Context context;
// private PackageInfo packageInfo;
//
// private NewTVSDK(Context context) {
// this.context = context;
//
// try {
// PackageManager pm = context.getPackageManager();
// packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
// } catch (Exception e) {
//
// }
// }
//
// public static NewTVSDK getInstence(Context context) {
// if (null == instence) {
// instence = new NewTVSDK(context);
// }
// return instence;
// }
//
// public void init() {
// loginSDK sdk = loginSDK.getInstance();
// String newTVAPPID = "4bf34d0e9acf4aa";
// String newTVChannelCode = "2626046001";
// String newTVAppkey = "2e535b79fc515eb17c3c2039517d6c27";
// String newTVAppSecret = "4160dcc2d67eecea0410dc770856d3ae";
// sdk.sdkInit(loginSDK.TYPE_COMMON, newTVChannelCode, newTVAppkey, newTVAppSecret, context);
// String retDeviceLogin = sdk.deviceLogin();
// logSDK logsdk;
// AdSDK adsdk = null;
// ADFrameLayout adfl = null;
// NativeLogReporterNewTV nlp = null;
// if ("1".equals(retDeviceLogin) || "766".equals(retDeviceLogin) || "777".equals(retDeviceLogin) || "891".equals(retDeviceLogin)) {
// StringBuffer sbDeviceID = new StringBuffer();
// int retDeviceID = sdk.getDeviceID(sbDeviceID);
// if (0 == retDeviceID) {
// StringBuffer sbLogServer = new StringBuffer();
// int getLogServer = sdk.getServerAddress("USER_LOG", sbLogServer);
// if (0 == getLogServer) {
// logsdk = logSDK.getInstance();
// boolean logSDKInitRet = logsdk.sdkInit(sbLogServer.toString(), sbDeviceID.toString(), UUID.randomUUID().toString(), newTVChannelCode, newTVAppkey);
// if (logSDKInitRet) {
// nlp = NativeLogReporterNewTV.getInstance(this.context, logsdk);
// nlp.report(88, "0," + packageInfo.versionName);
// StringBuffer versionType = new StringBuffer();
// sdk.getValueByKey("EXT_VERSION_TYPE", versionType);
// StringBuffer versionCode = new StringBuffer();
// sdk.getValueByKey("EXT_VERSION_CODE", versionCode);
// nlp.report(10, "0," + versionType.toString() + "," + versionCode.toString());
// }
// }
//
// StringBuffer sbAdServer = new StringBuffer();
// int getAdServer = sdk.getServerAddress("AD", sbAdServer);
// if (0 == getAdServer) {
// adsdk = AdSDK.getInstance();
// boolean adSDKInitRet = adsdk.init(sbAdServer.toString(), sbDeviceID.toString(), newTVAppkey, newTVChannelCode, null, context.getApplicationContext());
// if (adSDKInitRet) {
// StringBuffer sbAdData = new StringBuffer();
// int adSDKGetADRet = adsdk.getAD("open", null, null, null, null, null, sbAdData);
// if (0 == adSDKGetADRet) {
// String adInfo = sbAdData.toString();
//// fl_ad = findViewById(R.id.fl_ad);
//// adfl = new ADFrameLayout(this);
//// fl_ad.addView(adfl);
//// adfl.init(adsdk, adInfo);
//// adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN);
//
//// adfl = new ADFrameLayout(context);
//// ((AppActivity) context).addContentView(adfl, new WindowManager.LayoutParams(
//// FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
//// adfl.init(adsdk, adInfo);
//// adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN);
//
// //顶层窗口,覆盖Activity
package
com
.
topdraw
.
component
;
import
android.content.Context
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Handler
;
import
android.view.WindowManager
;
import
android.widget.FrameLayout
;
import
android.widget.Toast
;
import
org.cocos2dx.javascript.AppActivity
;
import
java.util.UUID
;
import
tv.icntv.adsdk.AdSDK
;
import
tv.icntv.logsdk.logSDK
;
import
tv.icntv.ottlogin.loginSDK
;
public
class
NewTVSDK
{
private
static
NewTVSDK
instence
;
private
Context
context
;
private
PackageInfo
packageInfo
;
private
NewTVSDK
(
Context
context
)
{
this
.
context
=
context
;
try
{
PackageManager
pm
=
context
.
getPackageManager
();
packageInfo
=
pm
.
getPackageInfo
(
context
.
getPackageName
(),
0
);
}
catch
(
Exception
e
)
{
}
}
public
static
NewTVSDK
getInstence
(
Context
context
)
{
if
(
null
==
instence
)
{
instence
=
new
NewTVSDK
(
context
);
}
return
instence
;
}
public
void
init
()
{
ApplicationInfo
appInfo
=
null
;
try
{
PackageManager
pm
=
context
.
getPackageManager
();
appInfo
=
pm
.
getApplicationInfo
(
context
.
getPackageName
(),
PackageManager
.
GET_META_DATA
);
}
catch
(
Exception
e
)
{
}
loginSDK
sdk
=
loginSDK
.
getInstance
();
String
newTVAPPID
=
appInfo
.
metaData
.
getString
(
"NewTV.APPID"
);;
String
newTVChannelCode
=
appInfo
.
metaData
.
getString
(
"NewTV.channelCode"
);
String
newTVAppkey
=
appInfo
.
metaData
.
getString
(
"NewTV.Appkey"
);
String
newTVAppSecret
=
appInfo
.
metaData
.
getString
(
"NewTV.AppSecret"
);
sdk
.
sdkInit
(
loginSDK
.
TYPE_COMMON
,
newTVChannelCode
,
newTVAppkey
,
newTVAppSecret
,
context
);
String
retDeviceLogin
=
sdk
.
deviceLogin
();
logSDK
logsdk
;
AdSDK
adsdk
=
null
;
ADFrameLayout
adfl
=
null
;
NativeLogReporterNewTV
nlp
=
null
;
if
(
"1"
.
equals
(
retDeviceLogin
)
||
"766"
.
equals
(
retDeviceLogin
)
||
"777"
.
equals
(
retDeviceLogin
)
||
"891"
.
equals
(
retDeviceLogin
))
{
StringBuffer
sbDeviceID
=
new
StringBuffer
();
int
retDeviceID
=
sdk
.
getDeviceID
(
sbDeviceID
);
if
(
0
==
retDeviceID
)
{
StringBuffer
sbLogServer
=
new
StringBuffer
();
int
getLogServer
=
sdk
.
getServerAddress
(
"USER_LOG"
,
sbLogServer
);
if
(
0
==
getLogServer
)
{
logsdk
=
logSDK
.
getInstance
();
boolean
logSDKInitRet
=
logsdk
.
sdkInit
(
sbLogServer
.
toString
(),
sbDeviceID
.
toString
(),
UUID
.
randomUUID
().
toString
(),
newTVChannelCode
,
newTVAppkey
);
if
(
logSDKInitRet
)
{
nlp
=
NativeLogReporterNewTV
.
getInstance
(
this
.
context
,
logsdk
);
nlp
.
report
(
88
,
"0,"
+
packageInfo
.
versionName
);
StringBuffer
versionType
=
new
StringBuffer
();
sdk
.
getValueByKey
(
"EXT_VERSION_TYPE"
,
versionType
);
StringBuffer
versionCode
=
new
StringBuffer
();
sdk
.
getValueByKey
(
"EXT_VERSION_CODE"
,
versionCode
);
nlp
.
report
(
10
,
"0,"
+
versionType
.
toString
()
+
","
+
versionCode
.
toString
());
}
}
StringBuffer
sbAdServer
=
new
StringBuffer
();
int
getAdServer
=
sdk
.
getServerAddress
(
"AD"
,
sbAdServer
);
if
(
0
==
getAdServer
)
{
adsdk
=
AdSDK
.
getInstance
();
boolean
adSDKInitRet
=
adsdk
.
init
(
sbAdServer
.
toString
(),
sbDeviceID
.
toString
(),
newTVAppkey
,
newTVChannelCode
,
null
,
context
.
getApplicationContext
());
if
(
adSDKInitRet
)
{
StringBuffer
sbAdData
=
new
StringBuffer
();
int
adSDKGetADRet
=
adsdk
.
getAD
(
"open"
,
null
,
null
,
null
,
null
,
null
,
sbAdData
);
if
(
0
==
adSDKGetADRet
)
{
String
adInfo
=
sbAdData
.
toString
();
// fl_ad = findViewById(R.id.fl_ad);
// adfl = new ADFrameLayout(this);
// fl_ad.addView(adfl);
// adfl.init(adsdk, adInfo);
// adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN);
// adfl = new ADFrameLayout(context);
// final WindowManager mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
// WindowManager.LayoutParams mParams = new WindowManager.LayoutParams();
// mWm.addView(adfl, mParams);
// ((AppActivity) context).addContentView(adfl, new WindowManager.LayoutParams(
// FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
// adfl.init(adsdk, adInfo);
// adfl.playPic(ADFrameLayout.AD_TYPE_APP_OPEN);
// }
// }
// }
// } else {
// Toast.makeText(context, "获取设备信息失败 " + retDeviceID, Toast.LENGTH_LONG).show();
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// ((AppActivity) context).finish();
// }
// }, 3000);
// }
// } else {
// Toast.makeText(context, "认证失败 " + retDeviceLogin, Toast.LENGTH_LONG).show();
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// ((AppActivity) context).finish();
// }
// }, 3000);
// }
// }
//}
//顶层窗口,覆盖Activity
adfl
=
new
ADFrameLayout
(
context
);
final
WindowManager
mWm
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
WindowManager
.
LayoutParams
mParams
=
new
WindowManager
.
LayoutParams
();
mWm
.
addView
(
adfl
,
mParams
);
adfl
.
init
(
adsdk
,
adInfo
);
adfl
.
playPic
(
ADFrameLayout
.
AD_TYPE_APP_OPEN
);
}
}
}
}
else
{
Toast
.
makeText
(
context
,
"获取设备信息失败 "
+
retDeviceID
,
Toast
.
LENGTH_LONG
).
show
();
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
((
AppActivity
)
context
).
finish
();
}
},
3000
);
}
}
else
{
Toast
.
makeText
(
context
,
"认证失败 "
+
retDeviceLogin
,
Toast
.
LENGTH_LONG
).
show
();
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
((
AppActivity
)
context
).
finish
();
}
},
3000
);
}
}
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/MelodyApplication.java
View file @
2da9e42
package
com
.
topdraw
.
melody
;
//import android.app.Application;
import
android.content.Context
;
import
android.os.Handler
;
import
android.util.Log
;
import
android.widget.Toast
;
import
com.topdraw.sdk.*
;
import
com.topdraw.sdk.ITopdrawSDK
;
import
com.topdraw.sdk.TopdrawApplication
;
import
com.topdraw.sdk.TopdrawSDK
;
import
org.cocos2dx.javascript.AppActivity
;
public
class
MelodyApplication
extends
TopdrawApplication
{
public
static
final
String
TAG
=
"MelodyApplication"
;
private
static
String
apiToken
=
"Nothing"
;
private
static
Context
context
;
public
static
final
String
ROOT_DIR
=
"/mnt/sdcard/fun"
;
public
static
ITopdrawSDK
topdrawSDK
;
public
static
AppActivity
appActivity
;
public
static
boolean
authResult
=
false
;
private
static
MelodyApplication
app
;
public
static
String
TOPDRAW_API_PATH
=
"http://demo.cloud.api.findfun.topdraw.cn:38081/findfun"
;
private
Handler
mHandler
=
new
Handler
();
public
static
boolean
isSDKInited
;
public
static
ITopdrawSDK
sdk
;
@Override
public
void
onCreate
()
{
super
.
onCreate
();
app
=
this
;
this
.
context
=
this
.
getApplicationContext
();
Log
.
d
(
TAG
,
"初始化SDK:currentThreadId"
+
Thread
.
currentThread
().
getId
());
TopdrawSDK
.
init
(
context
,
"td71b187fedb257ac0"
,
"432f53029ae58eef34ec9a6794975443"
,
initListener
);
PluginLoader
.
getInstance
().
init
(
getApplicationContext
(),
mHandler
,
TOPDRAW_API_PATH
,
"/plugin/plugin.json"
);
PluginLoader
.
getInstance
().
start
();
OBiPluginLoader
.
getInstance
().
init
(
getApplicationContext
());
//CrashHandler crashHandler = CrashHandler.getInstance();
//crashHandler.setCustomCrashHanler(getApplicationContext());
//MobclickAgent.UMAnalyticsConfig kk = new MobclickAgent.UMAnalyticsConfig(this,"5a168338a40fa377b500012b","amt");
//MobclickAgent.startWithConfigure(kk);
//ReStartExceptionHandler.getInstance().initReStartExceptionHandler(this);
}
/**
...
...
@@ -69,65 +43,8 @@ public class MelodyApplication extends TopdrawApplication {
return
app
;
}
public
static
String
getAPIToken
()
{
Log
.
d
(
TAG
,
"getAPIToken:["
+
apiToken
+
"]"
);
return
apiToken
;
}
public
static
String
getUserId
()
{
return
topdrawSDK
.
getUserID
();
}
public
static
Context
getAppContext
()
{
return
context
;
}
/**
* 初始化apk所使用的listener
*/
private
ITopdrawResultListener
initListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"TopdrawSDK inited:["
+
i
+
"]"
+
s
);
if
(
i
==
0
)
{
topdrawSDK
=
(
ITopdrawSDK
)
o
;
apiToken
=
topdrawSDK
.
getToken
();
Log
.
d
(
TAG
,
"API Token: "
+
apiToken
);
//topdrawSDK.auth(MelodyApplication.getAppContext(),apiToken,null,authListener);
}
else
{
apiToken
=
"Unreachable"
;
}
}
};
/**
* 认证所使用的Listener\
*/
private
ITopdrawResultListener
authListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"TopdrawSDK authed:["
+
i
+
"]"
+
s
);
if
(
i
==
10
)
{
Log
.
d
(
TAG
,
"auth success"
);
authResult
=
true
;
}
else
if
(
i
==
-
2010
)
{
authResult
=
false
;
System
.
out
.
println
(
"auth failed"
);
}
}
};
private
ITopdrawResultListener
orderListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"TopdrawSDK ordered:["
+
i
+
"]"
+
s
);
if
(
i
==
20
)
{
authResult
=
true
;
Log
.
d
(
TAG
,
"order success"
);
}
else
{
Log
.
d
(
TAG
,
"order failed"
);
}
}
};
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/TopdrawSDKWrapper.java
View file @
2da9e42
...
...
@@ -63,11 +63,11 @@ public class TopdrawSDKWrapper {
}
public
static
String
getAPIToken
()
{
return
MelodyApplication
.
getAPI
Token
();
return
MelodyApplication
.
sdk
.
get
Token
();
}
public
static
String
getUserId
()
{
return
MelodyApplication
.
getUserId
();
return
MelodyApplication
.
sdk
.
getUserID
();
}
/**
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
View file @
2da9e42
...
...
@@ -33,6 +33,9 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.IntentFilter
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.content.Intent
;
...
...
@@ -45,6 +48,8 @@ import android.view.KeyEvent;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.webkit.CookieManager
;
import
android.webkit.JavascriptInterface
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.widget.FrameLayout
;
...
...
@@ -52,12 +57,28 @@ import android.widget.ImageView;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.knowyou_jni.single.SDKUtil
;
import
com.topdraw.component.CocosMediaPlayer
;
import
com.topdraw.component.NewTVSDK
;
import
com.topdraw.forfun.R
;
import
com.topdraw.melody.CommonUtils
;
import
com.topdraw.melody.MelodyApplication
;
import
com.topdraw.melody.OBiPluginLoader
;
import
com.topdraw.melody.PluginLoader
;
import
com.topdraw.melody.TopdrawSDKWrapper
;
import
com.topdraw.sdk.ITopdrawResultListener
;
import
com.topdraw.sdk.ITopdrawSDK
;
import
com.topdraw.sdk.TopdrawSDK
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
tv.icntv.adsdk.AdSDK
;
import
tv.icntv.logsdk.logSDK
;
import
tv.icntv.ottlogin.loginSDK
;
public
class
AppActivity
extends
Cocos2dxActivity
{
private
static
String
TAG
=
"AppActivity"
;
...
...
@@ -71,13 +92,28 @@ public class AppActivity extends Cocos2dxActivity {
private
RelativeLayout
mRLSingleColor
;
private
RelativeLayout
mOBiLayout
;
public
static
boolean
baminSDKInited
=
false
;
public
static
String
APP_KEY
;
public
static
String
APP_NAME
;
public
static
String
APP_TYPE
;
public
static
String
USER_ID
;
private
static
String
TOPDRAW_PLATFORM
;
private
static
String
TOPDRAW_PLATFORM_SERVER
;
private
static
String
TOPDRAW_APPID
;
private
static
String
TOPDRAW_APPSECRET
;
public
static
String
TOPDRAW_API_PATH
=
"http://demo.cloud.api.findfun.topdraw.cn:38081/findfun"
;
private
final
Handler
mHandler
=
new
Handler
();
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Log
.
d
(
TAG
,
"判断APK是否安装。。。"
+
getExternalCacheDir
().
getPath
());
checkNetwork
();
//检查网络
initSdkData
();
//----解决游戏页按返回退出时,背景图透明度过高,onPause和onResume中控制显示还是隐藏
singleView
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
activity_main_single_color
,
null
);
mRLSingleColor
=
singleView
.
findViewById
(
R
.
id
.
ll_single
);
...
...
@@ -135,6 +171,33 @@ public class AppActivity extends Cocos2dxActivity {
SDKWrapper
.
getInstance
().
init
(
this
);
}
private
void
initSdkData
()
{
//init topdraw.jar-----
ApplicationInfo
appInfo
=
null
;
try
{
PackageManager
pm
=
getPackageManager
();
appInfo
=
pm
.
getApplicationInfo
(
getPackageName
(),
PackageManager
.
GET_META_DATA
);
}
catch
(
Exception
e
)
{
}
TOPDRAW_PLATFORM
=
appInfo
.
metaData
.
getString
(
"TOPDRAW.PLATFORM"
);
TOPDRAW_PLATFORM_SERVER
=
appInfo
.
metaData
.
getString
(
"TOPDRAW.PLATFORM_SERVER"
);
TOPDRAW_APPID
=
appInfo
.
metaData
.
getString
(
"TOPDRAW.APPID"
);
TOPDRAW_APPSECRET
=
appInfo
.
metaData
.
getString
(
"TOPDRAW.APPSECRET"
);
TopdrawSDK
.
init
(
getApplicationContext
(),
TOPDRAW_PLATFORM
,
TOPDRAW_PLATFORM_SERVER
,
TOPDRAW_APPID
,
TOPDRAW_APPSECRET
,
initListener
);
APP_KEY
=
appInfo
.
metaData
.
getString
(
"CMCC.APPKEY"
);
APP_NAME
=
getString
(
R
.
string
.
app_name
);
//init NewTV
NewTVSDK
.
getInstence
(
this
).
init
();
//注意防止loading图片覆盖掉开机广告 fix jerry
PluginLoader
.
getInstance
().
init
(
getApplicationContext
(),
mHandler
,
TOPDRAW_API_PATH
,
"/plugin/plugin.json"
);
PluginLoader
.
getInstance
().
start
();
OBiPluginLoader
.
getInstance
().
init
(
getApplicationContext
());
}
//修改回默认主题,防止部分挖洞窗口有阴影
@Override
public
void
setTheme
(
int
resid
)
{
...
...
@@ -311,4 +374,68 @@ public class AppActivity extends Cocos2dxActivity {
public
static
void
logInSceneE
(
String
strLog
)
{
Log
.
e
(
"logInSceneE"
,
strLog
);
}
private
ITopdrawResultListener
initListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
result
,
String
msg
,
Object
obj
)
{
// LOG(TAG, "onResult " + result + " " + msg + " " + obj);
if
(
0
==
result
)
{
MelodyApplication
.
sdk
=
(
ITopdrawSDK
)
obj
;
USER_ID
=
MelodyApplication
.
sdk
.
getOssUserID
();
MelodyApplication
.
isSDKInited
=
true
;
//局方埋点
try
{
SDKUtil
.
isOpenLog
=
true
;
int
sdkResult
=
SDKUtil
.
getInstance
().
ky_initWithAppKey
(
AppActivity
.
this
,
APP_KEY
,
getPackageManager
().
getPackageInfo
(
getPackageName
(),
0
).
versionName
);
baminSDKInited
=
(
sdkResult
==
0
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"appId"
,
TOPDRAW_APPID
);
params
.
put
(
"userId"
,
MelodyApplication
.
sdk
.
getUserID
());
MelodyApplication
.
sdk
.
auth
(
AppActivity
.
this
,
MelodyApplication
.
sdk
.
getToken
(),
params
,
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
if
(
10
==
i
)
{
NativeSystem
.
isAuthenticated
=
true
;
}
else
{
NativeSystem
.
isAuthenticated
=
false
;
}
if
(
baminSDKInited
)
{
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"APP_TYPE"
,
APP_TYPE
);
params
.
put
(
"USER_LOGIN"
,
"1"
);
params
.
put
(
"USER_ID"
,
USER_ID
);
params
.
put
(
"USER_ORDER"
,
NativeSystem
.
isAuthenticated
?
"已订购"
:
"未订购"
);
SDKUtil
.
getInstance
().
ky_trackCustom
(
params
);
SDKUtil
.
getInstance
().
ky_userSignIn
(
USER_ID
);
}
}
});
}
catch
(
Exception
e
)
{
}
}
else
if
(-
1020
==
result
)
{
Toast
.
makeText
(
AppActivity
.
this
,
"网络异常,请重试"
,
Toast
.
LENGTH_LONG
).
show
();
finish
();
}
else
{
Toast
.
makeText
(
AppActivity
.
this
,
"启动异常,请重试"
,
Toast
.
LENGTH_LONG
).
show
();
finish
();
}
}
};
private
static
class
NativeSystem
{
public
static
boolean
isAuthenticated
=
false
;
@JavascriptInterface
public
void
set
(
String
key
,
String
value
)
{
// LOG(TAG, "js call set() key=" + key + " value=" + value);
if
(
"isAuthenticated"
.
equals
(
key
)
&&
"true"
.
equals
(
value
))
{
isAuthenticated
=
true
;
}
}
}
}
...
...
Please
register
or
sign in
to post a comment