Commit 904a46ab by zhengnw@sobot.com

common 1.5.8 添加 sdk 退出登录

parent 3cd73d7f
......@@ -9,6 +9,9 @@ import android.net.Uri;
import android.widget.ImageView;
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.pictureframe.SobotBitmapUtil;
import com.sobot.utils.SobotLogUtils;
......@@ -210,13 +213,19 @@ public class MainActivity extends SobotBaseActivity {
Map<String, String> headers1 = new HashMap<>();
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
// public void resultBolok(SobotResultCode code, String msg, Object obj) {
// SobotLoginTools.getInstance().checkExpiresToken();
// SobotLogUtils.i(SobotLoginTools.getInstance().getAccessToken()+"");
// SobotLogUtils.i(SobotLoginTools.getInstance().getTempId());
// 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();
......
......@@ -153,8 +153,8 @@ public class SobotLoginTools {
public boolean checkExpiresToken() {
if (getLoginUser() != null) {
long difference = System.currentTimeMillis() - getLoginUser().getLogin_time();
SobotLogUtils.d("检查token是否过期:上次登录距离当前的时间" + difference);
if (getLoginUser().getLogin_time() > 0 && (difference > 12 * 60 * 60 * 1000)) {
SobotLogUtils.d("上次登录距离当前的时间:" + difference + "ms,已经超过12小时,token已经过期");
return false;
}
}
......@@ -458,10 +458,13 @@ public class SobotLoginTools {
// sdk 执行退出登录
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<>();
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
public void onResponse(String response) {
SobotCallBaseCode result = SobotGsonUtil.jsonToBean(response, SobotCallBaseCode.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment