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
5ba770c4
Commit
5ba770c4
authored
Jan 16, 2024
by
zhengnw@sobot.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widget 1.1.5 添加ActivityLifeCycle 检测app被系统回收(强杀)状态
parent
eaa6feb8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
537 additions
and
11 deletions
+537
-11
build.gradle
sobot_common/build.gradle
+2
-2
sobot-common-publish-mavencentral.gradle
sobot_common/sobot-common-publish-mavencentral.gradle
+1
-1
SobotLoginTools.java
...src/main/java/com/sobot/common/login/SobotLoginTools.java
+44
-7
HostManager.java
.../src/main/java/com/sobot/common/login/db/HostManager.java
+86
-0
LoginUserManager.java
...main/java/com/sobot/common/login/db/LoginUserManager.java
+150
-0
ServiceInfoManager.java
...in/java/com/sobot/common/login/db/ServiceInfoManager.java
+122
-0
sobot-widget-publish-mavencentral.gradle
sobot_widget/sobot-widget-publish-mavencentral.gradle
+1
-1
SobotActivityLifeCycle.java
...com/sobot/widget/myappliction/SobotActivityLifeCycle.java
+125
-0
SobotAppStatusConstant.java
...com/sobot/widget/myappliction/SobotAppStatusConstant.java
+6
-0
No files found.
sobot_common/build.gradle
View file @
5ba770c4
...
@@ -11,7 +11,7 @@ android {
...
@@ -11,7 +11,7 @@ android {
//这里就是打jar包
//这里就是打jar包
task
makeJar
(
type:
Copy
)
{
task
makeJar
(
type:
Copy
)
{
//删除旧的jar包
//删除旧的jar包
delete
'build/libs/sobot_common_1.5.
1
.jar'
delete
'build/libs/sobot_common_1.5.
2
.jar'
//原地址
//原地址
from
(
'build/intermediates/packaged-classes/release/'
)
from
(
'build/intermediates/packaged-classes/release/'
)
//导出jar包的地址
//导出jar包的地址
...
@@ -19,7 +19,7 @@ android {
...
@@ -19,7 +19,7 @@ android {
//包含的jar包
//包含的jar包
include
(
'classes.jar'
)
include
(
'classes.jar'
)
//重命名jar包为mysdk
//重命名jar包为mysdk
rename
(
'classes.jar'
,
'sobot_common_1.5.
1
.jar'
)
rename
(
'classes.jar'
,
'sobot_common_1.5.
2
.jar'
)
}
}
makeJar
.
dependsOn
(
build
)
makeJar
.
dependsOn
(
build
)
}
}
...
...
sobot_common/sobot-common-publish-mavencentral.gradle
View file @
5ba770c4
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext
{
ext
{
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_ARTIFACT_ID
=
'sobotcommon'
//项目名
PUBLISH_ARTIFACT_ID
=
'sobotcommon'
//项目名
PUBLISH_VERSION
=
'1.5.
1
'
//版本号
PUBLISH_VERSION
=
'1.5.
2
'
//版本号
}
}
...
...
sobot_common/src/main/java/com/sobot/common/login/SobotLoginTools.java
View file @
5ba770c4
...
@@ -5,6 +5,9 @@ import android.text.TextUtils;
...
@@ -5,6 +5,9 @@ import android.text.TextUtils;
import
com.sobot.common.login.callback.SobotResultBlock
;
import
com.sobot.common.login.callback.SobotResultBlock
;
import
com.sobot.common.login.callback.SobotResultCode
;
import
com.sobot.common.login.callback.SobotResultCode
;
import
com.sobot.common.login.db.HostManager
;
import
com.sobot.common.login.db.LoginUserManager
;
import
com.sobot.common.login.db.ServiceInfoManager
;
import
com.sobot.common.login.model.HostModel
;
import
com.sobot.common.login.model.HostModel
;
import
com.sobot.common.login.model.LoginUserEntity
;
import
com.sobot.common.login.model.LoginUserEntity
;
import
com.sobot.common.login.model.ServiceFunctionVoModel
;
import
com.sobot.common.login.model.ServiceFunctionVoModel
;
...
@@ -31,13 +34,12 @@ import java.util.Map;
...
@@ -31,13 +34,12 @@ import java.util.Map;
*/
*/
public
class
SobotLoginTools
{
public
class
SobotLoginTools
{
//内部类单例
//内部类单例
private
SobotLoginTools
()
{
private
SobotLoginTools
()
{
}
}
public
static
SobotLoginTools
getInstance
()
{
public
static
SobotLoginTools
getInstance
()
{
return
SobotLoginTools
.
SobotLoginTools
Holder
.
instance
;
return
SobotLoginToolsHolder
.
instance
;
}
}
private
static
class
SobotLoginToolsHolder
{
private
static
class
SobotLoginToolsHolder
{
...
@@ -48,37 +50,72 @@ public class SobotLoginTools {
...
@@ -48,37 +50,72 @@ public class SobotLoginTools {
private
LoginUserEntity
user
;
private
LoginUserEntity
user
;
public
LoginUserEntity
getLoginUser
()
{
public
LoginUserEntity
getLoginUser
()
{
if
(
user
==
null
||
user
.
getAid
()
==
null
)
{
user
=
LoginUserManager
.
getInstance
().
getCurUser
();
}
return
user
;
return
user
;
}
}
public
void
setLoginUser
(
LoginUserEntity
newUser
)
{
public
void
setLoginUser
(
LoginUserEntity
newUser
)
{
if
(
newUser
!=
null
)
{
LoginUserManager
.
getInstance
().
deleteAll
();
newUser
.
setLogin_time
(
System
.
currentTimeMillis
());
}
user
=
newUser
;
user
=
newUser
;
if
(
user
!=
null
)
{
user
.
setLogin_time
(
System
.
currentTimeMillis
());
LoginUserManager
.
getInstance
().
insert
(
user
);
}
else
{
HostManager
.
getInstance
().
deleteAll
();
ServiceInfoManager
.
getInstance
().
deleteAll
();
}
}
}
private
SobotServiceInfoModel
mServiceInfoModel
;
private
SobotServiceInfoModel
mServiceInfoModel
;
public
SobotServiceInfoModel
getServiceInfo
()
{
public
SobotServiceInfoModel
getServiceInfo
()
{
if
(
mServiceInfoModel
==
null
)
{
mServiceInfoModel
=
ServiceInfoManager
.
getInstance
().
getInfo
();
}
return
mServiceInfoModel
;
return
mServiceInfoModel
;
}
}
public
void
setServiceInfo
(
SobotServiceInfoModel
newServiceInfo
)
{
public
void
setServiceInfo
(
SobotServiceInfoModel
newServiceInfo
)
{
ServiceInfoManager
.
getInstance
().
deleteAll
();
mServiceInfoModel
=
newServiceInfo
;
mServiceInfoModel
=
newServiceInfo
;
if
(
mServiceInfoModel
!=
null
)
{
ServiceInfoManager
.
getInstance
().
insert
(
mServiceInfoModel
);
}
else
{
ServiceInfoManager
.
getInstance
().
deleteAll
();
}
}
}
private
HostModel
mHostModel
;
private
HostModel
mHostModel
;
//获取域名
//获取域名
public
HostModel
getHostInfo
()
{
public
HostModel
getHostModel
()
{
if
(
mHostModel
==
null
)
{
mHostModel
=
HostManager
.
getInstance
().
getHost
();
}
return
mHostModel
;
return
mHostModel
;
}
}
public
void
setHostInfo
(
HostModel
newHostModel
)
{
public
void
setHostModel
(
HostModel
newHostModel
)
{
HostManager
.
getInstance
().
deleteAll
();
if
(
newHostModel
!=
null
)
{
if
((
newHostModel
.
getHost
().
contains
(
"test-branche1"
))
||
(
newHostModel
.
getHost
().
contains
(
"api-c.sobot.com"
)
||
newHostModel
.
getHost
().
contains
(
"api-c.soboten.com"
))
&&
(!
newHostModel
.
getHost
().
contains
(
"api-c.sobot.com/text"
)
&&
!
newHostModel
.
getHost
().
contains
(
"api-c.soboten.com/text"
)))
{
if
(!
newHostModel
.
getHost
().
endsWith
(
"/"
))
{
newHostModel
.
setHost
(
newHostModel
.
getHost
()
+
"/text/"
);
}
else
{
newHostModel
.
setHost
(
newHostModel
.
getHost
()
+
"text/"
);
}
}
}
mHostModel
=
newHostModel
;
mHostModel
=
newHostModel
;
if
(
mHostModel
!=
null
)
{
HostManager
.
getInstance
().
insert
(
mHostModel
);
}
else
{
HostManager
.
getInstance
().
deleteAll
();
}
}
}
//呼叫 v6 获取 accessToken
//呼叫 v6 获取 accessToken
...
...
sobot_common/src/main/java/com/sobot/common/login/db/HostManager.java
0 → 100644
View file @
5ba770c4
package
com
.
sobot
.
common
.
login
.
db
;
import
android.annotation.SuppressLint
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.database.Cursor
;
import
com.sobot.common.login.model.HostModel
;
import
com.sobot.common.utils.SobotGlobalContext
;
import
java.util.List
;
/**
* 域名 操作类
*/
public
class
HostManager
extends
SobotCommonDao
<
HostModel
>
{
private
HostManager
(
Context
context
)
{
super
(
new
SobotCommonDBHelper
(
context
));
}
//volatile关键字确保多线程下正确处理
private
volatile
static
HostManager
mInstance
;
public
static
HostManager
getInstance
()
{
//第一次判空
if
(
mInstance
==
null
)
{
//进入同步区域
synchronized
(
HostManager
.
class
)
{
//第二次判空
if
(
mInstance
==
null
)
{
mInstance
=
new
HostManager
(
SobotGlobalContext
.
getAppContext
());
}
}
}
return
mInstance
;
}
@Override
public
String
getTableName
()
{
return
SobotCommonDBHelper
.
TABLE_SOBOT_HOST
;
}
@Override
public
void
unInit
()
{
}
@SuppressLint
(
"Range"
)
@Override
public
HostModel
parseCursorToBean
(
Cursor
cursor
)
{
HostModel
model
=
new
HostModel
();
model
.
setDesc
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"hostDesc"
)));
model
.
setHost
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"host"
)));
model
.
setJanussipProxy
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"janussipProxy"
)));
model
.
setJanusSocket
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"janusSocket"
)));
model
.
setOpenApiHost
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"openApiHost"
)));
model
.
setStompSocket
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"stompSocket"
)));
return
model
;
}
@Override
public
ContentValues
getContentValues
(
HostModel
hostModel
)
{
ContentValues
contentValues
=
new
ContentValues
();
contentValues
.
put
(
"hostDesc"
,
hostModel
.
getDesc
());
contentValues
.
put
(
"host"
,
hostModel
.
getHost
());
contentValues
.
put
(
"janussipProxy"
,
hostModel
.
getJanussipProxy
());
contentValues
.
put
(
"janusSocket"
,
hostModel
.
getJanusSocket
());
contentValues
.
put
(
"openApiHost"
,
hostModel
.
getOpenApiHost
());
contentValues
.
put
(
"stompSocket"
,
hostModel
.
getStompSocket
());
return
contentValues
;
}
public
void
saveHost
(
HostModel
host
)
{
deleteAll
();
insert
(
host
);
}
/**
* 获取最近用户记录 按日期倒序
*/
public
HostModel
getHost
()
{
List
<
HostModel
>
list
=
query
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
return
list
.
size
()
>
0
?
list
.
get
(
0
)
:
null
;
}
}
sobot_common/src/main/java/com/sobot/common/login/db/LoginUserManager.java
0 → 100644
View file @
5ba770c4
package
com
.
sobot
.
common
.
login
.
db
;
import
android.annotation.SuppressLint
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.database.Cursor
;
import
com.sobot.common.login.model.LoginUserEntity
;
import
com.sobot.common.utils.SobotGlobalContext
;
import
com.sobot.gson.SobotGsonUtil
;
import
com.sobot.utils.SobotStringUtils
;
import
java.util.List
;
import
java.util.Map
;
/**
* 登录用户信息 操作类
*/
public
class
LoginUserManager
extends
SobotCommonDao
<
LoginUserEntity
>
{
private
LoginUserManager
(
Context
context
)
{
super
(
new
SobotCommonDBHelper
(
context
));
}
//volatile关键字确保多线程下正确处理
private
volatile
static
LoginUserManager
mInstance
;
public
static
LoginUserManager
getInstance
()
{
//第一次判空
if
(
mInstance
==
null
)
{
//进入同步区域
synchronized
(
LoginUserManager
.
class
)
{
//第二次判空
if
(
mInstance
==
null
)
{
mInstance
=
new
LoginUserManager
(
SobotGlobalContext
.
getAppContext
());
}
}
}
return
mInstance
;
}
@Override
public
String
getTableName
()
{
return
SobotCommonDBHelper
.
TABLE_LOGIN_USER
;
}
@Override
public
void
unInit
()
{
}
@SuppressLint
(
"Range"
)
@Override
public
LoginUserEntity
parseCursorToBean
(
Cursor
cursor
)
{
LoginUserEntity
model
=
new
LoginUserEntity
();
model
.
setTempId
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"tempId"
)));
model
.
setNickName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"nickName"
)));
model
.
setStaffName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"staffName"
)));
model
.
setMaxServiceCount
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"maxServiceCount"
)));
model
.
setBlackFunction
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"blackFunction"
)));
model
.
setTransferFunction
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"transferFunction"
)));
String
ticketFunction
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"ticketFunction"
));
if
(!
SobotStringUtils
.
isEmpty
(
ticketFunction
)){
Map
<
String
,
Boolean
>
map
=
SobotGsonUtil
.
jsonToMaps
(
ticketFunction
);
model
.
setTicketFunction
(
map
);
}
model
.
setFace
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"face"
)));
model
.
setCompanyName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"companyName"
)));
model
.
setAppKey
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"appKey"
)));
model
.
setSid
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"sid"
)));
model
.
setPu
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"pu"
)));
model
.
setPuid
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"puid"
)));
model
.
setToken
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"token"
)));
model
.
setCusRoleName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"cusRoleName"
)));
model
.
setAid
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"aid"
)));
model
.
setCenterNumber
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"centerNumber"
)));
model
.
setAccountStatus
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"accountStatus"
)));
model
.
setImFlag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"imFlag"
)));
model
.
setCusRoleId
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"cusRoleId"
)));
model
.
setStatus
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"status"
)));
model
.
setTopFlag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"topFlag"
)));
model
.
setSortFlag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"sortFlag"
)));
model
.
setFuseWork
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"fuseWork"
)));
model
.
setCallV6Flag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"callV6Flag"
)));
model
.
setCallV1Flag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"callV1Flag"
)));
model
.
setTransferAuditFlag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"transferAuditFlag"
)));
model
.
setKbVersion
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"kbVersion"
))
+
""
);
model
.
setCompanyId
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"companyId"
)));
model
.
setLanguage
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"local_language"
)));
model
.
setAccess_token
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
LoginUserEntity
.
ACCESS_TOKEN
)));
model
.
setLogin_time
(
cursor
.
getLong
(
cursor
.
getColumnIndex
(
LoginUserEntity
.
LOGIN_TIME
)));
return
model
;
}
@Override
public
ContentValues
getContentValues
(
LoginUserEntity
userAccount
)
{
ContentValues
contentValues
=
new
ContentValues
();
contentValues
.
put
(
"_id"
,
8888
);
contentValues
.
put
(
"tempId"
,
userAccount
.
getTempId
());
contentValues
.
put
(
"nickName"
,
userAccount
.
getNickName
());
contentValues
.
put
(
"staffName"
,
userAccount
.
getStaffName
());
contentValues
.
put
(
"maxServiceCount"
,
userAccount
.
getMaxServiceCount
());
contentValues
.
put
(
"blackFunction"
,
userAccount
.
getBlackFunction
());
contentValues
.
put
(
"transferFunction"
,
userAccount
.
getTransferFunction
());
if
(
userAccount
.
getTicketFunction
()
!=
null
)
{
contentValues
.
put
(
"ticketFunction"
,
SobotGsonUtil
.
beanToJson
(
userAccount
.
getTicketFunction
()));
}
contentValues
.
put
(
"face"
,
userAccount
.
getFace
());
contentValues
.
put
(
"companyName"
,
userAccount
.
getCompanyName
());
contentValues
.
put
(
"appKey"
,
userAccount
.
getAppKey
());
contentValues
.
put
(
"sid"
,
userAccount
.
getSid
());
contentValues
.
put
(
"pu"
,
userAccount
.
getPu
());
contentValues
.
put
(
"puid"
,
userAccount
.
getPuid
());
contentValues
.
put
(
"token"
,
userAccount
.
getToken
());
contentValues
.
put
(
"cusRoleName"
,
userAccount
.
getCusRoleName
());
contentValues
.
put
(
"aid"
,
userAccount
.
getAid
());
contentValues
.
put
(
"centerNumber"
,
userAccount
.
getCenterNumber
());
contentValues
.
put
(
"accountStatus"
,
userAccount
.
getAccountStatus
());
contentValues
.
put
(
"imFlag"
,
userAccount
.
isImFlag
());
contentValues
.
put
(
"cusRoleId"
,
userAccount
.
getCusRoleId
());
contentValues
.
put
(
"status"
,
userAccount
.
getStatus
());
contentValues
.
put
(
"topFlag"
,
userAccount
.
getTopFlag
());
contentValues
.
put
(
"sortFlag"
,
userAccount
.
getSortFlag
());
contentValues
.
put
(
"fuseWork"
,
userAccount
.
getFuseWork
());
contentValues
.
put
(
"callV6Flag"
,
userAccount
.
getCallV6Flag
());
contentValues
.
put
(
"callV1Flag"
,
userAccount
.
getCallV1Flag
());
contentValues
.
put
(
"transferAuditFlag"
,
userAccount
.
getTransferAuditFlag
());
int
kbVersion
=
1
;
if
(
"6"
.
contains
(
SobotStringUtils
.
checkStringIsNull
(
userAccount
.
getKbVersion
())))
{
kbVersion
=
6
;
}
contentValues
.
put
(
"kbVersion"
,
kbVersion
);
contentValues
.
put
(
"companyId"
,
userAccount
.
getCompanyId
());
contentValues
.
put
(
"local_language"
,
userAccount
.
getLanguage
());
contentValues
.
put
(
LoginUserEntity
.
ACCESS_TOKEN
,
userAccount
.
getAccess_token
());
contentValues
.
put
(
LoginUserEntity
.
LOGIN_TIME
,
userAccount
.
getLogin_time
());
return
contentValues
;
}
public
void
saveUser
(
LoginUserEntity
user
)
{
insert
(
user
);
}
/**
* 获取最近用户记录 按日期倒序
*/
public
LoginUserEntity
getCurUser
()
{
List
<
LoginUserEntity
>
list
=
query
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
return
list
.
size
()
>
0
?
list
.
get
(
0
)
:
null
;
}
}
sobot_common/src/main/java/com/sobot/common/login/db/ServiceInfoManager.java
0 → 100644
View file @
5ba770c4
package
com
.
sobot
.
common
.
login
.
db
;
import
android.annotation.SuppressLint
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.database.Cursor
;
import
com.sobot.common.login.model.ServiceFunctionVoModel
;
import
com.sobot.common.login.model.SobotServiceInfoModel
;
import
com.sobot.common.utils.SobotGlobalContext
;
import
com.sobot.gson.SobotGsonUtil
;
import
com.sobot.gson.reflect.TypeToken
;
import
com.sobot.utils.SobotStringUtils
;
import
java.util.List
;
/**
* 坐席信息 操作类
*/
public
class
ServiceInfoManager
extends
SobotCommonDao
<
SobotServiceInfoModel
>
{
private
ServiceInfoManager
(
Context
context
)
{
super
(
new
SobotCommonDBHelper
(
context
));
}
//volatile关键字确保多线程下正确处理
private
volatile
static
ServiceInfoManager
mInstance
;
public
static
ServiceInfoManager
getInstance
()
{
//第一次判空
if
(
mInstance
==
null
)
{
//进入同步区域
synchronized
(
LoginUserManager
.
class
)
{
//第二次判空
if
(
mInstance
==
null
)
{
mInstance
=
new
ServiceInfoManager
(
SobotGlobalContext
.
getAppContext
());
}
}
}
return
mInstance
;
}
@Override
public
String
getTableName
()
{
return
SobotCommonDBHelper
.
TABLE_SERVICE_INFO
;
}
@Override
public
void
unInit
()
{
}
@SuppressLint
(
"Range"
)
@Override
public
SobotServiceInfoModel
parseCursorToBean
(
Cursor
cursor
)
{
SobotServiceInfoModel
model
=
new
SobotServiceInfoModel
();
model
.
setServiceId
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"serviceId"
)));
model
.
setServiceName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"serviceName"
)));
model
.
setCusRoleId
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"cusRoleId"
)));
model
.
setCusRoleName
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"cusRoleName"
)));
model
.
setServiceLanguage
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"serviceLanguage"
)));
model
.
setNewBossSwitch
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"newBossSwitch"
)));
model
.
setRegion
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"region"
)));
String
functionStr
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"functionStr"
));
if
(!
SobotStringUtils
.
isEmpty
(
functionStr
))
{
List
<
ServiceFunctionVoModel
>
list
=
SobotGsonUtil
.
jsonToBeans
(
functionStr
,
new
TypeToken
<
List
<
ServiceFunctionVoModel
>>()
{
}.
getType
());
model
.
setFunctionStr
(
list
);
}
model
.
setCompanyId
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"companyId"
)));
model
.
setCallV6Flag
(
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"callV6Flag"
)));
model
.
setLanguage
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"language"
)));
model
.
setTimezone
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"timezone"
)));
model
.
setTimezoneId
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"timezoneId"
)));
model
.
setPhoneNo
(
cursor
.
getString
(
cursor
.
getColumnIndex
(
"phoneNo"
)));
String
globalPermissions
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
"globalPermissions"
));
if
(!
SobotStringUtils
.
isEmpty
(
globalPermissions
))
{
List
<
String
>
globalPermissionslist
=
SobotGsonUtil
.
jsonToBeans
(
globalPermissions
,
new
TypeToken
<
List
<
String
>>()
{
}.
getType
());
model
.
setGlobalPermissions
(
globalPermissionslist
);
}
return
model
;
}
@Override
public
ContentValues
getContentValues
(
SobotServiceInfoModel
infoModel
)
{
ContentValues
contentValues
=
new
ContentValues
();
contentValues
.
put
(
"serviceId"
,
infoModel
.
getServiceId
());
contentValues
.
put
(
"serviceName"
,
infoModel
.
getServiceName
());
contentValues
.
put
(
"cusRoleId"
,
infoModel
.
getCusRoleId
());
contentValues
.
put
(
"cusRoleName"
,
infoModel
.
getCusRoleName
());
contentValues
.
put
(
"serviceLanguage"
,
infoModel
.
getServiceLanguage
());
contentValues
.
put
(
"newBossSwitch"
,
infoModel
.
getNewBossSwitch
());
contentValues
.
put
(
"region"
,
infoModel
.
getRegion
());
if
(!
SobotStringUtils
.
isEmpty
(
infoModel
.
getFunctionStr
()))
{
contentValues
.
put
(
"functionStr"
,
SobotGsonUtil
.
beanToJson
(
infoModel
.
getFunctionStr
()));
}
contentValues
.
put
(
"companyId"
,
infoModel
.
getCompanyId
());
contentValues
.
put
(
"callV6Flag"
,
infoModel
.
getCallV6Flag
());
contentValues
.
put
(
"language"
,
infoModel
.
getLanguage
());
contentValues
.
put
(
"timezone"
,
infoModel
.
getTimezone
());
contentValues
.
put
(
"timezoneId"
,
infoModel
.
getTimezoneId
());
contentValues
.
put
(
"phoneNo"
,
infoModel
.
getPhoneNo
());
if
(!
SobotStringUtils
.
isEmpty
(
infoModel
.
getGlobalPermissions
()))
{
contentValues
.
put
(
"globalPermissions"
,
SobotGsonUtil
.
beanToJson
(
infoModel
.
getGlobalPermissions
()));
}
return
contentValues
;
}
public
void
saveInfo
(
SobotServiceInfoModel
host
)
{
deleteAll
();
insert
(
host
);
}
/**
* 获取最近用户记录 按日期倒序
*/
public
SobotServiceInfoModel
getInfo
()
{
List
<
SobotServiceInfoModel
>
list
=
query
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
return
list
.
size
()
>
0
?
list
.
get
(
0
)
:
null
;
}
}
sobot_widget/sobot-widget-publish-mavencentral.gradle
View file @
5ba770c4
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext
{
ext
{
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_ARTIFACT_ID
=
'widget'
//项目名
PUBLISH_ARTIFACT_ID
=
'widget'
//项目名
PUBLISH_VERSION
=
'1.1.
4
'
//版本号
PUBLISH_VERSION
=
'1.1.
5
'
//版本号
}
}
...
...
sobot_widget/src/main/java/com/sobot/widget/myappliction/SobotActivityLifeCycle.java
0 → 100644
View file @
5ba770c4
package
com
.
sobot
.
widget
.
myappliction
;
import
android.app.Activity
;
import
android.app.Application
;
import
android.os.Bundle
;
import
android.util.Log
;
import
com.sobot.utils.SobotLogUtils
;
import
java.lang.ref.WeakReference
;
/**
* app 管理类
* 可判断 app被系统回收(强杀)状态;app是否前台
*/
public
class
SobotActivityLifeCycle
implements
Application
.
ActivityLifecycleCallbacks
{
//默认被初始化状态,被系统回收(强杀)状态
public
int
mAppStatus
=
SobotAppStatusConstant
.
STATUS_FORCE_KILLED
;
private
boolean
mPaused
=
true
;
private
boolean
mForeground
=
false
;
private
static
SobotActivityLifeCycle
sInstance
;
//当前Activity的弱引用
private
WeakReference
<
Activity
>
mActivityReference
;
protected
final
String
TAG
=
"SobotActivityLifeCycle"
;
public
static
final
int
ACTIVITY_ON_RESUME
=
0
;
public
static
final
int
ACTIVITY_ON_PAUSE
=
1
;
//打开的Activity数量统计
private
int
activityStartCount
=
0
;
private
SobotActivityLifeCycle
()
{
}
public
static
synchronized
SobotActivityLifeCycle
getInstance
()
{
if
(
sInstance
==
null
)
{
sInstance
=
new
SobotActivityLifeCycle
();
}
return
sInstance
;
}
/**
* 获取APP状态
*
* @return
*/
public
int
getAppStatus
()
{
return
mAppStatus
;
}
/**
* 设置APP状态
*
* @param appStatus
*/
public
void
setAppStatus
(
int
appStatus
)
{
this
.
mAppStatus
=
appStatus
;
}
public
Activity
getCurrentActivity
()
{
if
(
mActivityReference
!=
null
)
{
return
mActivityReference
.
get
();
}
return
null
;
}
public
boolean
isForground
()
{
return
mForeground
;
}
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
Log
.
d
(
TAG
,
activity
.
getLocalClassName
()
+
" "
+
"onActivityCreated"
);
mActivityReference
=
new
WeakReference
<
Activity
>(
activity
);
}
@Override
public
void
onActivityStarted
(
Activity
activity
)
{
Log
.
d
(
TAG
,
activity
.
getLocalClassName
()
+
" "
+
"onActivityStarted"
);
activityStartCount
++;
//数值从0变到1说明是从后台切到前台
if
(
activityStartCount
==
1
)
{
//从后台切到前台
SobotLogUtils
.
i
(
"从后台切到前台"
);
}
}
@Override
public
void
onActivityResumed
(
Activity
activity
)
{
String
activityName
=
activity
.
getClass
().
getName
();
mPaused
=
false
;
mForeground
=
true
;
mActivityReference
=
new
WeakReference
<
Activity
>(
activity
);
}
@Override
public
void
onActivityPaused
(
Activity
activity
)
{
//pause事件后是否在前台要分情况判断
mPaused
=
true
;
}
@Override
public
void
onActivityStopped
(
Activity
activity
)
{
Log
.
d
(
TAG
,
activity
.
getLocalClassName
()
+
" "
+
"onActivityStopped"
);
activityStartCount
--;
//数值从1到0说明是从前台切到后台
if
(
activityStartCount
==
0
)
{
//从前台切到后台
SobotLogUtils
.
i
(
"从前台切到后台"
);
}
}
@Override
public
void
onActivitySaveInstanceState
(
Activity
activity
,
Bundle
outState
)
{
}
@Override
public
void
onActivityDestroyed
(
Activity
activity
)
{
Log
.
d
(
TAG
,
activity
.
getLocalClassName
()
+
" "
+
"onActivityDestroyed"
);
}
}
sobot_widget/src/main/java/com/sobot/widget/myappliction/SobotAppStatusConstant.java
0 → 100644
View file @
5ba770c4
package
com
.
sobot
.
widget
.
myappliction
;
public
class
SobotAppStatusConstant
{
public
static
final
int
STATUS_FORCE_KILLED
=
-
1
;
//应用放在后台被强杀了
public
static
final
int
STATUS_NORMAL
=
1
;
//APP正常态
}
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