本文整理匯總了Java中com.socks.jiandan.net.RequestManager.addRequest方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestManager.addRequest方法的具體用法?Java RequestManager.addRequest怎麽用?Java RequestManager.addRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.socks.jiandan.net.RequestManager
的用法示例。
在下文中一共展示了RequestManager.addRequest方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadData
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void loadData() {
RequestManager.addRequest(new Request4Picture(Picture.getRequestUrl(mType, page),
new Response.Listener<ArrayList<Picture>>
() {
@Override
public void onResponse(ArrayList<Picture> response) {
getCommentCounts(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
mLoadFinisCallBack.loadFinish(null);
}
}), mActivity);
}
示例2: loadData
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void loadData() {
RequestManager.addRequest(new Request4Joke(Joke.getRequestUrl(page),
new Response.Listener<ArrayList<Joke>>
() {
@Override
public void onResponse(ArrayList<Joke> response) {
getCommentCounts(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadFinisCallBack.loadFinish(null);
}
}), mActivity);
}
示例3: getCommentCounts
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void getCommentCounts(final ArrayList<Picture> pictures) {
StringBuilder sb = new StringBuilder();
for (Picture joke : pictures) {
sb.append("comment-" + joke.getComment_ID() + ",");
}
RequestManager.addRequest(new Request4CommentCounts(CommentNumber.getCommentCountsURL(sb.toString()), new Response
.Listener<ArrayList<CommentNumber>>() {
@Override
public void onResponse(ArrayList<CommentNumber> response) {
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
mLoadFinisCallBack.loadFinish(null);
for (int i = 0; i < pictures.size(); i++) {
pictures.get(i).setComment_counts(response.get(i).getComments() + "");
}
if (page == 1) {
PictureAdapter.this.pictures.clear();
PictureCache.getInstance(mActivity).clearAllCache();
}
PictureAdapter.this.pictures.addAll(pictures);
notifyDataSetChanged();
//加載完畢後緩存
PictureCache.getInstance(mActivity).addResultCache(JSONParser.toString
(pictures), page);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
ShowToast.Short(ConstantString.LOAD_FAILED);
mLoadFinisCallBack.loadFinish(null);
mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
}
}
), mActivity);
}
示例4: loadData
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void loadData() {
RequestManager.addRequest(new Request4Video(Video.getUrlVideos(page),
new Response.Listener<ArrayList<Video>>() {
@Override
public void onResponse(ArrayList<Video> response) {
getCommentCounts(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadFinisCallBack.loadFinish(null);
}
}), mActivity);
}
示例5: executeRequest
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
public void executeRequest(Request<?> request) {
RequestManager.addRequest(request, this);
}
示例6: executeRequest
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
protected void executeRequest(Request request) {
RequestManager.addRequest(request, this);
}
示例7: getCommentCounts
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void getCommentCounts(final ArrayList<Joke> jokes) {
StringBuilder sb = new StringBuilder();
for (Joke joke : jokes) {
sb.append("comment-" + joke.getComment_ID() + ",");
}
String url = sb.toString();
if (url.endsWith(",")) {
url = url.substring(0, url.length() - 1);
}
RequestManager.addRequest(new Request4CommentCounts(CommentNumber.getCommentCountsURL(url), new Response
.Listener<ArrayList<CommentNumber>>() {
@Override
public void onResponse(ArrayList<CommentNumber> response) {
for (int i = 0; i < jokes.size(); i++) {
jokes.get(i).setComment_counts(response.get(i).getComments() + "");
}
if (page == 1) {
mJokes.clear();
//首次正常加載之後,清空之前的緩存
JokeCache.getInstance(mActivity).clearAllCache();
}
mJokes.addAll(jokes);
notifyDataSetChanged();
//加載完畢後緩存
JokeCache.getInstance(mActivity).addResultCache(JSONParser.toString(jokes),
page);
mLoadFinisCallBack.loadFinish(null);
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
mLoadFinisCallBack.loadFinish(null);
}
}
), mActivity);
}
示例8: loadDataByNetworkType
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void loadDataByNetworkType() {
if (NetWorkUtil.isNetWorkConnected(mActivity)) {
RequestManager.addRequest(new Request4FreshNews(FreshNews.getUrlFreshNews(page),
new Response.Listener<ArrayList<FreshNews>>() {
@Override
public void onResponse(ArrayList<FreshNews> response) {
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
mLoadFinisCallBack.loadFinish(null);
if (page == 1) {
mFreshNews.clear();
FreshNewsCache.getInstance(mActivity).clearAllCache();
}
mFreshNews.addAll(response);
notifyDataSetChanged();
FreshNewsCache.getInstance(mActivity).addResultCache(JSONParser.toString(response),
page);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
mLoadFinisCallBack.loadFinish(null);
}
}), mActivity);
} else {
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
mLoadFinisCallBack.loadFinish(null);
if (page == 1) {
mFreshNews.clear();
ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
}
mFreshNews.addAll(FreshNewsCache.getInstance(mActivity).getCacheByPage(page));
notifyDataSetChanged();
}
}
示例9: getCommentCounts
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
private void getCommentCounts(final ArrayList<Video> videos) {
StringBuilder sb = new StringBuilder();
for (Video video : videos) {
sb.append("comment-" + video.getComment_ID() + ",");
}
RequestManager.addRequest(new Request4CommentCounts(CommentNumber.getCommentCountsURL(sb.toString()), new Response
.Listener<ArrayList<CommentNumber>>() {
@Override
public void onResponse(ArrayList<CommentNumber> response) {
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
mLoadFinisCallBack.loadFinish(null);
for (int i = 0; i < videos.size(); i++) {
videos.get(i).setComment_count(response.get(i).getComments() + "");
}
if (page == 1) {
mVideos.clear();
VideoCache.getInstance(mActivity).clearAllCache();
}
mVideos.addAll(videos);
notifyDataSetChanged();
VideoCache.getInstance(mActivity).addResultCache(JSONParser.toString
(videos), page);
//防止加載不到一頁的情況
if (mVideos.size() < 10) {
loadNextPage();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadFinisCallBack.loadFinish(null);
mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, null);
}
}
), mActivity);
}
示例10: loadData
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
public void loadData() {
RequestManager.addRequest(new Request4CommentList(Commentator.getUrlCommentList(thread_key), new Response
.Listener<ArrayList<Commentator>>() {
@Override
public void onResponse(ArrayList<Commentator> response) {
if (response.size() == 0) {
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_NONE, null);
} else {
commentators.clear();
ArrayList<Commentator> hotCommentator = new ArrayList<>();
ArrayList<Commentator> normalComment = new ArrayList<>();
//添加熱門評論
for (Commentator commentator : response) {
if (commentator.getTag().equals(Commentator.TAG_HOT)) {
hotCommentator.add(commentator);
} else {
normalComment.add(commentator);
}
}
//添加熱門評論標簽
if (hotCommentator.size() != 0) {
Collections.sort(hotCommentator);
Commentator hotCommentFlag = new Commentator();
hotCommentFlag.setType(Commentator.TYPE_HOT);
hotCommentator.add(0, hotCommentFlag);
commentators.addAll(hotCommentator);
}
//添加最新評論及標簽
if (normalComment.size() != 0) {
Commentator newCommentFlag = new Commentator();
newCommentFlag.setType(Commentator.TYPE_NEW);
commentators.add(newCommentFlag);
Collections.sort(normalComment);
commentators.addAll(normalComment);
}
notifyDataSetChanged();
mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
}
}, new LoadFinishCallBack() {
@Override
public void loadFinish(Object obj) {
thread_id = (String) obj;
}
}), mActivity);
}
示例11: executeRequest
import com.socks.jiandan.net.RequestManager; //導入方法依賴的package包/類
protected void executeRequest(Request<?> request) {
RequestManager.addRequest(request, this);
}