com.facebook.model.GraphPlace Java Examples

The following examples show how to use com.facebook.model.GraphPlace. 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: PlacePickerFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #2
Source File: PlacePickerFragment.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #3
Source File: BatchRequestTests.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@MediumTest
@LargeTest
public void testExecuteBatchRequestsPathEncoding() throws IOException {
    // ensures that paths passed to batch requests are encoded properly before
    // we send it up to the server

    TestSession session = openTestSessionWithSharedUser();

    Request request1 = new Request(session, "TourEiffel");
    request1.setBatchEntryName("eiffel");
    request1.setBatchEntryOmitResultOnSuccess(false);
    Request request2 = new Request(session, "{result=eiffel:$.id}");

    List<Response> responses = Request.executeBatchAndWait(request1, request2);
    assertEquals(2, responses.size());
    assertTrue(responses.get(0).getError() == null);
    assertTrue(responses.get(1).getError() == null);

    GraphPlace eiffelTower1 = responses.get(0).getGraphObjectAs(GraphPlace.class);
    GraphPlace eiffelTower2 = responses.get(1).getGraphObjectAs(GraphPlace.class);
    assertTrue(eiffelTower1 != null);
    assertTrue(eiffelTower2 != null);

    assertEquals("Paris", eiffelTower1.getLocation().getCity());
    assertEquals("Paris", eiffelTower2.getLocation().getCity());
}
 
Example #4
Source File: PlacePickerFragment.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #5
Source File: BatchRequestTests.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@MediumTest
@LargeTest
public void testExecuteBatchedGets() throws IOException {
    TestSession session = openTestSessionWithSharedUser();

    Request request1 = new Request(session, "TourEiffel");
    Request request2 = new Request(session, "SpaceNeedle");

    List<Response> responses = Request.executeBatchAndWait(request1, request2);
    assertEquals(2, responses.size());
    assertTrue(responses.get(0).getError() == null);
    assertTrue(responses.get(1).getError() == null);

    GraphPlace eiffelTower = responses.get(0).getGraphObjectAs(GraphPlace.class);
    GraphPlace spaceNeedle = responses.get(1).getGraphObjectAs(GraphPlace.class);
    assertTrue(eiffelTower != null);
    assertTrue(spaceNeedle != null);

    assertEquals("Paris", eiffelTower.getLocation().getCity());
    assertEquals("Seattle", spaceNeedle.getLocation().getCity());
}
 
Example #6
Source File: PlacePickerFragment.java    From android-skeleton-project with MIT License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #7
Source File: AsyncRequestTests.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@MediumTest
@LargeTest
public void testExecuteSingleGet() {
    final TestSession session = openTestSessionWithSharedUser();
    Request request = new Request(session, "TourEiffel", null, null, new ExpectSuccessCallback() {
        @Override
        protected void performAsserts(Response response) {
            assertNotNull(response);
            GraphPlace graphPlace = response.getGraphObjectAs(GraphPlace.class);
            assertEquals("Paris", graphPlace.getLocation().getCity());
        }
    });

    TestRequestAsyncTask task = new TestRequestAsyncTask(request);

    task.executeOnBlockerThread();

    // Wait on 2 signals: request and task will both signal.
    waitAndAssertSuccess(2);
}
 
Example #8
Source File: AsyncRequestTests.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@MediumTest
@LargeTest
public void testExecuteSingleGetUsingHttpURLConnection() {
    final TestSession session = openTestSessionWithSharedUser();
    Request request = new Request(session, "TourEiffel", null, null, new ExpectSuccessCallback() {
        @Override
        protected void performAsserts(Response response) {
            assertNotNull(response);
            GraphPlace graphPlace = response.getGraphObjectAs(GraphPlace.class);
            assertEquals("Paris", graphPlace.getLocation().getCity());
        }
    });
    HttpURLConnection connection = Request.toHttpConnection(request);

    TestRequestAsyncTask task = new TestRequestAsyncTask(connection, Arrays.asList(new Request[] { request }));

    task.executeOnBlockerThread();

    // Wait on 2 signals: request and task will both signal.
    waitAndAssertSuccess(2);
}
 
Example #9
Source File: PlacePickerFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #10
Source File: PlacePickerFragment.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #11
Source File: PlacePickerFragment.java    From FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #12
Source File: KlyphPlacePickerFragment.java    From Klyph with MIT License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #13
Source File: PlacePickerFragment.java    From KlyphMessenger with MIT License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #14
Source File: PlacePickerFragment.java    From Klyph with MIT License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #15
Source File: PlacePickerFragment.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #16
Source File: PlacePickerSampleActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 6 votes vote down vote up
private void displaySelectedPlace(int resultCode) {
    String results = "";
    PlacePickerApplication application = (PlacePickerApplication) getApplication();

    GraphPlace selection = application.getSelectedPlace();
    if (selection != null) {
        GraphLocation location = selection.getLocation();

        results = String.format("Name: %s\nCategory: %s\nLocation: (%f,%f)\nStreet: %s, %s, %s, %s, %s",
                selection.getName(), selection.getCategory(),
                location.getLatitude(), location.getLongitude(),
                location.getStreet(), location.getCity(), location.getState(), location.getZip(),
                location.getCountry());
    } else {
        results = "<No place selected>";
    }

    resultsTextView.setText(results);
}
 
Example #17
Source File: PlacePickerFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void onLoadFinished(GraphObjectPagingLoader<GraphPlace> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    super.onLoadFinished(loader, data);

    // We could be called in this state if we are clearing data or if we are being re-attached
    // in the middle of a query.
    if (data == null || loader.isLoading()) {
        return;
    }

    hideActivityCircle();

    if (data.isFromCache()) {
        // Only the first page can be cached, since all subsequent pages will be round-tripped. Force
        // a refresh of the first page before we allow paging to begin. If the first page produced
        // no data, launch the refresh immediately, otherwise schedule it for later.
        loader.refreshOriginalRequest(data.areMoreObjectsAvailable() ? CACHED_RESULT_REFRESH_DELAY : 0);
    }
}
 
Example #18
Source File: PlacePickerFragment.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #19
Source File: KlyphPlacePickerFragment.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #20
Source File: HelloFacebookSampleActivity.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
private void onPlacePickerDone(PlacePickerFragment fragment) {
    FragmentManager fm = getSupportFragmentManager();
    fm.popBackStack();

    String result = "";

    GraphPlace selection = fragment.getSelection();
    if (selection != null) {
        result = selection.getName();
    } else {
        result = getString(R.string.no_place_selected);
    }

    showAlert(getString(R.string.you_picked), result);
}
 
Example #21
Source File: PlacePickerFragment.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #22
Source File: PlacePickerFragment.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #23
Source File: PlacePickerFragment.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
PickerFragmentAdapter<GraphPlace> createAdapter() {
    PickerFragmentAdapter<GraphPlace> adapter = new PickerFragmentAdapter<GraphPlace>(
            this.getActivity()) {
        @Override
        protected CharSequence getSubTitleOfGraphObject(GraphPlace graphObject) {
            String category = graphObject.getCategory();
            Integer wereHereCount = (Integer) graphObject.getProperty(WERE_HERE_COUNT);

            String result = null;
            if (category != null && wereHereCount != null) {
                result = getString(::APP_PACKAGE::.R.string.com_facebook_placepicker_subtitle_format, category, wereHereCount);
            } else if (category == null && wereHereCount != null) {
                result = getString(::APP_PACKAGE::.R.string.com_facebook_placepicker_subtitle_were_here_only_format, wereHereCount);
            } else if (category != null && wereHereCount == null) {
                result = getString(::APP_PACKAGE::.R.string.com_facebook_placepicker_subtitle_catetory_only_format, category);
            }
            return result;
        }

        @Override
        protected int getGraphObjectRowLayoutId(GraphPlace graphObject) {
            return ::APP_PACKAGE::.R.layout.com_facebook_placepickerfragment_list_row;
        }

        @Override
        protected int getDefaultPicture() {
            return ::APP_PACKAGE::.R.drawable.com_facebook_place_default_icon;
        }

    };
    adapter.setShowCheckbox(false);
    adapter.setShowPicture(getShowPictures());
    return adapter;
}
 
Example #24
Source File: PlacePickerFragment.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #25
Source File: PlacePickerFragment.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #26
Source File: PlacePickerFragment.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #27
Source File: GraphObjectPagingLoaderTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
public void onLoadFinished(Loader<SimpleGraphObjectCursor<GraphPlace>> loader,
        SimpleGraphObjectCursor<GraphPlace> data) {
    results = data;
    ++onLoadFinishedCount;
    testBlocker.signal();
}
 
Example #28
Source File: PlacePickerFragment.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
@Override
public void attach(GraphObjectAdapter<GraphPlace> adapter) {
    super.attach(adapter);

    this.adapter.setDataNeededListener(new GraphObjectAdapter.DataNeededListener() {
        @Override
        public void onDataNeeded() {
            // Do nothing if we are currently loading data . We will get notified again when that load finishes if the adapter still
            // needs more data. Otherwise, follow the next link.
            if (!loader.isLoading()) {
                loader.followNextLink();
            }
        }
    });
}
 
Example #29
Source File: GraphObjectPagingLoaderTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@MediumTest
@LargeTest
public void testLoaderFinishesImmediatelyOnNoResults() throws Exception {
    CountingCallback callback = new CountingCallback();
    final GraphObjectPagingLoader<GraphPlace> loader = (GraphObjectPagingLoader<GraphPlace>)
            getActivity().getSupportLoaderManager().initLoader(0, null, callback);

    TestSession session = openTestSessionWithSharedUser();

    // Unlikely to ever be a Place here.
    Location location = new Location("");
    location.setLatitude(-1.0);
    location.setLongitude(-1.0);

    final Request request = Request.newPlacesSearchRequest(session, location, 10, 5, null, null);

    // Need to run this on blocker thread so callbacks are made there.
    runOnBlockerThread(new Runnable() {
        @Override
        public void run() {
            loader.startLoading(request, false);
        }
    }, false);

    getTestBlocker().waitForSignals(1);
    assertEquals(1, callback.onLoadFinishedCount);
    assertEquals(0, callback.onErrorCount);
    assertEquals(0, callback.onLoadResetCount);
    assertNotNull(callback.results);
    assertEquals(0, callback.results.getCount());
}
 
Example #30
Source File: GraphObjectPagingLoaderTests.java    From FacebookImageShareIntent with MIT License 5 votes vote down vote up
@Override
public Loader<SimpleGraphObjectCursor<GraphPlace>> onCreateLoader(int id, Bundle args) {
    GraphObjectPagingLoader<GraphPlace> loader = new GraphObjectPagingLoader<GraphPlace>(getActivity(),
            GraphPlace.class);
    loader.setOnErrorListener(this);
    return loader;
}