Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
Widget
Project
Project
Details
Activity
Releases
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
Android Widget
Widget
Commits
e490c9d4
Commit
e490c9d4
authored
Sep 24, 2020
by
王雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整日志库初始化,上传等
parent
5f1a0bb8
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
137 additions
and
67 deletions
+137
-67
build.gradle
app/build.gradle
+5
-0
MainActivity.kt
app/src/main/java/com/qimai/android/widget/MainActivity.kt
+2
-0
build.gradle
log/build.gradle
+9
-2
libc++_shared.so
log/libs/arm64-v8a/libc++_shared.so
+0
-0
libmarsxlog.so
log/libs/arm64-v8a/libmarsxlog.so
+0
-0
libc++_shared.so
log/libs/armeabi-v7a/libc++_shared.so
+0
-0
libmarsxlog.so
log/libs/armeabi-v7a/libmarsxlog.so
+0
-0
AndroidManifest.xml
log/src/main/AndroidManifest.xml
+4
-15
DBCopyUtils.java
log/src/main/java/com/qimai/log/DBCopyUtils.java
+2
-2
InitContentProvider.kt
log/src/main/java/com/qimai/log/InitContentProvider.kt
+1
-1
LogInit.kt
log/src/main/java/com/qimai/log/LogInit.kt
+36
-23
QmLog.kt
log/src/main/java/com/qimai/log/QmLog.kt
+22
-9
QmLogConfig.kt
log/src/main/java/com/qimai/log/QmLogConfig.kt
+13
-0
UploadService.java
log/src/main/java/com/qimai/log/UploadService.java
+3
-3
PushDataBaseVm.kt
log/src/main/java/com/qimai/log/database/PushDataBaseVm.kt
+1
-1
PushNotifiInfo.kt
log/src/main/java/com/qimai/log/database/PushNotifiInfo.kt
+10
-10
PushNotifiInfoDao.kt
...src/main/java/com/qimai/log/database/PushNotifiInfoDao.kt
+7
-1
ScheduledExecutionService.kt
...n/java/com/qimai/log/service/ScheduledExecutionService.kt
+22
-0
No files found.
app/build.gradle
View file @
e490c9d4
...
@@ -21,6 +21,10 @@ android {
...
@@ -21,6 +21,10 @@ android {
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
}
}
}
packagingOptions
{
pickFirst
'lib/armeabi-v7a/libc++_shared.so'
pickFirst
'lib/armeabi-v7a/libmarsxlog.so'
}
}
}
dependencies
{
dependencies
{
...
@@ -31,6 +35,7 @@ dependencies {
...
@@ -31,6 +35,7 @@ dependencies {
implementation
'androidx.core:core-ktx:1.0.2'
implementation
'androidx.core:core-ktx:1.0.2'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
project
(
path:
':KeyBoardView'
)
implementation
project
(
path:
':KeyBoardView'
)
implementation
project
(
path:
':log'
)
testImplementation
'junit:junit:4.12'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
...
...
app/src/main/java/com/qimai/android/widget/MainActivity.kt
View file @
e490c9d4
...
@@ -9,6 +9,7 @@ import android.widget.TextView
...
@@ -9,6 +9,7 @@ import android.widget.TextView
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
com.qimai.android.widgetlib.popup.QmTipOverlayDrawable
import
com.qimai.android.widgetlib.popup.QmTipOverlayDrawable
import
com.qimai.android.widgetlib.toast.HolderContext
import
com.qimai.android.widgetlib.toast.HolderContext
import
com.qimai.log.QmLog
import
kotlinx.android.synthetic.main.activity_main.*
import
kotlinx.android.synthetic.main.activity_main.*
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
...
@@ -20,6 +21,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -20,6 +21,7 @@ class MainActivity : AppCompatActivity() {
this
this
}
}
QmLog
.
d
(
"test1111"
,
"111111"
)
findViewById
<
Button
>(
R
.
id
.
commonPop
).
setOnClickListener
{
findViewById
<
Button
>(
R
.
id
.
commonPop
).
setOnClickListener
{
// ToastUtils.getInstance().showCenter("测试测试")
// ToastUtils.getInstance().showCenter("测试测试")
...
...
log/build.gradle
View file @
e490c9d4
...
@@ -31,6 +31,13 @@ android {
...
@@ -31,6 +31,13 @@ android {
kotlinOptions
{
kotlinOptions
{
jvmTarget
=
'1.8'
jvmTarget
=
'1.8'
}
}
sourceSets
{
main
{
jniLibs
.
srcDirs
=
[
'libs'
]
}
}
}
}
...
@@ -47,7 +54,7 @@ dependencies {
...
@@ -47,7 +54,7 @@ dependencies {
testImplementation
'junit:junit:4.+'
testImplementation
'junit:junit:4.+'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
implementation
'com.tencent.mars:mars-xlog:1.2.4'
api
'com.tencent.mars:mars-xlog:1.2.4'
// For Kotlin use kapt instead of annotationProcessor (注意这个注释)
// For Kotlin use kapt instead of annotationProcessor (注意这个注释)
kapt
"androidx.room:room-compiler:$lifecycle_version"
kapt
"androidx.room:room-compiler:$lifecycle_version"
implementation
"androidx.room:room-runtime:$lifecycle_version"
implementation
"androidx.room:room-runtime:$lifecycle_version"
...
@@ -63,7 +70,7 @@ dependencies {
...
@@ -63,7 +70,7 @@ dependencies {
}
}
group
'com.qmai.android.log'
group
'com.qmai.android.log'
version
'1.0.1-SNAPSHOT'
version
'1.0.1
.13
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
log/libs/arm64-v8a/libc++_shared.so
0 → 100644
View file @
e490c9d4
File added
log/libs/arm64-v8a/libmarsxlog.so
0 → 100644
View file @
e490c9d4
File added
log/libs/armeabi-v7a/libc++_shared.so
0 → 100755
View file @
e490c9d4
File added
log/libs/armeabi-v7a/libmarsxlog.so
0 → 100755
View file @
e490c9d4
File added
log/src/main/AndroidManifest.xml
View file @
e490c9d4
...
@@ -6,27 +6,16 @@
...
@@ -6,27 +6,16 @@
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<application
<application
android:allowBackup=
"true"
>
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.MyApplication"
>
<activity
android:name=
".MainActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<provider
<provider
android:name=
"com.qimai.log.InitContentProvider"
android:name=
"com.qimai.log.InitContentProvider"
android:authorities=
"{applicationId}.InitContentProvider"
android:authorities=
"{applicationId}.InitContentProvider
1
"
android:enabled=
"true"
android:enabled=
"true"
android:exported=
"true"
/>
android:exported=
"false"
/>
<service
android:name=
"com.qimai.log.UploadService"
/>
<service
android:name=
"com.qimai.log.UploadService"
/>
<service
android:name=
".service.ScheduledExecutionService"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
log/src/main/java/com/qimai/log/DBCopyUtils.java
View file @
e490c9d4
...
@@ -24,7 +24,7 @@ public class DBCopyUtils {
...
@@ -24,7 +24,7 @@ public class DBCopyUtils {
private
static
final
String
TAG
=
"DBCopyUtils"
;
private
static
final
String
TAG
=
"DBCopyUtils"
;
public
static
void
copyLogToFTP
(
String
tag
)
{
/*
public static void copyLogToFTP(String tag) {
File file = null;
File file = null;
final String SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
final String SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
...
@@ -73,7 +73,7 @@ public class DBCopyUtils {
...
@@ -73,7 +73,7 @@ public class DBCopyUtils {
}
}
}
}
*/
/**
/**
* @param file 代表文件不是目录
* @param file 代表文件不是目录
...
...
log/src/main/java/com/qimai/log/InitContentProvider.kt
View file @
e490c9d4
...
@@ -20,7 +20,7 @@ class InitContentProvider : ContentProvider() {
...
@@ -20,7 +20,7 @@ class InitContentProvider : ContentProvider() {
}
}
override
fun
onCreate
():
Boolean
{
override
fun
onCreate
():
Boolean
{
context
?.
let
{
LogInit
.
getInstance
().
init
(
it
)
}
context
?.
let
{
LogInit
.
getInstance
().
init
(
it
)
}
return
true
return
true
}
}
...
...
log/src/main/java/com/qimai/log/LogInit.kt
View file @
e490c9d4
...
@@ -3,53 +3,65 @@ package com.qimai.log
...
@@ -3,53 +3,65 @@ package com.qimai.log
import
android.app.Activity
import
android.app.Activity
import
android.app.Application
import
android.app.Application
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.os.Environment
import
android.os.Environment
import
com.qimai.log.service.ScheduledExecutionService
import
com.tencent.mars.xlog.Log
import
com.tencent.mars.xlog.Log
import
com.tencent.mars.xlog.Log.appenderClose
import
com.tencent.mars.xlog.Xlog
import
com.tencent.mars.xlog.Xlog
class
LogInit
private
constructor
()
{
class
LogInit
private
constructor
()
{
lateinit
var
mApplication
:
Context
private
lateinit
var
mLogConfig
:
QmLogConfig
fun
init
(
app
:
Context
)
{
fun
init
(
application
:
Context
)
{
mApplication
=
app
init
(
QmLogConfig
(
application
))
addObserver
(
mApplication
)
}
@JvmOverloads
fun
init
(
config
:
QmLogConfig
)
{
this
.
mLogConfig
=
config
//addObserver(config.app)
System
.
loadLibrary
(
"c++_shared"
)
System
.
loadLibrary
(
"c++_shared"
)
System
.
loadLibrary
(
"marsxlog"
)
System
.
loadLibrary
(
"marsxlog"
)
val
SDCARD
=
Environment
.
getExternalStorageDirectory
().
absolutePath
var
logPath
=
""
val
logPath
=
mApplication
.
getFilesDir
().
toString
()
+
"/release/xlog"
if
(
BuildConfig
.
DEBUG
){
// this is necessary, or may cash for SIGBUS
logPath
=
config
.
logDebugPath
// this is necessary, or may cash for SIGBUS
}
else
{
val
cachePath
:
String
=
mApplication
.
getFilesDir
().
toString
()
+
"/debug/xlog"
logPath
=
config
.
logReleasePath
//init xlog
//init xlog
}
val
logConfig
=
Xlog
.
XLogConfig
()
val
logConfig
=
Xlog
.
XLogConfig
()
logConfig
.
mode
=
Xlog
.
AppednerModeAsync
logConfig
.
mode
=
Xlog
.
AppednerModeAsync
logConfig
.
logdir
=
cache
Path
logConfig
.
logdir
=
log
Path
logConfig
.
nameprefix
=
"log"
logConfig
.
nameprefix
=
"log"
logConfig
.
pubkey
=
""
;
logConfig
.
pubkey
=
""
logConfig
.
compressmode
=
Xlog
.
ZLIB_MODE
logConfig
.
compressmode
=
Xlog
.
ZLIB_MODE
logConfig
.
compresslevel
=
0
logConfig
.
compresslevel
=
0
logConfig
.
cachedir
=
cachePath
logConfig
.
cachedays
=
0
logConfig
.
cachedays
=
0
if
(
BuildConfig
.
DEBUG
)
{
logConfig
.
cachedir
=
""
logConfig
.
level
=
Xlog
.
LEVEL_DEBUG
// if (BuildConfig.DEBUG) {
Xlog
.
setConsoleLogOpen
(
true
)
}
else
{
logConfig
.
level
=
Xlog
.
LEVEL_DEBUG
logConfig
.
level
=
Xlog
.
LEVEL_DEBUG
Xlog
.
setConsoleLogOpen
(
true
)
Xlog
.
setConsoleLogOpen
(
true
)
}
// } else {
// logConfig.level = Xlog.LEVEL_ALL
// Xlog.setConsoleLogOpen(true)
//}
Xlog
.
appenderOpen
(
logConfig
)
Xlog
.
appenderOpen
(
logConfig
)
Log
.
setLogImp
(
Xlog
())
Log
.
setLogImp
(
Xlog
())
//检查是否有过期的通知数据
// val intent = Intent(getConfig().app, ScheduledExecutionService::class.java)
// getConfig().app.startService(intent)
}
}
private
fun
addObserver
(
mApplication
:
Context
)
{
private
fun
addObserver
(
mApplication
:
Context
)
{
if
(
mApplication
is
Application
){
if
(
mApplication
is
Application
)
{
mApplication
.
registerActivityLifecycleCallbacks
(
object
:
mApplication
.
registerActivityLifecycleCallbacks
(
object
:
Application
.
ActivityLifecycleCallbacks
{
Application
.
ActivityLifecycleCallbacks
{
override
fun
onActivityCreated
(
activity
:
Activity
,
savedInstanceState
:
Bundle
?)
{
override
fun
onActivityCreated
(
activity
:
Activity
,
savedInstanceState
:
Bundle
?)
{
...
@@ -86,7 +98,8 @@ class LogInit private constructor() {
...
@@ -86,7 +98,8 @@ class LogInit private constructor() {
fun
getInstance
():
LogInit
{
fun
getInstance
():
LogInit
{
return
mInstance
return
mInstance
}
}
}
fun
getConfig
()
=
mLogConfig
}
}
}
\ No newline at end of file
log/src/main/java/com/qimai/log/QmLog.kt
View file @
e490c9d4
...
@@ -2,38 +2,51 @@ package com.qimai.log
...
@@ -2,38 +2,51 @@ package com.qimai.log
import
android.content.Intent
import
android.content.Intent
import
com.tencent.mars.xlog.Log
import
com.tencent.mars.xlog.Log
import
java.lang.IllegalArgumentException
object
QmLog
{
object
QmLog
{
fun
d
(
tag
:
String
,
message
:
String
)
{
fun
d
(
tag
:
String
,
message
:
String
)
{
Log
.
d
(
tag
,
message
)
Log
.
d
(
tag
,
message
)
}
}
fun
e
(
tag
:
String
,
message
:
String
)
{
fun
e
(
tag
:
String
,
message
:
String
)
{
Log
.
e
(
tag
,
message
)
Log
.
e
(
tag
,
message
)
}
}
fun
v
(
tag
:
String
,
message
:
String
){
fun
v
(
tag
:
String
,
message
:
String
)
{
Log
.
v
(
tag
,
message
)
Log
.
v
(
tag
,
message
)
}
}
fun
w
(
tag
:
String
,
message
:
String
){
fun
w
(
tag
:
String
,
message
:
String
)
{
Log
.
w
(
tag
,
message
)
Log
.
w
(
tag
,
message
)
}
}
fun
i
(
tag
:
String
,
message
:
String
){
fun
i
(
tag
:
String
,
message
:
String
)
{
Log
.
i
(
tag
,
message
)
Log
.
i
(
tag
,
message
)
}
}
fun
flush
(){
Log
.
appenderClose
()
fun
flush
()
{
Log
.
appenderClose
()
}
}
/**
/**
* 上传log
* 上传log
*/
*/
fun
uploadLog
(
config
:
UploadConfig
){
fun
uploadLog
(
config
:
UploadConfig
)
{
//刷新下
//刷新下
Log
.
appenderFlush
(
false
)
Log
.
appenderFlush
(
false
)
val
intent
=
Intent
(
LogInit
.
getInstance
().
mApplication
,
UploadService
::
class
.
java
)
val
intent
=
Intent
(
getConfig
().
app
,
UploadService
::
class
.
java
)
intent
.
putExtra
(
"upload"
,
config
)
intent
.
putExtra
(
"upload"
,
config
)
LogInit
.
getInstance
().
mApplication
.
startService
(
intent
)
getConfig
().
app
.
startService
(
intent
)
}
}
fun
getConfig
():
QmLogConfig
{
val
config
:
QmLogConfig
?
=
LogInit
.
getInstance
().
getConfig
()
if
(
config
==
null
)
{
throw
IllegalArgumentException
(
"please call LogInit.init() first"
)
}
else
{
return
config
!!
}
}
}
}
\ No newline at end of file
log/src/main/java/com/qimai/log/QmLogConfig.kt
0 → 100644
View file @
e490c9d4
package
com.qimai.log
import
android.content.Context
/**
* 基本参数配置
*/
class
QmLogConfig
(
val
app
:
Context
,
var
logDebugPath
:
String
=
app
.
filesDir
.
toString
()
+
"/debug/xlog"
,
var
logReleasePath
:
String
=
app
.
filesDir
.
toString
()
+
"/release/xlog"
,
var
expiredDays
:
Int
=
10
)
{
}
\ No newline at end of file
log/src/main/java/com/qimai/log/UploadService.java
View file @
e490c9d4
...
@@ -60,13 +60,13 @@ public class UploadService extends IntentService {
...
@@ -60,13 +60,13 @@ public class UploadService extends IntentService {
//DBCopyUtils.copyLogToFTP();
//DBCopyUtils.copyLogToFTP();
//int requestNum = receiverBean.getNum();
//int requestNum = receiverBean.getNum();
File
file
=
null
;
File
file
=
null
;
final
String
SDCARD
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
();
// final String logPath = SDCARD + "/ptcy/log";
// final String logPath = SDCARD + "/ptcy/log";
final
String
logPath
;
final
String
logPath
;
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
logPath
=
LogInit
.
Companion
.
getInstance
().
mApplication
.
getFilesDir
().
toString
()
+
"/debug/xlog"
;
logPath
=
QmLog
.
INSTANCE
.
getConfig
().
getLogDebugPath
();
}
else
{
}
else
{
logPath
=
LogInit
.
Companion
.
getInstance
().
mApplication
.
getFilesDir
().
toString
()
+
"/release/xlog"
;
logPath
=
QmLog
.
INSTANCE
.
getConfig
().
getLogReleasePath
()
;
}
}
file
=
new
File
(
logPath
);
file
=
new
File
(
logPath
);
...
...
log/src/main/java/com/qimai/log/database/
App
DataBaseVm.kt
→
log/src/main/java/com/qimai/log/database/
Push
DataBaseVm.kt
View file @
e490c9d4
...
@@ -9,7 +9,7 @@ import kotlinx.coroutines.launch
...
@@ -9,7 +9,7 @@ import kotlinx.coroutines.launch
/**
/**
* 获取数据库操作类
* 获取数据库操作类
*/
*/
class
App
DataBaseVm
(
application
:
Application
)
:
AndroidViewModel
(
application
)
{
class
Push
DataBaseVm
(
application
:
Application
)
:
AndroidViewModel
(
application
)
{
private
val
mDataBse
:
PushNotifiInfoDao
by
lazy
{
private
val
mDataBse
:
PushNotifiInfoDao
by
lazy
{
PushNotifiDataBase
.
getDatabase
(
application
).
pushInfoDao
()
PushNotifiDataBase
.
getDatabase
(
application
).
pushInfoDao
()
}
}
...
...
log/src/main/java/com/qimai/log/database/PushNotifiInfo.kt
View file @
e490c9d4
...
@@ -7,15 +7,15 @@ import androidx.room.PrimaryKey
...
@@ -7,15 +7,15 @@ import androidx.room.PrimaryKey
@Entity
(
tableName
=
"push_info"
)
@Entity
(
tableName
=
"push_info"
)
data class
PushNotifiInfo
@JvmOverloads
data class
PushNotifiInfo
@JvmOverloads
constructor
(
constructor
(
@PrimaryKey
@ColumnInfo
(
name
=
"msg_id"
)
val
msg_id
:
String
,
//消息id
@PrimaryKey
@ColumnInfo
(
name
=
"msg_id"
)
val
msg_id
:
String
,
//消息id
@ColumnInfo
(
name
=
"status"
)
var
status
:
Boolean
,
// 状态
@ColumnInfo
(
name
=
"status"
)
var
status
:
Boolean
,
// 状态
@ColumnInfo
(
name
=
"error_msg"
)
var
errorMsg
:
String
?
=
null
,
//错误原因
@ColumnInfo
(
name
=
"error_msg"
)
var
errorMsg
:
String
?
=
null
,
//错误原因
@ColumnInfo
(
name
=
"push_type"
)
val
pushType
:
String
,
//用的什么推送
@ColumnInfo
(
name
=
"push_type"
)
val
pushType
:
String
,
//用的什么推送
@ColumnInfo
(
name
=
"rawText"
)
var
rawText
:
String
?
=
null
,
//原始信息
@ColumnInfo
(
name
=
"rawText"
)
var
rawText
:
String
?
=
null
,
//原始信息
@ColumnInfo
(
name
=
"time"
)
var
time
:
String
?
=
null
,
//格式化时间
@ColumnInfo
(
name
=
"time"
)
var
time
:
String
?
=
null
,
//格式化时间
@ColumnInfo
(
name
=
"device_id"
)
var
deviceId
:
String
?
=
null
,
//推送的devicedId
@ColumnInfo
(
name
=
"device_id"
)
var
deviceId
:
String
?
=
null
,
//推送的devicedId
@ColumnInfo
(
name
=
"model"
)
var
model
:
String
?
=
null
,
//手机型号
@ColumnInfo
(
name
=
"model"
)
var
model
:
String
?
=
null
,
//手机型号
@ColumnInfo
(
name
=
"app_version"
)
var
version
:
String
?
=
null
,
//app版本
@ColumnInfo
(
name
=
"app_version"
)
var
version
:
String
?
=
null
,
//app版本
@ColumnInfo
(
name
=
"time_stamp"
)
var
timeStamp
:
String
?=
null
//时间戳
@ColumnInfo
(
name
=
"time_stamp"
)
var
timeStamp
:
Long
?
=
null
//时间戳
)
{
)
{
}
}
\ No newline at end of file
log/src/main/java/com/qimai/log/database/PushNotifiInfoDao.kt
View file @
e490c9d4
package
com.qimai.log.database
package
com.qimai.log.database
import
androidx.room.*
import
androidx.room.*
import
java.sql.Timestamp
/**
/**
* 数据库操作类
* 数据库操作类
...
@@ -12,5 +13,10 @@ interface PushNotifiInfoDao {
...
@@ -12,5 +13,10 @@ interface PushNotifiInfoDao {
suspend
fun
insert
(
word
:
PushNotifiInfo
)
suspend
fun
insert
(
word
:
PushNotifiInfo
)
@Query
(
"update push_info set status= :status ,error_msg = :errorMsg where msg_id=:msg_id"
)
@Query
(
"update push_info set status= :status ,error_msg = :errorMsg where msg_id=:msg_id"
)
suspend
fun
updateStatus
(
msg_id
:
String
,
status
:
Boolean
,
errorMsg
:
String
?=
null
)
suspend
fun
updateStatus
(
msg_id
:
String
,
status
:
Boolean
,
errorMsg
:
String
?
=
null
)
//删除过期数据
@Query
(
"delete from push_info where time_stamp < :timestamp"
)
fun
deleteExpiredItems
(
timestamp
:
Long
)
}
}
\ No newline at end of file
log/src/main/java/com/qimai/log/service/ScheduledExecutionService.kt
0 → 100644
View file @
e490c9d4
package
com.qimai.log.service
import
android.app.IntentService
import
android.content.Intent
import
com.qimai.log.QmLog
import
com.qimai.log.database.PushNotifiDataBase
import
com.qimai.log.database.PushNotifiInfoDao
import
com.qimai.log.QmLogConfig
/**
* 定时执行任务
*/
class
ScheduledExecutionService
(
name
:
String
=
"schedule"
)
:
IntentService
(
name
)
{
private
val
mDataBse
:
PushNotifiInfoDao
by
lazy
{
PushNotifiDataBase
.
getDatabase
(
application
).
pushInfoDao
()
}
override
fun
onHandleIntent
(
intent
:
Intent
?)
{
val
totalTime
:
Long
=
(
QmLog
.
getConfig
().
expiredDays
*
24
*
60
*
60
*
1000
).
toLong
()
mDataBse
.
deleteExpiredItems
((
System
.
currentTimeMillis
()
-
totalTime
))
}
}
\ No newline at end of file
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