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
904a46ab
Commit
904a46ab
authored
Jan 18, 2024
by
zhengnw@sobot.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common 1.5.8 添加 sdk 退出登录
parent
3cd73d7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
MainActivity.java
app/src/main/java/com/sobot/moduletest/MainActivity.java
+10
-1
SobotLoginTools.java
...src/main/java/com/sobot/common/login/SobotLoginTools.java
+6
-3
No files found.
app/src/main/java/com/sobot/moduletest/MainActivity.java
View file @
904a46ab
...
@@ -9,6 +9,9 @@ import android.net.Uri;
...
@@ -9,6 +9,9 @@ import android.net.Uri;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.sobot.common.login.SobotLoginTools
;
import
com.sobot.common.login.callback.SobotResultBlock
;
import
com.sobot.common.login.callback.SobotResultCode
;
import
com.sobot.common.utils.SobotImageUtils
;
import
com.sobot.common.utils.SobotImageUtils
;
import
com.sobot.pictureframe.SobotBitmapUtil
;
import
com.sobot.pictureframe.SobotBitmapUtil
;
import
com.sobot.utils.SobotLogUtils
;
import
com.sobot.utils.SobotLogUtils
;
...
@@ -210,13 +213,19 @@ public class MainActivity extends SobotBaseActivity {
...
@@ -210,13 +213,19 @@ public class MainActivity extends SobotBaseActivity {
Map
<
String
,
String
>
headers1
=
new
HashMap
<>();
Map
<
String
,
String
>
headers1
=
new
HashMap
<>();
headers1
.
put
(
"language"
,
"zh"
);
headers1
.
put
(
"language"
,
"zh"
);
// SobotLoginTools.getInstance().doAppLogin(MainActivity.this,
MainActivity.this, "https://api-c.sobot.com/text","https://api-c.soboten.com/text", 8000, map1, headers1
, new SobotResultBlock() {
// SobotLoginTools.getInstance().doAppLogin(MainActivity.this,
getSobotBaseContext(), "https://api-c.sobot.com/text","https://api-c.soboten.com/text", 8000, map1, headers1,"zhengnw@sobot.com","znw123456"
, new SobotResultBlock() {
// @Override
// @Override
// public void resultBolok(SobotResultCode code, String msg, Object obj) {
// public void resultBolok(SobotResultCode code, String msg, Object obj) {
// SobotLoginTools.getInstance().checkExpiresToken();
// SobotLoginTools.getInstance().checkExpiresToken();
// SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken()+"");
// SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken()+"");
// SobotLogUtils.i(SobotLoginTools.getInstance().getTempId());
// SobotLogUtils.i(SobotLoginTools.getInstance().getTempId());
// SobotLogUtils.i(SobotLoginTools.getInstance().getToken()+"");
// SobotLogUtils.i(SobotLoginTools.getInstance().getToken()+"");
// SobotLoginTools.getInstance().logOut(MainActivity.this, "https://api-c.sobot.com/text", "zhengnw@sobot.com", new SobotResultBlock() {
// @Override
// public void resultBolok(SobotResultCode code, String msg, Object obj) {
//
// }
// });
// }
// }
// });
// });
// LoginUserEntity sa=new LoginUserEntity();
// LoginUserEntity sa=new LoginUserEntity();
...
...
sobot_common/src/main/java/com/sobot/common/login/SobotLoginTools.java
View file @
904a46ab
...
@@ -153,8 +153,8 @@ public class SobotLoginTools {
...
@@ -153,8 +153,8 @@ public class SobotLoginTools {
public
boolean
checkExpiresToken
()
{
public
boolean
checkExpiresToken
()
{
if
(
getLoginUser
()
!=
null
)
{
if
(
getLoginUser
()
!=
null
)
{
long
difference
=
System
.
currentTimeMillis
()
-
getLoginUser
().
getLogin_time
();
long
difference
=
System
.
currentTimeMillis
()
-
getLoginUser
().
getLogin_time
();
SobotLogUtils
.
d
(
"检查token是否过期:上次登录距离当前的时间"
+
difference
);
if
(
getLoginUser
().
getLogin_time
()
>
0
&&
(
difference
>
12
*
60
*
60
*
1000
))
{
if
(
getLoginUser
().
getLogin_time
()
>
0
&&
(
difference
>
12
*
60
*
60
*
1000
))
{
SobotLogUtils
.
d
(
"上次登录距离当前的时间:"
+
difference
+
"ms,已经超过12小时,token已经过期"
);
return
false
;
return
false
;
}
}
}
}
...
@@ -458,10 +458,13 @@ public class SobotLoginTools {
...
@@ -458,10 +458,13 @@ public class SobotLoginTools {
// sdk 执行退出登录
// sdk 执行退出登录
public
void
logOut
(
Object
cancelTag
,
String
host
,
String
loginAcount
,
final
SobotResultBlock
resultBlock
)
{
public
void
logOut
(
Object
cancelTag
,
String
host
,
String
loginAcount
,
final
SobotResultBlock
resultBlock
)
{
if
(
SobotStringUtils
.
isEmpty
(
loginAcount
))
{
if
(
!
SobotStringUtils
.
isEmpty
(
loginAcount
)
&&
isLogin
(
loginAcount
))
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"loginUser"
,
loginAcount
);
params
.
put
(
"loginUser"
,
loginAcount
);
SobotHttpUtils
.
doPost
(
cancelTag
,
host
+
"/basic-login/serviceLogOut/4"
,
8000
,
params
,
null
,
new
HttpBaseUtils
.
StringCallBack
()
{
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"temp-id"
,
getToken
());
headerParams
.
put
(
"from"
,
2
+
""
);
SobotHttpUtils
.
doPost
(
cancelTag
,
host
+
"/basic-login/serviceLogOut/4"
,
8000
,
params
,
headerParams
,
new
HttpBaseUtils
.
StringCallBack
()
{
@Override
@Override
public
void
onResponse
(
String
response
)
{
public
void
onResponse
(
String
response
)
{
SobotCallBaseCode
result
=
SobotGsonUtil
.
jsonToBean
(
response
,
SobotCallBaseCode
.
class
);
SobotCallBaseCode
result
=
SobotGsonUtil
.
jsonToBean
(
response
,
SobotCallBaseCode
.
class
);
...
...
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