去除volley 中TAG的滥用导致无法重复加载同一url,项目整理
This commit is contained in:
@ -18,8 +18,12 @@ import org.json.JSONObject;
|
||||
*/
|
||||
public class PostCommentUtils {
|
||||
|
||||
public static void addCommentData(final String url, final String content, final Context context,
|
||||
final PostCommentListener listener) {
|
||||
public static void addCommentData(Context context, String url, String content, PostCommentListener listener) {
|
||||
addCommentData(context, url, content, true, listener);
|
||||
}
|
||||
|
||||
public static void addCommentData(final Context context, final String url, final String content,
|
||||
final boolean isCheck, final PostCommentListener listener) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -36,8 +40,7 @@ public class PostCommentUtils {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.statusCode == 401) {
|
||||
TokenUtils.getToken(context, false);
|
||||
addCommentData(url, content, context, listener);
|
||||
addCommentData(context, url, content, false, listener);
|
||||
return;
|
||||
}
|
||||
if (listener != null){
|
||||
@ -46,13 +49,17 @@ public class PostCommentUtils {
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
request.addHeader("TOKEN", TokenUtils.getToken(context));
|
||||
request.addHeader("TOKEN", TokenUtils.getToken(context, isCheck));
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void addCommentVoto(final String newsId, final Context context) {
|
||||
public static void addCommentVoto(final Context context, final String newsId) {
|
||||
addCommentVoto(context, newsId, true);
|
||||
}
|
||||
|
||||
public static void addCommentVoto(final Context context, final String newsId, final boolean isCheck) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -63,13 +70,12 @@ public class PostCommentUtils {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (error.networkResponse != null && error.networkResponse.statusCode == 401) {
|
||||
TokenUtils.getToken(context, false);
|
||||
addCommentVoto(newsId, context);
|
||||
addCommentVoto(context, newsId, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
request.addHeader("TOKEN", TokenUtils.getToken(context));
|
||||
request.addHeader("TOKEN", TokenUtils.getToken(context, isCheck));
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
}).start();
|
||||
|
||||
Reference in New Issue
Block a user