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
5f1a0bb8
Commit
5f1a0bb8
authored
Sep 22, 2020
by
王雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增push数据库
parent
b79ec945
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
141 additions
and
3 deletions
+141
-3
build.gradle
build.gradle
+1
-0
build.gradle
log/build.gradle
+14
-1
LogInit.kt
log/src/main/java/com/qimai/log/LogInit.kt
+1
-1
UploadConfig.kt
log/src/main/java/com/qimai/log/UploadConfig.kt
+1
-1
AppDataBaseVm.kt
log/src/main/java/com/qimai/log/database/AppDataBaseVm.kt
+28
-0
PushNotifiDataBase.kt
...rc/main/java/com/qimai/log/database/PushNotifiDataBase.kt
+38
-0
PushNotifiInfo.kt
log/src/main/java/com/qimai/log/database/PushNotifiInfo.kt
+21
-0
PushNotifiInfoDao.kt
...src/main/java/com/qimai/log/database/PushNotifiInfoDao.kt
+16
-0
FloatsExtension.kt
.../src/main/java/com/qimai/android/tools/FloatsExtension.kt
+21
-0
No files found.
build.gradle
View file @
5f1a0bb8
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
buildscript
{
buildscript
{
ext
.
kotlin_version
=
'1.3.60'
ext
.
kotlin_version
=
'1.3.60'
ext
.
lintVersion
=
'26.5.0'
ext
.
lintVersion
=
'26.5.0'
ext
.
lifecycle_version
=
"2.2.5"
repositories
{
repositories
{
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
// 阿里云镜像
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public/'
}
// 阿里云镜像
...
...
log/build.gradle
View file @
5f1a0bb8
...
@@ -2,6 +2,7 @@ apply plugin: 'com.android.library'
...
@@ -2,6 +2,7 @@ apply plugin: 'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
apply
plugin:
'kotlin-android-extensions'
apply
plugin:
"com.whl.gradle-publish-plugin"
apply
plugin:
"com.whl.gradle-publish-plugin"
apply
plugin:
'kotlin-kapt'
android
{
android
{
compileSdkVersion
29
compileSdkVersion
29
...
@@ -47,10 +48,22 @@ dependencies {
...
@@ -47,10 +48,22 @@ dependencies {
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'
implementation
'com.tencent.mars:mars-xlog:1.2.4'
// For Kotlin use kapt instead of annotationProcessor (注意这个注释)
kapt
"androidx.room:room-compiler:$lifecycle_version"
implementation
"androidx.room:room-runtime:$lifecycle_version"
kapt
"androidx.room:room-compiler:$lifecycle_version"
implementation
"androidx.room:room-ktx:$lifecycle_version"
api
"androidx.lifecycle:lifecycle-extensions:2.2.0"
api
"androidx.lifecycle:lifecycle-runtime:2.2.0"
annotationProcessor
"androidx.lifecycle:lifecycle-compiler:2.2.0"
kapt
"androidx.lifecycle:lifecycle-compiler:2.2.0"
api
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
api
"androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
}
}
group
'com.qmai.android.log'
group
'com.qmai.android.log'
version
'1.0.
0
-SNAPSHOT'
version
'1.0.
1
-SNAPSHOT'
gradlePublish
{
gradlePublish
{
...
...
log/src/main/java/com/qimai/log/LogInit.kt
View file @
5f1a0bb8
...
@@ -29,7 +29,7 @@ class LogInit private constructor() {
...
@@ -29,7 +29,7 @@ class LogInit private constructor() {
logConfig
.
logdir
=
cachePath
logConfig
.
logdir
=
cachePath
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
.
cachedir
=
cachePath
logConfig
.
cachedays
=
0
logConfig
.
cachedays
=
0
...
...
log/src/main/java/com/qimai/log/UploadConfig.kt
View file @
5f1a0bb8
...
@@ -3,7 +3,7 @@ package com.qimai.log
...
@@ -3,7 +3,7 @@ package com.qimai.log
import
android.os.Parcelable
import
android.os.Parcelable
/**
/**
* @tag 名字
* @tag
文件
名字
*/
*/
class
UploadConfig
(
var
tag
:
String
):
java
.
io
.
Serializable
{
class
UploadConfig
(
var
tag
:
String
):
java
.
io
.
Serializable
{
...
...
log/src/main/java/com/qimai/log/database/AppDataBaseVm.kt
0 → 100644
View file @
5f1a0bb8
package
com.qimai.log.database
import
android.app.Application
import
androidx.lifecycle.AndroidViewModel
import
androidx.lifecycle.viewModelScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
/**
* 获取数据库操作类
*/
class
AppDataBaseVm
(
application
:
Application
)
:
AndroidViewModel
(
application
)
{
private
val
mDataBse
:
PushNotifiInfoDao
by
lazy
{
PushNotifiDataBase
.
getDatabase
(
application
).
pushInfoDao
()
}
fun
insertPushInfo
(
notifiInfo
:
PushNotifiInfo
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
mDataBse
.
insert
(
notifiInfo
)
}
}
fun
updatePushInfo
(
msg_id
:
String
,
status
:
Boolean
,
errorMsg
:
String
?
=
null
)
{
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
mDataBse
.
updateStatus
(
msg_id
,
status
,
errorMsg
)
}
}
}
\ No newline at end of file
log/src/main/java/com/qimai/log/database/PushNotifiDataBase.kt
0 → 100644
View file @
5f1a0bb8
package
com.qimai.log.database
import
android.content.Context
import
androidx.room.Database
import
androidx.room.Room
import
androidx.room.RoomDatabase
/**
*
*/
@Database
(
entities
=
[
PushNotifiInfo
::
class
],
version
=
1
,
exportSchema
=
false
)
abstract
class
PushNotifiDataBase
:
RoomDatabase
()
{
abstract
fun
pushInfoDao
():
PushNotifiInfoDao
companion
object
{
// Singleton prevents multiple instances of database opening at the
// same time.
@Volatile
private
var
INSTANCE
:
PushNotifiDataBase
?
=
null
fun
getDatabase
(
context
:
Context
):
PushNotifiDataBase
{
val
tempInstance
=
INSTANCE
if
(
tempInstance
!=
null
)
{
return
tempInstance
}
synchronized
(
this
)
{
val
instance
=
Room
.
databaseBuilder
(
context
.
applicationContext
,
PushNotifiDataBase
::
class
.
java
,
"push_database"
).
build
()
INSTANCE
=
instance
return
instance
}
}
}
}
\ No newline at end of file
log/src/main/java/com/qimai/log/database/PushNotifiInfo.kt
0 → 100644
View file @
5f1a0bb8
package
com.qimai.log.database
import
androidx.room.ColumnInfo
import
androidx.room.Entity
import
androidx.room.PrimaryKey
@Entity
(
tableName
=
"push_info"
)
data class
PushNotifiInfo
@JvmOverloads
constructor
(
@PrimaryKey
@ColumnInfo
(
name
=
"msg_id"
)
val
msg_id
:
String
,
//消息id
@ColumnInfo
(
name
=
"status"
)
var
status
:
Boolean
,
// 状态
@ColumnInfo
(
name
=
"error_msg"
)
var
errorMsg
:
String
?
=
null
,
//错误原因
@ColumnInfo
(
name
=
"push_type"
)
val
pushType
:
String
,
//用的什么推送
@ColumnInfo
(
name
=
"rawText"
)
var
rawText
:
String
?
=
null
,
//原始信息
@ColumnInfo
(
name
=
"time"
)
var
time
:
String
?
=
null
,
//格式化时间
@ColumnInfo
(
name
=
"device_id"
)
var
deviceId
:
String
?
=
null
,
//推送的devicedId
@ColumnInfo
(
name
=
"model"
)
var
model
:
String
?
=
null
,
//手机型号
@ColumnInfo
(
name
=
"app_version"
)
var
version
:
String
?
=
null
,
//app版本
@ColumnInfo
(
name
=
"time_stamp"
)
var
timeStamp
:
String
?=
null
//时间戳
)
{
}
\ No newline at end of file
log/src/main/java/com/qimai/log/database/PushNotifiInfoDao.kt
0 → 100644
View file @
5f1a0bb8
package
com.qimai.log.database
import
androidx.room.*
/**
* 数据库操作类
*/
@Dao
interface
PushNotifiInfoDao
{
@Insert
(
onConflict
=
OnConflictStrategy
.
IGNORE
)
suspend
fun
insert
(
word
:
PushNotifiInfo
)
@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
)
}
\ No newline at end of file
tools/src/main/java/com/qimai/android/tools/FloatsExtension.kt
0 → 100644
View file @
5f1a0bb8
package
com.qimai.android.tools
import
android.content.res.Resources
import
android.util.TypedValue
//float值转为sp像素
val
Float
.
sp
get
()
=
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
this
,
Resources
.
getSystem
().
displayMetrics
)
//float像素值转为dp
val
Float
.
dp
get
()
=
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_SP
,
this
,
Resources
.
getSystem
().
displayMetrics
)
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