Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sobot_module_Dev
Project
Overview
Details
Activity
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
sobot_android
Sobot_module_Dev
Commits
dc33c7b5
Commit
dc33c7b5
authored
Aug 14, 2023
by
zhengnw@sobot.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空字符判断
parent
778b97a5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
42 deletions
+95
-42
build.gradle
sobot_common/build.gradle
+2
-2
sobot-common-publish-mavencentral.gradle
sobot_common/sobot-common-publish-mavencentral.gradle
+1
-1
SobotCommonDao.java
...c/main/java/com/sobot/common/login/db/SobotCommonDao.java
+91
-38
build.gradle
sobot_widget/build.gradle
+1
-1
No files found.
sobot_common/build.gradle
View file @
dc33c7b5
...
...
@@ -32,12 +32,12 @@ dependencies {
// api project(':sobot_network')
// api project(':sobot_gson')
api
'com.sobot.library:utils:1.1.
1
'
api
'com.sobot.library:utils:1.1.
2
'
api
'com.sobot.library:picture:1.1.4'
api
'com.sobot.library:net:1.2.0'
api
'com.sobot.library:gson:1.1.1'
// api 'com.sobot.library:utils:1.1.
1
'
// api 'com.sobot.library:utils:1.1.
2
'
// api 'com.sobot.library:picture_x:1.1.4'
// api 'com.sobot.library:net:1.2.0'
// api 'com.sobot.library:gson:1.1.1'
...
...
sobot_common/sobot-common-publish-mavencentral.gradle
View file @
dc33c7b5
...
...
@@ -13,7 +13,7 @@ ext {
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_ARTIFACT_ID
=
'sobotcommon'
//项目名
// PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名
PUBLISH_VERSION
=
'1.3.
5
'
//版本号
PUBLISH_VERSION
=
'1.3.
6
'
//版本号
}
...
...
sobot_common/src/main/java/com/sobot/common/login/db/SobotCommonDao.java
View file @
dc33c7b5
...
...
@@ -30,7 +30,11 @@ public abstract class SobotCommonDao<T> {
public
SQLiteDatabase
openWriter
()
{
try
{
return
helper
.
getWritableDatabase
();
if
(
helper
!=
null
)
{
return
helper
.
getWritableDatabase
();
}
else
{
return
null
;
}
}
catch
(
Exception
e
)
{
//ignore
}
...
...
@@ -42,7 +46,9 @@ public abstract class SobotCommonDao<T> {
if
(
database
!=
null
&&
database
.
isOpen
())
database
.
close
();
}
/** 插入一条记录 */
/**
* 插入一条记录
*/
public
boolean
insert
(
T
t
)
{
if
(
t
==
null
)
return
false
;
if
(
database
==
null
)
return
false
;
...
...
@@ -55,7 +61,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -67,12 +73,16 @@ public abstract class SobotCommonDao<T> {
return
false
;
}
/** 插入一条记录 */
/**
* 插入一条记录
*/
public
long
insert
(
SQLiteDatabase
database
,
T
t
)
{
return
database
.
insert
(
getTableName
(),
null
,
getContentValues
(
t
));
}
/** 插入多条记录 */
/**
* 插入多条记录
*/
public
boolean
insert
(
List
<
T
>
ts
)
{
if
(
ts
==
null
)
return
false
;
if
(
database
==
null
)
return
false
;
...
...
@@ -87,7 +97,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -107,23 +117,29 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
return
false
;
}
}
/** 删除所有数据 */
/**
* 删除所有数据
*/
public
boolean
deleteAll
()
{
return
delete
(
null
,
null
);
}
/** 删除所有数据 */
/**
* 删除所有数据
*/
public
long
deleteAll
(
SQLiteDatabase
database
)
{
return
delete
(
database
,
null
,
null
);
}
/** 根据条件删除数据库中的数据 */
/**
* 根据条件删除数据库中的数据
*/
public
boolean
delete
(
String
whereClause
,
String
[]
whereArgs
)
{
if
(
database
==
null
)
return
false
;
long
start
=
System
.
currentTimeMillis
();
...
...
@@ -135,7 +151,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -147,7 +163,9 @@ public abstract class SobotCommonDao<T> {
return
false
;
}
/** 根据条件删除数据库中的数据 */
/**
* 根据条件删除数据库中的数据
*/
public
long
delete
(
SQLiteDatabase
database
,
String
whereClause
,
String
[]
whereArgs
)
{
return
database
.
delete
(
getTableName
(),
whereClause
,
whereArgs
);
}
...
...
@@ -165,7 +183,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -198,7 +216,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -225,7 +243,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -255,7 +273,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -275,13 +293,15 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
return
false
;
}
}
/** 更新一条记录 */
/**
* 更新一条记录
*/
public
boolean
update
(
T
t
,
String
whereClause
,
String
[]
whereArgs
)
{
if
(
t
==
null
)
return
false
;
if
(
database
==
null
)
return
false
;
...
...
@@ -294,7 +314,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -306,12 +326,16 @@ public abstract class SobotCommonDao<T> {
return
false
;
}
/** 更新一条记录 */
/**
* 更新一条记录
*/
public
long
update
(
SQLiteDatabase
database
,
T
t
,
String
whereClause
,
String
[]
whereArgs
)
{
return
database
.
update
(
getTableName
(),
getContentValues
(
t
),
whereClause
,
whereArgs
);
}
/** 更新一条记录 */
/**
* 更新一条记录
*/
public
boolean
update
(
ContentValues
contentValues
,
String
whereClause
,
String
[]
whereArgs
)
{
if
(
database
==
null
)
return
false
;
long
start
=
System
.
currentTimeMillis
();
...
...
@@ -323,7 +347,7 @@ public abstract class SobotCommonDao<T> {
return
true
;
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -335,29 +359,39 @@ public abstract class SobotCommonDao<T> {
return
false
;
}
/** 更新一条记录 */
/**
* 更新一条记录
*/
public
long
update
(
SQLiteDatabase
database
,
ContentValues
contentValues
,
String
whereClause
,
String
[]
whereArgs
)
{
return
database
.
update
(
getTableName
(),
contentValues
,
whereClause
,
whereArgs
);
}
/** 查询并返回所有对象的集合 */
/**
* 查询并返回所有对象的集合
*/
public
List
<
T
>
queryAll
(
SQLiteDatabase
database
)
{
return
query
(
database
,
null
,
null
);
}
/** 按条件查询对象并返回集合 */
/**
* 按条件查询对象并返回集合
*/
public
List
<
T
>
query
(
SQLiteDatabase
database
,
String
selection
,
String
[]
selectionArgs
)
{
return
query
(
database
,
null
,
selection
,
selectionArgs
,
null
,
null
,
null
,
null
);
}
/** 查询满足条件的一个结果 */
/**
* 查询满足条件的一个结果
*/
public
T
queryOne
(
SQLiteDatabase
database
,
String
selection
,
String
[]
selectionArgs
)
{
List
<
T
>
query
=
query
(
database
,
null
,
selection
,
selectionArgs
,
null
,
null
,
null
,
"1"
);
if
(
query
.
size
()
>
0
)
return
query
.
get
(
0
);
return
null
;
}
/** 按条件查询对象并返回集合 */
/**
* 按条件查询对象并返回集合
*/
public
List
<
T
>
query
(
SQLiteDatabase
database
,
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
List
<
T
>
list
=
new
ArrayList
<>();
Cursor
cursor
=
null
;
...
...
@@ -368,7 +402,7 @@ public abstract class SobotCommonDao<T> {
}
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
closeDatabase
(
null
,
cursor
);
...
...
@@ -376,17 +410,23 @@ public abstract class SobotCommonDao<T> {
return
list
;
}
/** 查询并返回所有对象的集合 */
/**
* 查询并返回所有对象的集合
*/
public
List
<
T
>
queryAll
()
{
return
query
(
null
,
null
);
}
/** 按条件查询对象并返回集合 */
/**
* 按条件查询对象并返回集合
*/
public
List
<
T
>
query
(
String
selection
,
String
[]
selectionArgs
)
{
return
query
(
null
,
selection
,
selectionArgs
,
null
,
null
,
null
,
null
);
}
/** 查询满足条件的一个结果 */
/**
* 查询满足条件的一个结果
*/
public
T
queryOne
(
String
selection
,
String
[]
selectionArgs
)
{
long
start
=
System
.
currentTimeMillis
();
List
<
T
>
query
=
query
(
null
,
selection
,
selectionArgs
,
null
,
null
,
null
,
"1"
);
...
...
@@ -396,9 +436,14 @@ public abstract class SobotCommonDao<T> {
return
query
.
size
()
>
0
?
query
.
get
(
0
)
:
null
;
}
/** 按条件查询对象并返回集合 */
/**
* 按条件查询对象并返回集合
*/
public
List
<
T
>
query
(
String
[]
columns
,
String
selection
,
String
[]
selectionArgs
,
String
groupBy
,
String
having
,
String
orderBy
,
String
limit
)
{
if
(
database
==
null
)
{
this
.
database
=
openWriter
();
}
if
(
database
==
null
)
{
return
new
ArrayList
<>();
}
long
start
=
System
.
currentTimeMillis
();
...
...
@@ -414,7 +459,7 @@ public abstract class SobotCommonDao<T> {
database
.
setTransactionSuccessful
();
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
closeDatabase
(
null
,
cursor
);
...
...
@@ -431,7 +476,9 @@ public abstract class SobotCommonDao<T> {
void
call
(
SQLiteDatabase
database
);
}
/** 用于给外界提供事物开启的模板 */
/**
* 用于给外界提供事物开启的模板
*/
public
void
startTransaction
(
Action
action
)
{
if
(
database
==
null
)
return
;
lock
.
lock
();
...
...
@@ -441,7 +488,7 @@ public abstract class SobotCommonDao<T> {
database
.
setTransactionSuccessful
();
}
catch
(
Exception
e
)
{
if
(
isDebug
)
{
Log
.
e
(
TAG
,
""
,
e
);
Log
.
e
(
TAG
,
""
,
e
);
}
}
finally
{
database
.
endTransaction
();
...
...
@@ -449,14 +496,20 @@ public abstract class SobotCommonDao<T> {
}
}
/** 获取对应的表名 */
/**
* 获取对应的表名
*/
public
abstract
String
getTableName
();
public
abstract
void
unInit
();
/** 将Cursor解析成对应的JavaBean */
/**
* 将Cursor解析成对应的JavaBean
*/
public
abstract
T
parseCursorToBean
(
Cursor
cursor
);
/** 需要替换的列 */
/**
* 需要替换的列
*/
public
abstract
ContentValues
getContentValues
(
T
t
);
}
sobot_widget/build.gradle
View file @
dc33c7b5
...
...
@@ -14,7 +14,7 @@ dependencies {
api
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
compileOnly
'com.android.support:appcompat-v7:28.0.0'
compileOnly
'com.android.support:recyclerview-v7:28.0.0'
api
'com.sobot.library:utils:1.1.
1
'
api
'com.sobot.library:utils:1.1.
2
'
}
...
...
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