本文整理匯總了Java中com.facebook.RequestBatch類的典型用法代碼示例。如果您正苦於以下問題:Java RequestBatch類的具體用法?Java RequestBatch怎麽用?Java RequestBatch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RequestBatch類屬於com.facebook包,在下文中一共展示了RequestBatch類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import com.facebook.RequestBatch; //導入依賴的package包/類
@Override
protected void setUp() throws Exception {
r1 = new Request(null, "4");
r2 = new Request(null, "4");
progressMap = new HashMap<Request, RequestProgress>();
progressMap.put(r1, new RequestProgress(null, r1));
progressMap.get(r1).addToMax(5);
progressMap.put(r2, new RequestProgress(null, r2));
progressMap.get(r2).addToMax(5);
requests = new RequestBatch(r1, r2);
ByteArrayOutputStream backing = new ByteArrayOutputStream();
stream = new ProgressOutputStream(backing, requests, progressMap, MAX_PROGRESS);
}
示例2: startLoading
import com.facebook.RequestBatch; //導入依賴的package包/類
private void startLoading(Request request, boolean skipRoundtripIfCached, long afterDelay) {
this.skipRoundtripIfCached = skipRoundtripIfCached;
appendResults = false;
nextRequest = null;
currentRequest = request;
currentRequest.setCallback(new Request.Callback() {
@Override
public void onCompleted(Response response) {
requestCompleted(response);
}
});
// We are considered loading even if we have a delay.
loading = true;
final RequestBatch batch = putRequestIntoBatch(request, skipRoundtripIfCached);
Runnable r = new Runnable() {
@Override
public void run() {
Request.executeBatchAsync(batch);
}
};
if (afterDelay == 0) {
r.run();
} else {
Handler handler = new Handler();
handler.postDelayed(r, afterDelay);
}
}
示例3: testCreateNonemptyRequestBatch
import com.facebook.RequestBatch; //導入依賴的package包/類
@SmallTest
@MediumTest
@LargeTest
public void testCreateNonemptyRequestBatch() {
Request meRequest = Request.newMeRequest(null, null);
RequestBatch batch = new RequestBatch(new Request[] { meRequest, meRequest });
assertEquals(2, batch.size());
assertEquals(meRequest, batch.get(0));
assertEquals(meRequest, batch.get(1));
}