TOKEN失效
This commit is contained in:
@@ -163,7 +163,7 @@ dependencies {
|
||||
api 'cn.rongcloud.sdk:im_kit:5.2.5' // 即时通讯 UI 基础组件
|
||||
//融云小视频模块
|
||||
api 'cn.rongcloud.sdk:sight:5.2.5'
|
||||
api 'com.facebook.android:facebook-login:8.2.0'
|
||||
api 'com.facebook.android:facebook-android-sdk:11.3.0'
|
||||
implementation 'com.facebook.android:facebook-android-sdk:[8,9)'
|
||||
|
||||
api('com.twitter.sdk.android:twitter-core:3.1.1@aar') {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.yunbao.common.http;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.cache.CacheMode;
|
||||
@@ -12,6 +13,7 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -72,8 +74,12 @@ public class HttpClient {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (IMLoginManager.isLogin(context)) {
|
||||
IMLoginModel model = IMLoginManager.get(context).getUserInfo();
|
||||
map.put("uid", String.valueOf(model.getId()));
|
||||
map.put("token", model.getToken());
|
||||
if (TextUtils.isEmpty(model.getToken())) {
|
||||
RouteUtil.forwardEntry();
|
||||
} else {
|
||||
map.put("uid", String.valueOf(model.getId()));
|
||||
map.put("token", model.getToken());
|
||||
}
|
||||
}
|
||||
return OkGo.<JsonBean>get(mUrl + serviceName)
|
||||
.params(map, true)
|
||||
@@ -90,8 +96,13 @@ public class HttpClient {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (IMLoginManager.isLogin(context)) {
|
||||
IMLoginModel model = IMLoginManager.get(context).getUserInfo();
|
||||
map.put("uid", String.valueOf(model.getId()));
|
||||
map.put("token", model.getToken());
|
||||
if (TextUtils.isEmpty(model.getToken())) {
|
||||
RouteUtil.forwardEntry();
|
||||
} else {
|
||||
map.put("uid", String.valueOf(model.getId()));
|
||||
map.put("token", model.getToken());
|
||||
}
|
||||
|
||||
}
|
||||
return OkGo.<JsonBean>get(url + serviceName)
|
||||
.headers("Connection", "keep-alive")
|
||||
@@ -105,9 +116,14 @@ public class HttpClient {
|
||||
//拼装基本信息
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (IMLoginManager.isLogin(context)) {
|
||||
|
||||
IMLoginModel model = IMLoginManager.get(context).getUserInfo();
|
||||
map.put("uid", String.valueOf(model.getId()));
|
||||
map.put("token", model.getToken());
|
||||
if (TextUtils.isEmpty(model.getToken())) {
|
||||
RouteUtil.forwardEntry();
|
||||
} else {
|
||||
map.put("uid", String.valueOf(model.getId()));
|
||||
map.put("token", model.getToken());
|
||||
}
|
||||
}
|
||||
return OkGo.<JsonBean>post(mUrl + serviceName)
|
||||
.headers("Connection", "keep-alive")
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.yunbao.common.http.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
@@ -11,13 +13,14 @@ import okhttp3.Request;
|
||||
public class GetRequestParams implements IRequestParam {
|
||||
/**
|
||||
* 构建Request
|
||||
*
|
||||
* @param isNeedUid 是否需要添加用户uid参数
|
||||
* @param request
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Request getRequest(boolean isNeedUid,Request request, Context context) {
|
||||
public Request getRequest(boolean isNeedUid, Request request, Context context) {
|
||||
//添加公共参数
|
||||
if (IMLoginManager.isLogin(context)) {
|
||||
IMLoginModel model = IMLoginManager.get(context).getUserInfo();
|
||||
@@ -26,10 +29,16 @@ public class GetRequestParams implements IRequestParam {
|
||||
.addQueryParameter("token", model.getToken())
|
||||
.build();*/
|
||||
HttpUrl.Builder builder = request.url().newBuilder();
|
||||
if(isNeedUid) {
|
||||
builder.addQueryParameter("uid", String.valueOf(model.getId()));
|
||||
if (TextUtils.isEmpty(model.getToken())) {
|
||||
RouteUtil.forwardEntry();
|
||||
} else {
|
||||
|
||||
if (isNeedUid) {
|
||||
builder.addQueryParameter("uid", String.valueOf(model.getId()));
|
||||
}
|
||||
builder.addQueryParameter("token", model.getToken());
|
||||
}
|
||||
builder.addQueryParameter("token", model.getToken());
|
||||
|
||||
return request.newBuilder().url(builder.build()).build();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.yunbao.common.http.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class PostRequestParams implements IRequestParam {
|
||||
@Override
|
||||
public Request getRequest(boolean isNeedUid,Request request, Context context) {
|
||||
public Request getRequest(boolean isNeedUid, Request request, Context context) {
|
||||
if (request.body() instanceof FormBody) {
|
||||
FormBody.Builder bodyBuilder = new FormBody.Builder();
|
||||
|
||||
@@ -21,15 +23,18 @@ public class PostRequestParams implements IRequestParam {
|
||||
}
|
||||
if (IMLoginManager.isLogin(context)) {
|
||||
IMLoginModel model = IMLoginManager.get(context).getUserInfo();
|
||||
if (TextUtils.isEmpty(model.getToken())) {
|
||||
RouteUtil.forwardEntry();
|
||||
} else {
|
||||
/* formBody = bodyBuilder.addEncoded("uid", String.valueOf(model.getId()))
|
||||
.addEncoded("token", model.getToken())
|
||||
.build();*/
|
||||
if (isNeedUid){
|
||||
bodyBuilder.addEncoded("uid", String.valueOf(model.getId()));
|
||||
if (isNeedUid) {
|
||||
bodyBuilder.addEncoded("uid", String.valueOf(model.getId()));
|
||||
}
|
||||
bodyBuilder.addEncoded("token", model.getToken());
|
||||
formBody = bodyBuilder.build();
|
||||
}
|
||||
bodyBuilder.addEncoded("token", model.getToken());
|
||||
formBody=bodyBuilder.build();
|
||||
|
||||
}
|
||||
request = request.newBuilder().post(formBody).build();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ public class RouteUtil {
|
||||
public static final String PATH_MYWEBVIEWACTIVTITY = "/main/MyWebViewActivity";
|
||||
public static final String PATH_ZHUANGBANACTIVITY = "/main/ZhuangBanActivity";
|
||||
public static final String PATH_FACEBOOKACTIVITY = "/baidu/FacebookLoginActivity";
|
||||
public static final String PATH_MAIN= "/main/MainActivity";
|
||||
public static final String PATH_MAIN = "/main/MainActivity";
|
||||
public static final String PATH_ENTRY = "/main/EntryActivity";
|
||||
|
||||
/**
|
||||
* 启动页
|
||||
@@ -44,6 +45,17 @@ public class RouteUtil {
|
||||
.navigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* toke失效重新登录
|
||||
*/
|
||||
public static void forwardEntry() {
|
||||
ARouter.getInstance().build(PATH_ENTRY)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.withBoolean("forwardEntry", true)
|
||||
.navigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到个人主页
|
||||
* intoIndex 2=个人中心进入 1=单聊进入 0=其他
|
||||
@@ -68,7 +80,7 @@ public class RouteUtil {
|
||||
if (!"".equals(Constants.chatActionUrl)) {
|
||||
url = Constants.chatActionUrl;
|
||||
}
|
||||
Constants.myUrl = url + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&t=" + System.currentTimeMillis();
|
||||
Constants.myUrl = url + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&t=" + System.currentTimeMillis();
|
||||
ARouter.getInstance().build(PATH_MYWEBVIEWACTIVTITY)
|
||||
.navigation();
|
||||
}
|
||||
@@ -79,7 +91,7 @@ public class RouteUtil {
|
||||
public static void forwardZhuangBanActivity(String url) {
|
||||
Constants.myPackageUrl = url;
|
||||
ARouter.getInstance().build(PATH_ZHUANGBANACTIVITY)
|
||||
.withString("title","")
|
||||
.withString("title", "")
|
||||
.navigation();
|
||||
}
|
||||
|
||||
|
||||
@@ -880,4 +880,24 @@ Limited ride And limited avatar frame</string>
|
||||
<string name="system_notice">Notice</string>
|
||||
<string name="online_service">Online Service</string>
|
||||
<string name="popular_tickets">Hot Ticket</string>
|
||||
|
||||
<string name="tell_the_world">Tell the world!</string>
|
||||
<string name="better_emperor_hint">Tell the world! %s recommends anchor %s to everyone!</string>
|
||||
<string name="emperor_hint">Tell the world! %s recommends the anchor %s to everyone, and the splendid glance is amazing!</string>
|
||||
<string name="try_again_later">Failed to load data, please try again later</string>
|
||||
<string name="open_noble2">open</string>
|
||||
<string name="enough_speakers">Not enough speakers</string>
|
||||
<string name="order_query">order inquiries</string>
|
||||
<string name="order_query_success">No exception to the order</string>
|
||||
<string name="login_invalid">Login failed, please log in again</string>
|
||||
|
||||
<string name="onlookers">onlookers</string>
|
||||
<string name="open_noble">的直播間開通了</string>
|
||||
<string name="baron">baron</string>
|
||||
<string name="viscount">子爵</string>
|
||||
<string name="marquis">侯爵</string>
|
||||
<string name="duke">公爵</string>
|
||||
<string name="king">国王</string>
|
||||
<string name="emperor">皇帝</string>
|
||||
<string name="better_emperor">超皇</string>
|
||||
</resources>
|
||||
|
||||
@@ -911,5 +911,7 @@
|
||||
<string name="enough_speakers">喇叭數量不足</string>
|
||||
<string name="order_query">订单查询中</string>
|
||||
<string name="order_query_success">订单无异常</string>
|
||||
<string name="login_invalid">登錄失效,請重新登錄</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user