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
7606bd5a
...
7606bd5a3ea4837fc6fc5608d17656d56c48a554
authored
2020-03-17 16:23:28 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.解决下载游戏时返回,游戏依然在后台下载
1 parent
edac4bc5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
14 deletions
assets/Script/gameDetail.js
assets/Script/gameLoading.js
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/OBiPluginLoader.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/TopdrawSDKWrapper.java
assets/Script/gameDetail.js
View file @
7606bd5
...
...
@@ -353,9 +353,9 @@ cc.Class({
}
this
.
_aFocusTargets
[
0
][
'ButtonOpen'
]
=
cc
.
find
(
'ButtonOpen'
,
this
.
node
);
let
fiBanner
=
cc
.
find
(
'ButtonVip'
,
this
.
node
).
addComponent
(
FocusInfo
);
//
fiBanner
.
init
(
''
,
true
,
null
,
null
,
1.06
);
this
.
_aFocusTargets
[
0
][
'button_vip'
]
=
cc
.
find
(
'ButtonVip'
,
this
.
node
);
//
let fiBanner = cc.find('ButtonVip', this.node).addComponent(FocusInfo); //
//
fiBanner.init('', true, null, null, 1.06);
//
this._aFocusTargets[0]['button_vip'] = cc.find('ButtonVip', this.node);
var
nodeInitFocus
=
cc
.
find
(
'ButtonOpen'
,
this
.
node
);
//强制写死,不然会闪屏,找不到ButtonOpen
// cc.log("初始化 " + nodeInitFocus.name);
...
...
assets/Script/gameLoading.js
View file @
7606bd5
...
...
@@ -100,6 +100,9 @@ cc.Class({
case
cc
.
macro
.
KEY
.
backspace
:
case
Common
.
ANDROID_KEY
.
back
:
this
.
_bIsFocusInit
=
true
;
if
(
this
.
_oSceneContext
.
_downloadUrl
&&
this
.
_oSceneContext
.
_downloadUrl
!=
"undefined"
)
{
//如果有下载地址就启动奥比游戏
jsb
.
reflection
.
callStaticMethod
(
"com/topdraw/melody/TopdrawSDKWrapper"
,
"closeDownloadObiApk"
,
"()V"
);
}
this
.
backAScene
();
break
;
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/OBiPluginLoader.java
View file @
7606bd5
...
...
@@ -37,6 +37,11 @@ public class OBiPluginLoader {
public
static
final
int
PROGRESS_0_01
=
1
;
public
static
double
PROGRESS
=
PROGRESS_1
;
private
String
sdPath
=
Environment
.
getExternalStorageDirectory
()
+
"/"
;
private
HttpURLConnection
conn
;
private
BufferedInputStream
bis
=
null
;
private
FileOutputStream
fos
=
null
;
private
File
fTemp
;
private
File
dirPackage
;
public
static
OBiPluginLoader
getInstance
()
{
if
(
null
==
instance
)
{
...
...
@@ -83,10 +88,7 @@ public class OBiPluginLoader {
public
void
start
(
String
downloadUrl
,
String
packageName
,
final
OnResultListener
rListener
,
final
OnProgressListener
pListener
)
{
this
.
path
=
downloadUrl
;
final
File
dirPackage
=
new
File
(
sdPath
+
packageName
);
if
(!
dirPackage
.
exists
())
{
dirPackage
.
mkdir
();
Log
.
d
(
"OBiPluginLoader"
,
"创建目录"
+
dirPackage
);
dirPackage
=
new
File
(
sdPath
+
packageName
);
final
OnProgressListener
pl
=
new
OnProgressListener
()
{
@Override
public
void
onProgress
(
double
d
)
{
...
...
@@ -95,7 +97,6 @@ public class OBiPluginLoader {
}
}
};
String
fileName
=
null
;
if
(
null
!=
this
.
path
)
{
if
(
this
.
path
.
contains
(
"?"
))
{
...
...
@@ -107,6 +108,9 @@ public class OBiPluginLoader {
fileName
=
this
.
path
.
substring
(
this
.
path
.
lastIndexOf
(
"/"
)
+
1
);
}
}
if
(!
dirPackage
.
exists
())
{
dirPackage
.
mkdir
();
Log
.
d
(
"OBiPluginLoader"
,
"创建目录"
+
dirPackage
);
final
File
fileTempOK
=
new
File
(
dirPackage
,
fileName
);
final
OnResultListener
rl
=
new
OnResultListener
()
{
@Override
...
...
@@ -152,6 +156,27 @@ public class OBiPluginLoader {
if
(
null
!=
rListener
)
{
rListener
.
onResult
(
0
,
path
);
}
}
else
{
//这里再去下载,jerry -0317
final
File
fileTempOK
=
new
File
(
dirPackage
,
fileName
);
final
OnResultListener
rl
=
new
OnResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
msg
)
{
if
(
0
==
i
)
{
boolean
checkSuccess
=
false
;
if
(
fileTempOK
.
exists
()
&&
fileTempOK
.
isFile
())
{
if
(
null
!=
rListener
)
{
rListener
.
onResult
(
0
,
fileTempOK
.
getAbsolutePath
());
}
}
}
}
};
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
downloadApk
(
""
,
fileTempOK
,
rl
,
pl
);
}
}).
start
();
}
}
}
...
...
@@ -159,8 +184,6 @@ public class OBiPluginLoader {
public
void
downloadApk
(
String
downloadURL
,
final
File
file
,
OnResultListener
rlistener
,
OnProgressListener
plistener
)
{
Log
.
d
(
"OBiPluginLoader"
,
"downloadApk start.."
);
downloadURL
=
this
.
path
;
BufferedInputStream
bis
=
null
;
FileOutputStream
fos
=
null
;
try
{
if
(
file
.
exists
()
&&
file
.
isFile
())
{
file
.
delete
();
...
...
@@ -169,7 +192,7 @@ public class OBiPluginLoader {
if
(!
parentFile
.
exists
())
{
parentFile
.
mkdir
();
}
File
f
=
new
File
(
file
.
getAbsolutePath
()
+
"_temp"
);
fTemp
=
new
File
(
file
.
getAbsolutePath
()
+
"_temp"
);
String
url
=
null
;
if
(
downloadURL
.
startsWith
(
"http"
))
{
url
=
downloadURL
;
...
...
@@ -178,7 +201,7 @@ public class OBiPluginLoader {
}
URL
u
=
new
URL
(
url
);
Log
.
d
(
"OBiPluginLoader"
,
"downloadAPK url: "
+
url
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
u
.
openConnection
();
conn
=
(
HttpURLConnection
)
u
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
conn
.
setConnectTimeout
(
5000
);
conn
.
setReadTimeout
(
5000
);
...
...
@@ -199,7 +222,7 @@ public class OBiPluginLoader {
long
tempReadSize
=
0
;
long
progressSize
=
0
;
bis
=
new
BufferedInputStream
(
conn
.
getInputStream
());
fos
=
new
FileOutputStream
(
f
);
fos
=
new
FileOutputStream
(
f
Temp
);
byte
[]
buffer
=
new
byte
[
1024
];
int
len
=
0
;
while
((
len
=
bis
.
read
(
buffer
))
!=
-
1
)
{
...
...
@@ -228,7 +251,7 @@ public class OBiPluginLoader {
}
fos
.
write
(
buffer
,
0
,
len
);
}
boolean
flag
=
f
.
renameTo
(
file
);
boolean
flag
=
f
Temp
.
renameTo
(
file
);
String
[]
command
=
{
"chmod"
,
"777"
,
file
.
getPath
()};
ProcessBuilder
builder
=
new
ProcessBuilder
(
command
);
try
{
...
...
@@ -272,6 +295,34 @@ public class OBiPluginLoader {
}
}
public
void
closeDownloadApk
()
{
Log
.
d
(
"OBiPluginLoader"
,
"目录是否存在:"
+
dirPackage
.
exists
());
if
(
fTemp
.
exists
()
&&
fTemp
.
isFile
())
{
fTemp
.
delete
();
}
if
(
null
!=
conn
)
{
try
{
conn
.
disconnect
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
if
(
null
!=
bis
)
{
try
{
bis
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
null
!=
fos
)
{
try
{
fos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
public
interface
OnResultListener
{
public
void
onResult
(
int
i
,
String
msg
);
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/topdraw/melody/TopdrawSDKWrapper.java
View file @
7606bd5
...
...
@@ -321,6 +321,11 @@ public class TopdrawSDKWrapper {
});
}
public
static
void
closeDownloadObiApk
()
{
Log
.
d
(
TAG
,
"取消下载。。。"
);
OBiPluginLoader
.
getInstance
().
closeDownloadApk
();
}
public
static
boolean
isApkInstalled
(
Context
context
,
String
packageName
)
{
// List<PackageInfo> packageInfoList = context.getPackageManager().getInstalledPackages(0);
// for (int i = 0; i < packageInfoList.size(); i++) {
...
...
Please
register
or
sign in
to post a comment