Skip to content

Commit 8681ca5

Browse files
author
geyifeng
committed
优化代码
1 parent 79b3e66 commit 8681ca5

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

cactus/src/main/java/com/gyf/cactus/Cactus.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class Cactus private constructor() {
6565
* key,通过广播形式获取启动次数
6666
*/
6767
const val CACTUS_TIMES = "times"
68-
6968
@JvmStatic
7069
val instance by lazy { Cactus() }
7170
}

cactus/src/main/java/com/gyf/cactus/callback/CactusCallback.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ interface CactusCallback {
1818
* 停止时调用
1919
*/
2020
fun onStop()
21-
}
21+
}

cactus/src/main/java/com/gyf/cactus/exception/CactusException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ package com.gyf.cactus.exception
66
* @author geyifeng
77
* @date 2019-11-08 11:51
88
*/
9-
class CactusException internal constructor(msg: String) : Exception(msg)
9+
class CactusException internal constructor(msg: String) : Exception(msg)

cactus/src/main/java/com/gyf/cactus/pix/OnePixActivity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package com.gyf.cactus.pix
22

33
import android.app.Activity
44
import android.os.Bundle
5-
import android.util.Log
65
import android.view.Gravity
7-
import com.gyf.cactus.entity.Constant
86
import com.gyf.cactus.ext.finishOnePix
97
import com.gyf.cactus.ext.isScreenOn
8+
import com.gyf.cactus.ext.log
109
import com.gyf.cactus.ext.setOnePix
1110

1211
/**
@@ -18,7 +17,7 @@ class OnePixActivity : Activity() {
1817

1918
override fun onCreate(savedInstanceState: Bundle?) {
2019
super.onCreate(savedInstanceState)
21-
Log.d(Constant.CACTUS_TAG, "one pix is created")
20+
log("one pix is created")
2221
overridePendingTransition(0, 0)
2322
//设定一像素的activity
2423
window.setGravity(Gravity.START or Gravity.TOP)
@@ -41,7 +40,7 @@ class OnePixActivity : Activity() {
4140
override fun onDestroy() {
4241
super.onDestroy()
4342
finishOnePix()
44-
Log.d(Constant.CACTUS_TAG, "one pix is destroyed")
43+
log("one pix is destroyed")
4544
}
4645

4746
override fun finish() {

cactus/src/main/java/com/gyf/cactus/service/CactusJobService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import android.content.ComponentName
99
import android.content.Context
1010
import android.content.Intent
1111
import android.os.Build
12-
import android.util.Log
1312
import androidx.annotation.RequiresApi
1413
import com.gyf.cactus.entity.CactusConfig
1514
import com.gyf.cactus.entity.Constant
@@ -58,15 +57,15 @@ class CactusJobService : JobService() {
5857
}
5958

6059
override fun onStartJob(jobParameters: JobParameters): Boolean {
61-
Log.d(Constant.CACTUS_TAG, "onStartJob")
60+
log("onStartJob")
6261
if (!isServiceRunning && !mIsStop) {
6362
registerCactus(mCactusConfig)
6463
}
6564
return false
6665
}
6766

6867
override fun onStopJob(jobParameters: JobParameters): Boolean {
69-
Log.d(Constant.CACTUS_TAG, "onStopJob")
68+
log("onStopJob")
7069
if (!isServiceRunning && !mIsStop) {
7170
registerCactus(mCactusConfig)
7271
}

cactus/src/main/java/com/gyf/cactus/workmanager/CactusWorker.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package com.gyf.cactus.workmanager
22

33
import android.content.Context
4-
import android.util.Log
54
import androidx.work.WorkManager
65
import androidx.work.Worker
76
import androidx.work.WorkerParameters
87
import com.gyf.cactus.entity.Constant
9-
import com.gyf.cactus.ext.getConfig
10-
import com.gyf.cactus.ext.isServiceRunning
11-
import com.gyf.cactus.ext.register
12-
import com.gyf.cactus.ext.registerStopReceiver
8+
import com.gyf.cactus.ext.*
139

1410
/**
1511
* WorkManager定时器
@@ -37,10 +33,7 @@ class CactusWorker(val context: Context, workerParams: WorkerParameters) :
3733
context.apply {
3834
val cactusConfig = getConfig()
3935
if (cactusConfig.defaultConfig.debug) {
40-
Log.d(
41-
Constant.CACTUS_TAG,
42-
"CactusWorker-isServiceRunning:$isServiceRunning"
43-
)
36+
log("CactusWorker-isServiceRunning:$isServiceRunning")
4437
}
4538
if (!isServiceRunning) {
4639
register(cactusConfig)

0 commit comments

Comments
 (0)