diff --git a/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/AbsOpenAPI.java b/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/AbsOpenAPI.java index 9576aba..df4a598 100644 --- a/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/AbsOpenAPI.java +++ b/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/AbsOpenAPI.java @@ -23,6 +23,11 @@ import com.sina.weibo.sdk.net.RequestListener; import com.sina.weibo.sdk.net.WeiboParameters; import com.sina.weibo.sdk.utils.LogUtil; +import com.sina.weibo.sdk.openapi.models.*; +import com.sina.weibo.sdk.net.ListRequestListener; +import java.util.List; +import java.util.Collection; +import java.util.Collections; /** * 微博 OpenAPI 的基类,每个接口类都继承了此抽象类。 @@ -58,6 +63,26 @@ public AbsOpenAPI(Context context, String appKey, Oauth2AccessToken accessToken) mAccessToken = accessToken; } + public abstract class SimpleRequestListener implements RequestListener, ListRequestListener { + @Override public void onComplete(String json) { + onComplete(parse(json, (T) null)); + } + + private List parse(String json, Status defValue) { + StatusList statusList = StatusList.parse(json); + return statusList.statusList; + } + + private List parse(String json, Comment defValue) { + CommentList list = CommentList.parse(json); + return list.commentList; + } + + private List parse(String json, T defValue) { + return null; + } + } + /** * HTTP 异步请求。 * diff --git a/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/models/CommentList.java b/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/models/CommentList.java index 0948ff6..3dd3254 100644 --- a/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/models/CommentList.java +++ b/weibo-android-sdk/src/main/java/com/sina/weibo/sdk/openapi/models/CommentList.java @@ -17,6 +17,7 @@ package com.sina.weibo.sdk.openapi.models; import java.util.ArrayList; +import java.util.List; import org.json.JSONArray; import org.json.JSONException; @@ -33,7 +34,7 @@ public class CommentList { /** 微博列表 */ - public ArrayList commentList; + public List commentList; public String previous_cursor; public String next_cursor; public int total_number;