FangTangApplication.java
3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.xgimi.gimicinema.application;
import android.util.Log;
import android.widget.Toast;
import com.gimi.common.cinema.utils.LogUtils;
import com.gimi.common.cinema.utils.Utils;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.qnbar.smc.application.MySampleAdvanceStrategy;
import com.qnbar.smc.service.TelinkLightService;
import com.telink.TelinkApplication;
import com.telink.bluetooth.light.AdvanceStrategy;
import com.telink.bluetooth.light.model.Mesh;
public class FangTangApplication extends TelinkApplication {
private Mesh mesh;
private String currentPlayUrl;
@Override
public void onCreate() {
super.onCreate();
AdvanceStrategy.setDefault(new MySampleAdvanceStrategy());
// CrashHandler crashHandler = CrashHandler.getInstance();
// crashHandler.init(getApplicationContext());initLog\\
initLog();
}
@Override
public void doInit() {
// String fileName = "telink-";
// fileName += System.currentTimeMillis();
// fileName += ".log";
// TelinkLog.LOG2FILE_ENABLE = false;
// TelinkLog.onCreate(fileName);
super.doInit();
//AES.Security = true;
/**
*
*@see com.telink.bluetooth.light.model.Mesh#saveOrUpdate
*/
//save by json string
try {
String string = Utils.getString(this, "mesh-config");
this.mesh = new Gson().fromJson(string, Mesh.class);
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
if (mesh == null) {
Toast.makeText(this, "没有配置智能灯光,请配置", Toast.LENGTH_SHORT).show();
// return;
}
Log.d("SMCService", "doInit");
//启动LightService
this.startLightService(TelinkLightService.class);
}
public Mesh getMesh() {
return this.mesh;
}
public void setMesh(Mesh mesh) {
this.mesh = mesh;
}
public boolean isEmptyMesh() {
return this.mesh == null;
}
public String getCurrentPlayUrl() {
return currentPlayUrl;
}
public void setCurrentPlayUrl(String currentPlayUrl) {
this.currentPlayUrl = currentPlayUrl;
}
public static void initLog() {
LogUtils.Builder builder = new LogUtils.Builder()
.setLogSwitch(true)// 设置log总开关,包括输出到控制台和文件,默认开
.setConsoleSwitch(true)// 设置是否输出到控制台开关,默认开
.setGlobalTag(null)// 设置log全局标签,默认为空
// 当全局标签不为空时,我们输出的log全部为该tag,
// 为空时,如果传入的tag为空那就显示类名,否则显示tag
.setLogHeadSwitch(true)// 设置log头信息开关,默认为开
.setLog2FileSwitch(true)// 打印log时是否存到文件的开关,默认关
.setDir("/sdcard/ft_log/")// 当自定义路径为空时,写入应用的/cache/log/目录中
.setBorderSwitch(true)// 输出日志是否带边框开关,默认开
.setConsoleFilter(LogUtils.V)// log的控制台过滤器,和logcat过滤器同理,默认Verbose
.setFileFilter(LogUtils.V);// log文件过滤器,和logcat过滤器同理,默认Verbose
LogUtils.d(builder.toString());
}
}