public void followNextLink() { if (this.nextRequest != null) { this.appendResults = true; this.currentRequest = this.nextRequest; this.currentRequest.setCallback(new Request.Callback() { public void onCompleted(Response paramAnonymousResponse) { GraphObjectPagingLoader.this.requestCompleted(paramAnonymousResponse); } }); this.loading = true; Request.executeBatchAsync(putRequestIntoBatch(this.currentRequest, this.skipRoundtripIfCached)); } }
/** * Asynchronously requests the Page accounts associated with the linked account. Requires an opened active {@link Session}. * * @param callback a {@link Callback} when the request completes. * @return true if the request is made; false if no opened {@link Session} is active. */ boolean requestAccounts(Callback callback) { boolean isSuccessful = false; Session session = Session.getActiveSession(); if (session != null && session.isOpened()) { // Construct fields to request. Bundle params = new Bundle(); params.putString(ACCOUNTS_LISTING_FEILDS_KEY, ACCOUNTS_LISTING_FIELDS_VALUE); // Construct and execute albums listing request. Request request = new Request(session, ACCOUNTS_LISTING_GRAPH_PATH, params, HttpMethod.GET, callback); request.executeAsync(); isSuccessful = true; } return isSuccessful; }
/** * Asynchronously requests the albums associated with the linked account. Requires an opened active {@link Session}. * * @param id may be {@link #ME} or a Page id. * @param callback a {@link Callback} when the request completes. * @return true if the request is made; false if no opened {@link Session} is active. */ boolean requestAlbums(String id, Callback callback) { boolean isSuccessful = false; Session session = Session.getActiveSession(); if (session != null && session.isOpened()) { // Construct fields to request. Bundle params = new Bundle(); params.putString(ALBUMS_LISTING_LIMIT_KEY, ALBUMS_LISTING_LIMIT_VALUE); params.putString(ALBUMS_LISTING_FEILDS_KEY, ALBUMS_LISTING_FIELDS_VALUE); // Construct and execute albums listing request. Request request = new Request(session, id + TO_ALBUMS_LISTING_GRAPH_PATH, params, HttpMethod.GET, callback); request.executeAsync(); isSuccessful = true; } return isSuccessful; }
private void createAlbum() { // TODO Auto-generated method stub Bundle params = new Bundle(); params.putString("name", ViewStory.this.story.getName()); params.putString("message", ViewStory.this.story.getComment()); Request request = new Request(MainActivity.session, "me/albums", params, HttpMethod.POST); request.setCallback(new Request.Callback() { @Override public void onCompleted(Response response) { // TODO Auto-generated method stub try { jo = response.getGraphObject().getInnerJSONObject().getJSONArray("data").getJSONObject(0); Toast.makeText(ViewStory.this, "ALBUM CREATION COMPLETED\n", Toast.LENGTH_LONG).show(); uploadImagesToAlbum(jo); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(ViewStory.this, "ALBUM CREATION FAILED\n", Toast.LENGTH_LONG).show(); } } }); request.executeAsync(); }
private void uploadImagesToAlbum(JSONObject jo) throws JSONException { // TODO Auto-generated method stub ArrayList<Photo> photos = db.get_photos(ViewStory.this.story.getId()); for (int i = 0; i < photos.size(); i++) { String imgUrl = photos.get(i).getUrl(); Bitmap bmp = BitmapFactory.decodeFile(imgUrl); String imgComment = photos.get(i).getComment(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); Bundle params = new Bundle(); params.putByteArray("source", byteArray); params.putString("message", imgComment); Request rr = new Request(MainActivity.session, jo.getString("id")+"/photos", params, HttpMethod.POST); rr.setCallback(new Callback() { @Override public void onCompleted(Response response) { // TODO Auto-generated method stub Toast.makeText(ViewStory.this, "PHOTO ADDED SUCESSFULLY", Toast.LENGTH_LONG).show(); } }); rr.executeAsync(); } }
private void startLoading(Request paramRequest, boolean paramBoolean, long paramLong) { this.skipRoundtripIfCached = paramBoolean; this.appendResults = false; this.nextRequest = null; this.currentRequest = paramRequest; this.currentRequest.setCallback(new Request.Callback() { public void onCompleted(Response paramAnonymousResponse) { GraphObjectPagingLoader.this.requestCompleted(paramAnonymousResponse); } }); this.loading = true; Runnable local3 = new Runnable() { public void run() { Request.executeBatchAsync(this.val$batch); } }; if (paramLong == 0L) { local3.run(); return; } new Handler().postDelayed(local3, paramLong); }
@Override public void postStatus(Activity activity, String message, AggregatorPlace place) { Session session = Session.getActiveSession(); if(session != null && session.isOpened()){ // Check for publish permissions List<String> permissions = session.getPermissions(); if(!permissions.contains("publish_stream")){ Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(activity, Arrays.asList("publish_stream")); session.requestNewPublishPermissions(newPermissionsRequest); return; } GraphPlace gPlace = null; RawPlace providerPlace = PlaceHelper.getRawPlaceFromAggregator(activity, place, Provider.FACEBOOK); if(providerPlace != null){ gPlace = GraphObject.Factory.create(GraphPlace.class); gPlace.setId(providerPlace.getRawReference()); } Request request = Request.newStatusUpdateRequest(session, message, gPlace, null, new Request.Callback(){ @Override public void onCompleted(Response response) { Log.i(TAG , "POSTED: " + response.toString()); } }); request.executeAsync(); } }
protected void getFriends(final Context context, final Session session, final GraphUser user, final ModelCallback<JSONArray> callback) { Request.newGraphPathRequest(session, "/me/friends", new Callback() { @Override public void onCompleted(Response response) { if (response.getError() != null) { callback.error(response.getError().getException()); return; } matchContacts(context, user, response, callback); } }).executeAsync(); }
@Override public RawPlace getPlaceFromReference(String id) { final Session session = Session.getActiveSession(); if (session != null & session.isOpened()) { // Make an API call to get nearby places and define a new callback to handle the response Request request = Request.newGraphPathRequest(session, id, new Callback() { @Override public void onCompleted(Response response) { } }); GraphPlace graphPlace = request.executeAndWait().getGraphObject().cast(GraphPlace.class); return createPlace(graphPlace); } return null; }