Skip to content

Commit 5234fc5

Browse files
committed
1.优化一下App的代码
1 parent ff10bc6 commit 5234fc5

File tree

1 file changed

+19
-26
lines changed
  • qpython/src/main/java/org/qpython/qpy/main/app

1 file changed

+19
-26
lines changed

qpython/src/main/java/org/qpython/qpy/main/app/App.java

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
4545
import retrofit2.converter.gson.GsonConverterFactory;
4646

47-
public class App extends QSL4APP {
47+
public class App extends QSL4APP implements CactusCallback{
4848

4949
private static final String TAG = "APP";
5050
private static Context sContext;
@@ -244,20 +244,7 @@ private void initCactus() {
244244
.setLargeIcon(R.drawable.ic_launcher)
245245
.setSmallIcon(R.drawable.ic_launcher)
246246
.hideNotificationAfterO(false)
247-
.addCallback(new CactusCallback() {
248-
@Override
249-
public void doWork(int i) {
250-
LogUtil.e("doWork1111111");
251-
if (!isRunService( "org.qpython.qsl4a.QPyScriptService")) {
252-
startPyService();
253-
}
254-
}
255-
256-
@Override
257-
public void onStop() {
258-
259-
}
260-
})
247+
.addCallback(this)
261248
.register(this);
262249
}
263250

@@ -271,12 +258,23 @@ private void initLayoutDir() {
271258
}
272259
}
273260

274-
// @Override
275-
// public void doWork(int i) {
276-
// if (!isRunService(this, "org.qpython.qsl4a.QPyScriptService")) {
277-
// startPyService();
278-
// }
279-
// }
261+
/**
262+
* 保活的回调接口
263+
* @param i
264+
*/
265+
@Override
266+
public void doWork(int i) {
267+
LogUtil.e("doWork1111111");
268+
if (!isRunService( "org.qpython.qsl4a.QPyScriptService")) {
269+
startPyService();
270+
}
271+
}
272+
273+
/**
274+
* 保活的回调接口
275+
*/
276+
@Override
277+
public void onStop() {}
280278

281279
private void startPyService() {
282280
LogUtil.e("doWork22222");
@@ -285,11 +283,6 @@ private void startPyService() {
285283
startService(intent);
286284
}
287285

288-
// @Override
289-
// public void onStop() {
290-
//
291-
// }
292-
293286
/**
294287
* 判断服务是否在运行
295288
*

0 commit comments

Comments
 (0)