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
676bd9de
...
676bd9deae86b973a16978ab58cd3d8c9f336ac7
authored
2020-04-16 17:22:11 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
埋点SDK新增游戏开始和结束事件
1 parent
29791e8e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
169 additions
and
99 deletions
assets/Script/common/Application.js
assets/Script/common/TVCanvas.js
assets/Script/gameDetail.js
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/src/org/cocos2dx/javascript/common/CommonUtils.java
assets/Script/common/Application.js
View file @
676bd9d
...
...
@@ -240,16 +240,18 @@ cc.Class({
obj
[
oLinkPoint
.
type
+
"Id"
]
=
oLinkPoint
.
id
;
obj
[
oLinkPoint
.
type
+
"Code"
]
=
oLinkPoint
.
code
;
break
;
case
"play
OBiGame"
:
//页面报错了
case
"play
Game"
:
//
obj
=
{
"ui"
:
this
.
oSceneUIMap
[
_this
.
_strSceneName
]
||
_this
.
_strSceneName
,
"context"
:
_this
.
_oScene
.
_oSceneContext
,
"parameters"
:
_this
.
getTopSceneParameter
(),
}
break
;
case
"
playGame"
:
//页面报错了
case
"
endGame"
:
//
obj
=
{
"ui"
:
this
.
oSceneUIMap
[
_this
.
_strSceneName
]
||
_this
.
_strSceneName
,
"context"
:
_this
.
_oScene
.
_oSceneContext
,
"parameters"
:
_this
.
getTopSceneParameter
(),
}
break
;
case
"error"
:
//页面报错了
...
...
assets/Script/common/TVCanvas.js
View file @
676bd9d
...
...
@@ -1599,6 +1599,13 @@ cc.Topdraw.TVCanvas =
}
},
4
);
},
//Java调用结束游戏
endGame
:
function
()
{
this
.
_cLog
.
screenI
(
"gameDetail.js->endGame 发送探针==>"
);
this
.
_oProbe
.
requestProbe
(
"endGame"
);
},
update
:
function
(
dt
)
{
try
{
this
.
updateTimer
+=
dt
;
...
...
assets/Script/gameDetail.js
View file @
676bd9d
...
...
@@ -496,17 +496,23 @@ cc.Class({
if
(
!
this
.
_bInitExistApk
)
{
//还未拿到判断数据
return
;
}
//福建埋点SDK发送
jsb
.
reflection
.
callStaticMethod
(
"org/cocos2dx/javascript/AppActivity"
,
"onKYSendData"
,
"(Ljava/lang/String;)V"
,
cc
.
find
(
"Desc/Title"
,
this
.
node
).
getComponent
(
cc
.
Label
).
string
);
this
.
_oProbe
.
requestProbe
(
"playGame"
);
if
(
this
.
_bIsExistApk
==
"true"
)
{
if
(
this
.
_oSceneContext
.
_downloadUrl
&&
this
.
_oSceneContext
.
_downloadUrl
!=
"undefined"
)
{
//如果有下载地址就启动奥比游戏
this
.
_oProbe
.
requestProbe
(
"playOBiGame"
);
jsb
.
reflection
.
callStaticMethod
(
"org/cocos2dx/javascript/common/TopdrawSDKWrapper"
,
"startOBiGame"
,
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"
,
Common
.
TOPDRAW_API_SERVER
+
this
.
_oSceneContext
.
_downloadUrl
,
this
.
_oSceneContext
.
_packageName
,
this
.
_oSceneContext
.
_className
,
""
);
jsb
.
reflection
.
callStaticMethod
(
"org/cocos2dx/javascript/common/TopdrawSDKWrapper"
,
"startOBiGame"
,
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"
,
Common
.
TOPDRAW_API_SERVER
+
this
.
_oSceneContext
.
_downloadUrl
,
this
.
_oSceneContext
.
_packageName
,
this
.
_oSceneContext
.
_className
,
""
);
}
else
{
//这里应该转圈圈等待加载游戏
// cc.find("LoadingLabel", this.node).opacity = 255;
// cc.find("Loading/LoadingIcon", this.node).opacity = 255;
// cc.find("Loading/LoadingIcon", this.node).getComponent(cc.Animation).play();
this
.
_oProbe
.
requestProbe
(
"playGame"
);
jsb
.
reflection
.
callStaticMethod
(
"org/cocos2dx/javascript/common/TopdrawSDKWrapper"
,
"startGame"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
,
this
.
_oSceneContext
.
_packageName
,
""
);
jsb
.
reflection
.
callStaticMethod
(
"org/cocos2dx/javascript/common/TopdrawSDKWrapper"
,
"startGame"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
,
this
.
_oSceneContext
.
_packageName
,
""
);
}
}
else
{
this
.
doCurrentFocusTVLinkAction
(
Common
.
TV_LINK_ACTION_CLICK
);
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
View file @
676bd9d
...
...
@@ -67,11 +67,14 @@ import org.cocos2dx.javascript.component.CocosMediaPlayer;
import
org.cocos2dx.javascript.common.CommonUtils
;
import
org.cocos2dx.javascript.common.MelodyApplication
;
import
org.cocos2dx.javascript.common.TopdrawSDKWrapper
;
import
org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge
;
public
class
AppActivity
extends
Cocos2dxActivity
{
private
static
String
TAG
=
"AppActivity"
;
private
static
ImageView
img
=
null
;
protected
static
Handler
mUIHandler
;
private
static
boolean
gameStart
=
false
;
private
static
String
mGameName
=
null
;
private
BroadcastReceiver
receiver
=
null
;
private
View
view
;
private
View
singleView
;
...
...
@@ -100,7 +103,7 @@ public class AppActivity extends Cocos2dxActivity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
checkNetwork
(
);
//检查网络
CommonUtils
.
checkNetwork
(
this
);
//检查网络
initSdkData
();
...
...
@@ -212,70 +215,6 @@ public class AppActivity extends Cocos2dxActivity {
}
@Override
protected
void
onResume
()
{
Log
.
d
(
"AppActivity"
,
"onResume()...."
);
super
.
onResume
();
SDKWrapper
.
getInstance
().
onResume
();
mRLSingleColor
.
setVisibility
(
View
.
GONE
);
mOBiLayout
.
setVisibility
(
View
.
GONE
);
relativeLayout
.
setVisibility
(
View
.
GONE
);
}
@Override
protected
void
onPause
()
{
Log
.
d
(
"AppActivity"
,
"onPause()...."
);
// mRLSingleColor.setVisibility(View.VISIBLE); //放到启动游戏时显示
// setTheme(android.R.style.Theme_NoDisplay);
super
.
onPause
();
SDKWrapper
.
getInstance
().
onPause
();
}
@Override
protected
void
onStop
()
{
Log
.
d
(
"AppActivity"
,
"onStop()...."
);
super
.
onStop
();
SDKWrapper
.
getInstance
().
onStop
();
}
@Override
protected
void
onDestroy
()
{
Log
.
d
(
"AppActivity"
,
"onDestroy()...."
);
unregisterReceiver
(
receiver
);
super
.
onDestroy
();
SDKWrapper
.
getInstance
().
onDestroy
();
}
public
static
void
onExitApp
()
{
Log
.
d
(
TAG
,
"onExitApp..."
);
//未来SDK退出
NativeLogReporterNewTV
nlp
=
NativeLogReporterNewTV
.
getInstance
(
getContext
(),
null
);
nlp
.
report
(
88
,
"1"
);
if
(
baminSDKInited
)
{
//埋点SDK退出--
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"APP_TYPE"
,
APP_TYPE
);
params
.
put
(
"USER_LOGIN"
,
"0"
);
params
.
put
(
"USER_ID"
,
USER_ID
);
params
.
put
(
"USER_ORDER"
,
NativeSystem
.
isAuthenticated
?
"已订购"
:
"未订购"
);
SDKUtil
.
getInstance
().
ky_trackCustom
(
params
);
SDKUtil
.
getInstance
().
ky_userSignOut
(
USER_ID
);
}
TopdrawSDK
.
destory
(
getContext
(),
null
,
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"destory "
+
i
+
" "
+
s
);
try
{
if
(
baminSDKInited
)
{
SDKUtil
.
getInstance
().
ky_quit
();
//这里考虑延迟几秒销毁,否则无法触发
}
System
.
exit
(
0
);
}
catch
(
Throwable
t
)
{
}
}
});
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
SDKWrapper
.
getInstance
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
...
...
@@ -346,34 +285,6 @@ public class AppActivity extends Cocos2dxActivity {
});
}
//检查网络
private
void
checkNetwork
()
{
Log
.
d
(
TAG
,
"网络链接:"
+
CommonUtils
.
isNetworkAvalible
(
AppActivity
.
this
));
if
(!
CommonUtils
.
isNetworkAvalible
(
AppActivity
.
this
))
{
TextView
msg
=
new
TextView
(
AppActivity
.
this
);
msg
.
setText
(
" 当前未连接网络,请设置网络后登陆!"
);
new
AlertDialog
.
Builder
(
AppActivity
.
this
)
.
setIcon
(
R
.
mipmap
.
ic_launcher
)
.
setTitle
(
"网络状态提示"
)
.
setView
(
msg
)
.
setPositiveButton
(
"确定"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
startActivity
(
new
Intent
(
Settings
.
ACTION_WIRELESS_SETTINGS
));
try
{
new
Thread
().
sleep
(
2000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
AppActivity
.
this
.
finish
();
System
.
exit
(
0
);
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
}
}).
create
().
show
();
}
}
public
View
getProgressBarView
()
{
return
view
;
}
...
...
@@ -482,4 +393,110 @@ public class AppActivity extends Cocos2dxActivity {
}
}
}
@Override
protected
void
onPause
()
{
Log
.
d
(
"AppActivity"
,
"onPause()...."
);
// mRLSingleColor.setVisibility(View.VISIBLE); //放到启动游戏时显示
// setTheme(android.R.style.Theme_NoDisplay);
super
.
onPause
();
SDKWrapper
.
getInstance
().
onPause
();
}
@Override
protected
void
onStop
()
{
Log
.
d
(
"AppActivity"
,
"onStop()...."
);
super
.
onStop
();
SDKWrapper
.
getInstance
().
onStop
();
}
@Override
protected
void
onDestroy
()
{
Log
.
d
(
"AppActivity"
,
"onDestroy()...."
);
unregisterReceiver
(
receiver
);
super
.
onDestroy
();
SDKWrapper
.
getInstance
().
onDestroy
();
}
@Override
protected
void
onResume
()
{
Log
.
d
(
"AppActivity"
,
"onResume()...."
);
super
.
onResume
();
SDKWrapper
.
getInstance
().
onResume
();
mRLSingleColor
.
setVisibility
(
View
.
GONE
);
mOBiLayout
.
setVisibility
(
View
.
GONE
);
relativeLayout
.
setVisibility
(
View
.
GONE
);
//退出游戏发送探针
if
(
gameStart
&&
mGameName
!=
null
)
{
Log
.
d
(
TAG
,
"onResume->退出游戏| "
+
mGameName
);
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"GAME_ID"
,
""
);
//game_id暂时没有值
params
.
put
(
"GAME_NAME"
,
mGameName
);
SDKUtil
.
getInstance
().
ky_playEnd
(
params
);
//js探针发送
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Log
.
d
(
TAG
,
"onResume->发送探针"
);
runOnGLThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Cocos2dxJavascriptJavaBridge
.
evalString
(
"cc.find('Canvas',cc.director.getScene()).getComponent(cc.Topdraw.TVCanvas).endGame();"
);
}
});
}
});
}
}
/**
* 福建移动埋点SDK、启动游戏
*
* @param gameName
*/
public
static
void
onKYSendData
(
String
gameName
)
{
Log
.
d
(
TAG
,
"onStartGame->启动游戏| "
+
gameName
);
gameStart
=
true
;
mGameName
=
gameName
;
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"GAME_ID"
,
""
);
//game_id暂时没有值
params
.
put
(
"GAME_NAME"
,
gameName
);
SDKUtil
.
getInstance
().
ky_playStart
(
params
);
}
public
static
void
onExitApp
()
{
Log
.
d
(
TAG
,
"onExitApp..."
);
//未来SDK退出
NativeLogReporterNewTV
nlp
=
NativeLogReporterNewTV
.
getInstance
(
getContext
(),
null
);
nlp
.
report
(
88
,
"1"
);
if
(
baminSDKInited
)
{
//埋点SDK退出--
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"APP_TYPE"
,
APP_TYPE
);
params
.
put
(
"USER_LOGIN"
,
"0"
);
params
.
put
(
"USER_ID"
,
USER_ID
);
params
.
put
(
"USER_ORDER"
,
NativeSystem
.
isAuthenticated
?
"已订购"
:
"未订购"
);
SDKUtil
.
getInstance
().
ky_trackCustom
(
params
);
SDKUtil
.
getInstance
().
ky_userSignOut
(
USER_ID
);
}
TopdrawSDK
.
destory
(
getContext
(),
null
,
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"destory "
+
i
+
" "
+
s
);
try
{
if
(
baminSDKInited
)
{
SDKUtil
.
getInstance
().
ky_quit
();
//这里考虑延迟几秒销毁,否则无法触发
}
System
.
exit
(
0
);
}
catch
(
Throwable
t
)
{
}
}
});
}
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/CommonUtils.java
View file @
676bd9d
package
org
.
cocos2dx
.
javascript
.
common
;
import
android.app.AlertDialog
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.net.Uri
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.widget.TextView
;
import
com.topdraw.forfun_FJYD.R
;
import
org.cocos2dx.javascript.AppActivity
;
import
java.io.File
;
...
...
@@ -122,4 +131,33 @@ public class CommonUtils {
return
value
;
}
//检查网络
public
static
void
checkNetwork
(
final
Context
context
)
{
Log
.
d
(
TAG
,
"网络链接:"
+
CommonUtils
.
isNetworkAvalible
(
context
));
if
(!
CommonUtils
.
isNetworkAvalible
(
context
))
{
TextView
msg
=
new
TextView
(
context
);
msg
.
setText
(
" 当前未连接网络,请设置网络后登陆!"
);
new
AlertDialog
.
Builder
(
context
)
.
setIcon
(
R
.
mipmap
.
ic_launcher
)
.
setTitle
(
"网络状态提示"
)
.
setView
(
msg
)
.
setPositiveButton
(
"确定"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
context
.
startActivity
(
new
Intent
(
Settings
.
ACTION_WIRELESS_SETTINGS
));
try
{
new
Thread
().
sleep
(
2000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
((
AppActivity
)
context
).
finish
();
System
.
exit
(
0
);
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
}
}).
create
().
show
();
}
}
}
...
...
Please
register
or
sign in
to post a comment