Java Code Examples for com.facebook.internal.CacheableRequestBatch#setForceRoundTrip()

The following examples show how to use com.facebook.internal.CacheableRequestBatch#setForceRoundTrip() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchRequestTests.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@SmallTest
@MediumTest
@LargeTest
public void testCreateEmptyRequestBatch() {
    CacheableRequestBatch batch = new CacheableRequestBatch();

    Request meRequest = Request.newMeRequest(null, null);
    assertEquals(0, batch.size());
    batch.add(meRequest);
    assertEquals(1, batch.size());
    assertEquals(meRequest, batch.get(0));

    String key = "The Key";
    assertNull(batch.getCacheKeyOverride());
    batch.setCacheKeyOverride(key);
    assertEquals(key, batch.getCacheKeyOverride());

    assertTrue(!batch.getForceRoundTrip());
    batch.setForceRoundTrip(true);
    assertTrue(batch.getForceRoundTrip());
}
 
Example 2
Source File: GraphObjectPagingLoader.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 3
Source File: GraphObjectPagingLoader.java    From Klyph with MIT License 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 4
Source File: GraphObjectPagingLoader.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 5
Source File: GraphObjectPagingLoader.java    From android-skeleton-project with MIT License 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 6
Source File: GraphObjectPagingLoader.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 7
Source File: GraphObjectPagingLoader.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 8
Source File: GraphObjectPagingLoader.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 9
Source File: GraphObjectPagingLoader.java    From KlyphMessenger with MIT License 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 10
Source File: GraphObjectPagingLoader.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 11
Source File: GraphObjectPagingLoader.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 12
Source File: GraphObjectPagingLoader.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private CacheableRequestBatch putRequestIntoBatch(Request request, boolean skipRoundtripIfCached) {
    // We just use the request URL as the cache key.
    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    // We use the default cache key (request URL).
    batch.setForceRoundTrip(!skipRoundtripIfCached);
    return batch;
}
 
Example 13
Source File: BatchRequestTests.java    From FacebookImageShareIntent with MIT License 4 votes vote down vote up
@MediumTest
@LargeTest
public void testCacheMyFriendsRequest() throws Exception {
    TestUtils.clearFileLruCache(Response.getResponseCache());
    TestSession session = openTestSessionWithSharedUser();

    Request request = Request.newMyFriendsRequest(session, null);

    CacheableRequestBatch batch = new CacheableRequestBatch(request);
    batch.setCacheKeyOverride("MyFriends");

    // Running the request with empty cache should hit the server.
    List<Response> responses = Request.executeBatchAndWait(batch);
    assertNotNull(responses);
    assertEquals(1, responses.size());

    Response response = responses.get(0);
    assertNotNull(response);
    assertNull(response.getError());
    assertTrue(!response.getIsFromCache());

    // Running again should hit the cache.
    responses = Request.executeBatchAndWait(batch);
    assertNotNull(responses);
    assertEquals(1, responses.size());

    response = responses.get(0);
    assertNotNull(response);
    assertNull(response.getError());
    assertTrue(response.getIsFromCache());

    // Forcing roundtrip should hit the server again.
    batch.setForceRoundTrip(true);
    responses = Request.executeBatchAndWait(batch);
    assertNotNull(responses);
    assertEquals(1, responses.size());

    response = responses.get(0);
    assertNotNull(response);
    assertNull(response.getError());
    assertTrue(!response.getIsFromCache());

    TestUtils.clearFileLruCache(Response.getResponseCache());
}