Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
machine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
android
machine
Commits
14c8c12e
Commit
14c8c12e
authored
Oct 22, 2022
by
wjg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v2
parent
00b09a2b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
178 additions
and
71 deletions
+178
-71
app/build.gradle
+2
-2
app/src/main/java/com/ihaoin/hooloo/device/data/vo/CheckUpdateVo.java
+24
-15
app/src/main/java/com/ihaoin/hooloo/device/data/vo/UpdateDataVo.java
+33
-0
app/src/main/java/com/ihaoin/hooloo/device/home/view/LauncherActivity.java
+2
-2
app/src/main/java/com/ihaoin/hooloo/device/interaction/view/FrameView.java
+2
-2
app/src/main/java/com/ihaoin/hooloo/device/network/HttpUtil.java
+6
-3
app/src/main/java/com/ihaoin/hooloo/device/update/UpdateService.java
+56
-39
app/src/main/java/com/ihaoin/hooloo/device/update/UpdateSocket.java
+37
-6
app/src/main/java/com/ihaoin/hooloo/device/util/Utils.java
+14
-0
app/src/main/res/values-w800dp/dimens.xml
+1
-1
app/src/main/res/values/dimens.xml
+1
-1
No files found.
app/build.gradle
View file @
14c8c12e
...
@@ -10,8 +10,8 @@ android {
...
@@ -10,8 +10,8 @@ android {
applicationId
"com.ihaoin.hooloo.device"
applicationId
"com.ihaoin.hooloo.device"
minSdkVersion
26
minSdkVersion
26
targetSdkVersion
30
targetSdkVersion
30
versionCode
10
versionCode
5
versionName
"1.0.
10
"
versionName
"1.0.
5
"
ndk
{
ndk
{
//选择要添加的对应 cpu 类型的 .so 库。
//选择要添加的对应 cpu 类型的 .so 库。
...
...
app/src/main/java/com/ihaoin/hooloo/device/data/vo/CheckUpdateVo.java
View file @
14c8c12e
...
@@ -3,31 +3,40 @@ package com.ihaoin.hooloo.device.data.vo;
...
@@ -3,31 +3,40 @@ package com.ihaoin.hooloo.device.data.vo;
import
java.io.Serializable
;
import
java.io.Serializable
;
public
class
CheckUpdateVo
implements
Serializable
{
public
class
CheckUpdateVo
implements
Serializable
{
private
String
url
;
private
String
requestId
;
private
Integer
versionCode
;
private
Integer
code
;
private
String
version
;
private
String
message
;
private
UpdateDataVo
data
;
public
String
get
Url
()
{
public
String
get
RequestId
()
{
return
url
;
return
requestId
;
}
}
public
void
set
Url
(
String
url
)
{
public
void
set
RequestId
(
String
requestId
)
{
this
.
url
=
url
;
this
.
requestId
=
requestId
;
}
}
public
Integer
get
Version
Code
()
{
public
Integer
getCode
()
{
return
versionC
ode
;
return
c
ode
;
}
}
public
void
set
VersionCode
(
Integer
versionC
ode
)
{
public
void
set
Code
(
Integer
c
ode
)
{
this
.
versionCode
=
versionC
ode
;
this
.
code
=
c
ode
;
}
}
public
String
get
Version
()
{
public
String
get
Message
()
{
return
version
;
return
message
;
}
}
public
void
setVersion
(
String
version
)
{
public
void
setMessage
(
String
message
)
{
this
.
version
=
version
;
this
.
message
=
message
;
}
public
UpdateDataVo
getData
()
{
return
data
;
}
public
void
setData
(
UpdateDataVo
data
)
{
this
.
data
=
data
;
}
}
}
}
app/src/main/java/com/ihaoin/hooloo/device/data/vo/UpdateDataVo.java
0 → 100644
View file @
14c8c12e
package
com
.
ihaoin
.
hooloo
.
device
.
data
.
vo
;
import
java.io.Serializable
;
public
class
UpdateDataVo
implements
Serializable
{
private
String
url
;
private
Integer
versionCode
;
private
String
version
;
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
Integer
getVersionCode
()
{
return
versionCode
;
}
public
void
setVersionCode
(
Integer
versionCode
)
{
this
.
versionCode
=
versionCode
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
}
app/src/main/java/com/ihaoin/hooloo/device/home/view/LauncherActivity.java
View file @
14c8c12e
...
@@ -127,8 +127,8 @@ public class LauncherActivity extends Activity {
...
@@ -127,8 +127,8 @@ public class LauncherActivity extends Activity {
startMachineClient
();
startMachineClient
();
startTimeoutThread
();
startTimeoutThread
();
getMachineCode
();
getMachineCode
();
//
startUpdateSocket();
startUpdateSocket
();
// new UpdateService().start();
// new UpdateService(
this
).start();
View
.
OnClickListener
l
=
v
->
{
View
.
OnClickListener
l
=
v
->
{
InteractionMsg
msg
=
new
InteractionMsg
();
InteractionMsg
msg
=
new
InteractionMsg
();
...
...
app/src/main/java/com/ihaoin/hooloo/device/interaction/view/FrameView.java
View file @
14c8c12e
...
@@ -135,13 +135,13 @@ public class FrameView extends SurfaceView implements SurfaceHolder.Callback {
...
@@ -135,13 +135,13 @@ public class FrameView extends SurfaceView implements SurfaceHolder.Callback {
if
(
mod
==
frameCount
-
1
)
{
// 每次播放的最后一帧
if
(
mod
==
frameCount
-
1
)
{
// 每次播放的最后一帧
repeatCount
++;
repeatCount
++;
Utils
.
i
(
"play last, onAnimationRepeat "
+
(
animatorListener
!=
null
));
//
Utils.i("play last, onAnimationRepeat " + (animatorListener != null));
if
(
animatorListener
!=
null
)
{
if
(
animatorListener
!=
null
)
{
animatorListener
.
onAnimationRepeat
(
null
);
animatorListener
.
onAnimationRepeat
(
null
);
}
}
}
}
}
}
Utils
.
i
(
"play end, onAnimationEnd "
+
(
animatorListener
!=
null
));
//
Utils.i("play end, onAnimationEnd " + (animatorListener != null));
if
(
animatorListener
!=
null
)
{
if
(
animatorListener
!=
null
)
{
animatorListener
.
onAnimationEnd
(
null
);
animatorListener
.
onAnimationEnd
(
null
);
}
}
...
...
app/src/main/java/com/ihaoin/hooloo/device/network/HttpUtil.java
View file @
14c8c12e
...
@@ -6,9 +6,9 @@ import android.os.Handler;
...
@@ -6,9 +6,9 @@ import android.os.Handler;
import
android.os.Message
;
import
android.os.Message
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.ihaoin.hooloo.device.base.BizException
;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.base.AppConfig
;
import
com.ihaoin.hooloo.device.base.AppConfig
;
import
com.ihaoin.hooloo.device.base.BizException
;
import
com.ihaoin.hooloo.device.data.po.CheckUpdate
;
import
com.ihaoin.hooloo.device.data.po.CheckUpdate
;
import
com.ihaoin.hooloo.device.util.JsonUtils
;
import
com.ihaoin.hooloo.device.util.JsonUtils
;
import
com.ihaoin.hooloo.device.util.SharedPreferencesUtils
;
import
com.ihaoin.hooloo.device.util.SharedPreferencesUtils
;
...
@@ -17,6 +17,7 @@ import com.ihaoin.hooloo.device.util.Utils;
...
@@ -17,6 +17,7 @@ import com.ihaoin.hooloo.device.util.Utils;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
okhttp3.Call
;
import
okhttp3.Call
;
...
@@ -202,9 +203,11 @@ public class HttpUtil {
...
@@ -202,9 +203,11 @@ public class HttpUtil {
checkUpdate
.
setVersionCode
(
packageInfo
.
versionCode
);
checkUpdate
.
setVersionCode
(
packageInfo
.
versionCode
);
checkUpdate
.
setVersionName
(
packageInfo
.
versionName
);
checkUpdate
.
setVersionName
(
packageInfo
.
versionName
);
checkUpdate
.
setType
(
String
.
valueOf
(
SharedPreferencesUtils
.
getScreenNo
(
HLApplication
.
SELF
)));
checkUpdate
.
setType
(
String
.
valueOf
(
SharedPreferencesUtils
.
getScreenNo
(
HLApplication
.
SELF
)));
String
content
=
JsonUtils
.
toString
(
checkUpdate
).
replaceAll
(
"\""
,
"'"
);
String
content
=
JsonUtils
.
toString
(
checkUpdate
);
String
params
=
String
.
format
(
"{\"params\": \"%s\"}"
,
content
);
HashMap
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"params"
,
content
);
String
params
=
JsonUtils
.
toString
(
map
);
post
(
HttpParams
.
POST_CHECK_UPDATE
,
params
,
handler
);
post
(
HttpParams
.
POST_CHECK_UPDATE
,
params
,
handler
);
}
}
...
...
app/src/main/java/com/ihaoin/hooloo/device/update/UpdateService.java
View file @
14c8c12e
package
com
.
ihaoin
.
hooloo
.
device
.
update
;
package
com
.
ihaoin
.
hooloo
.
device
.
update
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.
content.Context
;
import
android.
app.Activity
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageInfo
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.Message
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.HLApplication
;
import
com.ihaoin.hooloo.device.base.AppConfig
;
import
com.ihaoin.hooloo.device.base.AppConfig
;
import
com.ihaoin.hooloo.device.data.vo.
CheckUpdate
Vo
;
import
com.ihaoin.hooloo.device.data.vo.
UpdateData
Vo
;
import
com.ihaoin.hooloo.device.network.HttpUtil
;
import
com.ihaoin.hooloo.device.network.HttpUtil
;
import
com.ihaoin.hooloo.device.network.NetworkHandler
;
import
com.ihaoin.hooloo.device.network.NetworkHandler
;
import
com.ihaoin.hooloo.device.util.ApkUtils
;
import
com.ihaoin.hooloo.device.util.ApkUtils
;
...
@@ -23,34 +24,15 @@ import java.io.File;
...
@@ -23,34 +24,15 @@ import java.io.File;
@SuppressLint
(
"HandlerLeak"
)
@SuppressLint
(
"HandlerLeak"
)
public
class
UpdateService
extends
Thread
{
public
class
UpdateService
extends
Thread
{
private
Context
mContext
;
private
Activity
mContext
;
public
UpdateService
(
Context
context
)
{
public
UpdateService
(
Activity
context
)
{
this
.
mContext
=
context
;
this
.
mContext
=
context
;
}
}
// @Nullable
// @Override
// public IBinder onBind(Intent intent) {
// checkUpdate();
// return null;
// }
@Override
@Override
public
void
run
()
{
public
void
run
()
{
HttpUtil
.
checkUpdate
(
checkUpdateHandler
);
HttpUtil
.
checkUpdate
(
checkUpdateHandler
);
// while (true) {
// try {
// if (System.currentTimeMillis() / 1000 % 60 == 0) {
// Utils.i("check");
// }
// checkUpdate();
// Thread.sleep(1000);
// } catch (Exception e) {
// e.printStackTrace();
// Utils.i("check update error");
// }
// }
}
}
private
CheckUpdateHandler
checkUpdateHandler
=
new
CheckUpdateHandler
();
private
CheckUpdateHandler
checkUpdateHandler
=
new
CheckUpdateHandler
();
...
@@ -65,46 +47,74 @@ public class UpdateService extends Thread {
...
@@ -65,46 +47,74 @@ public class UpdateService extends Thread {
// updateVo.setVersionCode(10);
// updateVo.setVersionCode(10);
Object
obj
=
msg
.
obj
;
Object
obj
=
msg
.
obj
;
if
(
msg
.
what
==
0
||
obj
==
null
)
{
if
(
msg
.
what
==
0
||
obj
==
null
)
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"检查更新返回¬失败"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"检查更新返回失败"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"检查更新返回失败"
,
Toast
.
LENGTH_LONG
);
}
return
;
}
UpdateDataVo
dataVo
=
JsonUtils
.
readValue
(
obj
,
UpdateDataVo
.
class
);
if
(
dataVo
==
null
)
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"检查更新返回为空"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"检查更新返回为空"
,
Toast
.
LENGTH_LONG
);
}
return
;
return
;
}
}
CheckUpdateVo
updateVo
=
JsonUtils
.
readValue
(
obj
,
CheckUpdateVo
.
class
);
if
(
dataVo
.
getVersionCode
()
==
null
||
dataVo
.
getVersionCode
()
<=
0
)
{
if
(
updateVo
.
getVersionCode
()
==
null
||
updateVo
.
getVersionCode
()
<=
0
)
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"version code为空"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"version code 为空"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"version code为空"
,
Toast
.
LENGTH_LONG
);
}
return
;
return
;
}
}
if
(
StringUtils
.
isEmpty
(
updateVo
.
getUrl
()))
{
if
(
StringUtils
.
isEmpty
(
dataVo
.
getUrl
()))
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"url 为空"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"url为空"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"url为空"
,
Toast
.
LENGTH_LONG
);
}
return
;
return
;
}
}
if
(
StringUtils
.
isEmpty
(
updateVo
.
getVersion
()))
{
if
(
StringUtils
.
isEmpty
(
dataVo
.
getVersion
()))
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"version 为空"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"version为空"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"version为空"
,
Toast
.
LENGTH_LONG
);
}
return
;
return
;
}
}
PackageInfo
packageInfo
=
Utils
.
getPackageInfo
();
PackageInfo
packageInfo
=
Utils
.
getPackageInfo
();
if
(
updateVo
.
getVersionCode
()
<=
packageInfo
.
versionCode
)
{
if
(
dataVo
.
getVersionCode
()
<=
packageInfo
.
versionCode
)
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
String
.
format
(
"不需要更新, current: %s, update: %s"
,
packageInfo
.
versionCode
,
updateVo
.
getVersionCode
()));
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
String
.
format
(
"不需要更新, current: %s, update: %s"
,
packageInfo
.
versionCode
,
dataVo
.
getVersionCode
()));
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
String
.
format
(
"不需要更新, current: %s, update: %s"
,
packageInfo
.
versionCode
,
dataVo
.
getVersionCode
()),
Toast
.
LENGTH_LONG
);
}
return
;
return
;
}
}
startDownload
(
update
Vo
);
startDownload
(
data
Vo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"检查更新失败"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"检查更新失败"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"检查更新失败"
,
Toast
.
LENGTH_LONG
);
}
}
}
}
}
}
}
private
void
startDownload
(
CheckUpdateVo
update
Vo
)
{
private
void
startDownload
(
UpdateDataVo
data
Vo
)
{
String
filename
=
"hooloo-device_"
+
updateVo
.
getVersion
()
+
"_"
+
update
Vo
.
getVersionCode
()
+
"_"
+
System
.
currentTimeMillis
()
+
".apk"
;
String
filename
=
"hooloo-device_"
+
dataVo
.
getVersion
()
+
"_"
+
data
Vo
.
getVersionCode
()
+
"_"
+
System
.
currentTimeMillis
()
+
".apk"
;
String
path
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/hooloo"
;
String
path
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
()
+
"/hooloo"
;
if
(!
new
File
(
path
).
exists
())
{
if
(!
new
File
(
path
).
exists
())
{
new
File
(
path
).
mkdirs
();
new
File
(
path
).
mkdirs
();
}
}
String
file
=
path
+
"/"
+
filename
;
String
file
=
path
+
"/"
+
filename
;
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
String
.
format
(
"开始下载文件 url: %s, file: %s"
,
updateVo
.
getUrl
(),
file
));
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
String
.
format
(
"开始下载文件 url: %s, file: %s"
,
dataVo
.
getUrl
(),
file
));
HttpUtil
.
download
(
updateVo
.
getUrl
(),
file
,
downloadHandler
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
String
.
format
(
"开始下载文件 url: %s, file: %s"
,
dataVo
.
getUrl
(),
file
),
Toast
.
LENGTH_LONG
);
}
HttpUtil
.
download
(
dataVo
.
getUrl
(),
file
,
downloadHandler
);
}
}
private
Handler
downloadHandler
=
new
Handler
()
{
private
Handler
downloadHandler
=
new
Handler
()
{
...
@@ -113,17 +123,24 @@ public class UpdateService extends Thread {
...
@@ -113,17 +123,24 @@ public class UpdateService extends Thread {
try
{
try
{
Object
obj
=
msg
.
obj
;
Object
obj
=
msg
.
obj
;
if
(
msg
.
what
==
0
||
obj
==
null
)
{
if
(
msg
.
what
==
0
||
obj
==
null
)
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"download file error"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"下载文件失败"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"下载文件失败"
,
Toast
.
LENGTH_LONG
);
}
return
;
return
;
}
}
if
(
AppConfig
.
DEBUG
)
{
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"下载文件完成,测试版本不能自动升级"
,
Toast
.
LENGTH_LONG
);
return
;
// 测试不实际升级
return
;
// 测试不实际升级
}
}
ApkUtils
.
install
(
HLApplication
.
SELF
,
obj
.
toString
());
ApkUtils
.
install
(
HLApplication
.
SELF
,
obj
.
toString
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"下载文件错误"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"下载文件错误"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"下载文件错误"
,
Toast
.
LENGTH_LONG
);
}
}
}
}
}
};
};
...
...
app/src/main/java/com/ihaoin/hooloo/device/update/UpdateSocket.java
View file @
14c8c12e
package
com
.
ihaoin
.
hooloo
.
device
.
update
;
package
com
.
ihaoin
.
hooloo
.
device
.
update
;
import
android.content.Context
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.ihaoin.hooloo.device.base.AppConfig
;
import
com.ihaoin.hooloo.device.base.AppConfig
;
...
@@ -19,10 +25,10 @@ import io.socket.emitter.Emitter;
...
@@ -19,10 +25,10 @@ import io.socket.emitter.Emitter;
/** Linux通信 检查更新 */
/** Linux通信 检查更新 */
public
class
UpdateSocket
extends
Thread
{
public
class
UpdateSocket
extends
Thread
{
private
Context
mContext
;
private
Activity
mContext
;
private
Socket
mSocket
;
private
Socket
mSocket
;
public
UpdateSocket
(
Context
context
)
{
public
UpdateSocket
(
Activity
context
)
{
this
.
mContext
=
context
;
this
.
mContext
=
context
;
}
}
...
@@ -34,25 +40,39 @@ public class UpdateSocket extends Thread {
...
@@ -34,25 +40,39 @@ public class UpdateSocket extends Thread {
private
void
connectSocket
()
{
private
void
connectSocket
()
{
try
{
try
{
mSocket
=
IO
.
socket
(
Base
.
NSP_UPGRADE
);
mSocket
=
IO
.
socket
(
Base
.
NSP_UPGRADE
);
mSocket
.
connect
();
mSocket
.
on
(
"connect"
,
onConnect
);
mSocket
.
on
(
"connect"
,
onConnect
);
mSocket
.
on
(
"disconnect"
,
onDisconnect
);
mSocket
.
on
(
"disconnect"
,
onDisconnect
);
mSocket
.
on
(
"upgrade"
,
onUpgrade
);
mSocket
.
on
(
"upgrade"
,
onUpgrade
);
mSocket
.
connect
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"连接server失败,错误原因:"
+
e
.
getMessage
());
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"连接server失败,错误原因:"
+
e
.
getMessage
());
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"连接server失败,错误原因:"
+
e
.
getMessage
(),
Toast
.
LENGTH_LONG
);
}
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
private
Emitter
.
Listener
onConnect
=
args
->
{
private
Emitter
.
Listener
onConnect
=
args
->
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"update socket connected"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"update socket connected"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"update socket, 成功连接"
,
Toast
.
LENGTH_LONG
);
}
mSocket
.
emit
(
"state"
,
""
,
(
Ack
)
ack
->
process
(
"state"
,
ack
));
mSocket
.
emit
(
"state"
,
""
,
(
Ack
)
ack
->
process
(
"state"
,
ack
));
};
};
private
Emitter
.
Listener
onDisconnect
=
args
->
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"update socket disconnected"
);
private
Emitter
.
Listener
onDisconnect
=
args
->
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"update socket disconnected"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"update socket, 断开连接"
,
Toast
.
LENGTH_LONG
);
}
};
private
Emitter
.
Listener
onUpgrade
=
args
->
{
private
Emitter
.
Listener
onUpgrade
=
args
->
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"update socket upgrade"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
"update socket upgrade"
);
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"update socket, onUpgrade"
,
Toast
.
LENGTH_LONG
);
}
process
(
"upgrade"
,
args
);
process
(
"upgrade"
,
args
);
};
};
...
@@ -79,6 +99,9 @@ public class UpdateSocket extends Thread {
...
@@ -79,6 +99,9 @@ public class UpdateSocket extends Thread {
return
;
return
;
}
}
String
content
=
args
[
0
].
toString
();
String
content
=
args
[
0
].
toString
();
if
(
AppConfig
.
DEBUG
)
{
Utils
.
showToast
(
mContext
,
"update socket, 接收消息: "
+
content
,
Toast
.
LENGTH_LONG
);
}
if
(
StringUtils
.
isEmpty
(
content
))
{
if
(
StringUtils
.
isEmpty
(
content
))
{
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
func
+
" content empty"
);
Utils
.
i
(
AppConfig
.
TAG_UPDATE
,
func
+
" content empty"
);
return
;
return
;
...
@@ -90,10 +113,18 @@ public class UpdateSocket extends Thread {
...
@@ -90,10 +113,18 @@ public class UpdateSocket extends Thread {
return
;
return
;
}
}
if
(
node
.
get
(
"upgrade"
)
!=
null
&&
node
.
get
(
"upgrade"
).
asBoolean
())
{
if
(
node
.
get
(
"upgrade"
)
!=
null
&&
node
.
get
(
"upgrade"
).
asBoolean
())
{
new
UpdateService
(
mContext
).
start
(
);
startUpdateServiceHandler
.
sendEmptyMessage
(
0
);
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
@SuppressLint
(
"HandlerLeak"
)
private
Handler
startUpdateServiceHandler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
new
UpdateService
(
mContext
).
start
();
}
};
}
}
app/src/main/java/com/ihaoin/hooloo/device/util/Utils.java
View file @
14c8c12e
package
com
.
ihaoin
.
hooloo
.
device
.
util
;
package
com
.
ihaoin
.
hooloo
.
device
.
util
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageInfo
;
...
@@ -305,6 +306,19 @@ public class Utils {
...
@@ -305,6 +306,19 @@ public class Utils {
showToast
(
context
,
text
,
Toast
.
LENGTH_SHORT
);
showToast
(
context
,
text
,
Toast
.
LENGTH_SHORT
);
}
}
public
static
void
showToast
(
Activity
activity
,
String
text
,
int
t
)
{
activity
.
runOnUiThread
(()
->
{
View
view
=
LayoutInflater
.
from
(
activity
).
inflate
(
R
.
layout
.
view_toast
,
null
);
TextView
textView
=
view
.
findViewById
(
R
.
id
.
txt_toast
);
textView
.
setText
(
text
);
Toast
toast
=
Toast
.
makeText
(
activity
,
text
,
t
);
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
toast
.
setView
(
view
);
toast
.
show
();
});
}
public
static
void
showToast
(
Context
context
,
String
text
,
int
t
)
{
public
static
void
showToast
(
Context
context
,
String
text
,
int
t
)
{
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
view_toast
,
null
);
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
view_toast
,
null
);
TextView
textView
=
view
.
findViewById
(
R
.
id
.
txt_toast
);
TextView
textView
=
view
.
findViewById
(
R
.
id
.
txt_toast
);
...
...
app/src/main/res/values-w800dp/dimens.xml
View file @
14c8c12e
...
@@ -150,7 +150,7 @@
...
@@ -150,7 +150,7 @@
<dimen
name=
"interaction_recommend_margin_bottom"
>
140px
</dimen>
<dimen
name=
"interaction_recommend_margin_bottom"
>
140px
</dimen>
<dimen
name=
"interaction_recommend_image_margin"
>
80px
</dimen>
<dimen
name=
"interaction_recommend_image_margin"
>
80px
</dimen>
<dimen
name=
"interaction_goods_icon_width"
>
260px
</dimen>
<dimen
name=
"interaction_goods_icon_width"
>
260px
</dimen>
<dimen
name=
"interaction_goods_icon_height"
>
260
px
</dimen>
<dimen
name=
"interaction_goods_icon_height"
>
195
px
</dimen>
<dimen
name=
"ts_interaction_line1"
>
260px
</dimen>
<dimen
name=
"ts_interaction_line1"
>
260px
</dimen>
<dimen
name=
"ts_interaction_line2"
>
100px
</dimen>
<dimen
name=
"ts_interaction_line2"
>
100px
</dimen>
...
...
app/src/main/res/values/dimens.xml
View file @
14c8c12e
...
@@ -166,7 +166,7 @@
...
@@ -166,7 +166,7 @@
<dimen
name=
"interaction_recommend_margin_bottom"
>
140px
</dimen>
<dimen
name=
"interaction_recommend_margin_bottom"
>
140px
</dimen>
<dimen
name=
"interaction_recommend_image_margin"
>
80px
</dimen>
<dimen
name=
"interaction_recommend_image_margin"
>
80px
</dimen>
<dimen
name=
"interaction_goods_icon_width"
>
260px
</dimen>
<dimen
name=
"interaction_goods_icon_width"
>
260px
</dimen>
<dimen
name=
"interaction_goods_icon_height"
>
260
px
</dimen>
<dimen
name=
"interaction_goods_icon_height"
>
195
px
</dimen>
<dimen
name=
"ts_interaction_line1"
>
260px
</dimen>
<dimen
name=
"ts_interaction_line1"
>
260px
</dimen>
<dimen
name=
"ts_interaction_line2"
>
100px
</dimen>
<dimen
name=
"ts_interaction_line2"
>
100px
</dimen>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment