Search in sources :

Example 6 with FacebookException

use of com.facebook.FacebookException in project Klyph by jonathangerbaud.

the class ProfilePictureView method processResponse.

private void processResponse(ImageResponse response) {
    // 2. Detached this view, in which case the response should be discarded.
    if (response.getRequest() == lastRequest) {
        lastRequest = null;
        Bitmap responseImage = response.getBitmap();
        Exception error = response.getError();
        if (error != null) {
            OnErrorListener listener = onErrorListener;
            if (listener != null) {
                listener.onError(new FacebookException("Error in downloading profile picture for profileId: " + getProfileId(), error));
            } else {
                Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, error.toString());
            }
        } else if (responseImage != null) {
            setImageBitmap(responseImage);
            if (response.isCachedRedirect()) {
                sendImageRequest(false);
            }
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) FacebookException(com.facebook.FacebookException) FacebookException(com.facebook.FacebookException) URISyntaxException(java.net.URISyntaxException)

Example 7 with FacebookException

use of com.facebook.FacebookException in project Klyph by jonathangerbaud.

the class PlacePickerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    destroyed = false;
    setTitle(R.string.choose_place);
    placePickerFragment = (KlyphPlacePickerFragment) getSupportFragmentManager().findFragmentById(R.id.place_picker_fragment);
    placePickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() {

        @Override
        public void onSelectionChanged(PickerFragment<?> fragment) {
            GraphPlace place = placePickerFragment.getSelection();
            if (place != null) {
                Intent intent = new Intent();
                intent.putExtra(KlyphBundleExtras.PLACE_ID, place.getId());
                intent.putExtra(KlyphBundleExtras.PLACE_NAME, place.getName());
                setResult(RESULT_OK, intent);
                finish();
            }
        }
    });
    placePickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {

        @Override
        public void onError(PickerFragment<?> fragment, FacebookException error) {
            PlacePickerActivity.this.onError(error);
        }
    });
    placePickerFragment.setShowTitleBar(false);
}
Also used : FacebookException(com.facebook.FacebookException) KlyphPlacePickerFragment(com.facebook.widget.KlyphPlacePickerFragment) PickerFragment(com.facebook.widget.PickerFragment) Intent(android.content.Intent) GraphPlace(com.facebook.model.GraphPlace)

Example 8 with FacebookException

use of com.facebook.FacebookException in project Klyph by jonathangerbaud.

the class PostActivity method publishPost.

private void publishPost() {
    Log.d("PostActivity", "Publish post try " + numTry);
    Log.d("PostActivity", "Publish post privacy " + privacy.toString());
    if (photoUris.size() > 0) {
        publishPhotos();
    } else if (shareFragment.isVisible()) {
        Bundle params = shareFragment.getParams();
        setPrivacyParams(params);
        if (shareFragment.isFriendShare()) {
            WebDialog dialog = new WebDialog.FeedDialogBuilder(this, Session.getActiveSession(), params).build();
            dialog.setOnCompleteListener(new WebDialog.OnCompleteListener() {

                @Override
                public void onComplete(Bundle values, FacebookException error) {
                    if (error == null) {
                        // When the story is posted, close activity
                        final String postId = values.getString("post_id");
                        if (postId != null) {
                            finish();
                        }
                    }
                }
            });
            dialog.show();
        } else {
            params.putString("message", messageTextView.getText().toString());
            sendRequest(Query.POST_STATUS, elementId, params);
        }
    } else if (linkFragment.isVisible()) {
        Bundle params = linkFragment.getParams();
        params.putString("message", messageTextView.getText().toString());
        if (isGroupMessage == false)
            setPrivacyParams(params);
        // params.putString("privacy", "{'value':'" + privacy.toString() + "'}");
        sendRequest(Query.POST_STATUS, elementId, params);
    } else {
        Bundle params = new Bundle();
        params.putString("message", messageTextView.getText().toString());
        if (placeId != null && placeId != "") {
            params.putString("place", placeId);
            if (friends != null && friends.size() > 0) {
                StringBuilder ids = new StringBuilder();
                for (String key : friends.keySet()) {
                    ids.append(key).append(",");
                }
                params.putString("tags", ids.substring(0, ids.length() - 1));
            }
        }
        if (isEventMessage == false && isGroupMessage == false && isPageMessage == false) {
            setPrivacyParams(params);
        // params.putString("privacy", "{'value':'" + privacy.toString() + "'}");
        }
        sendRequest(Query.POST_STATUS, elementId, params);
    }
}
Also used : Bundle(android.os.Bundle) WebDialog(com.facebook.widget.WebDialog) FacebookException(com.facebook.FacebookException)

Example 9 with FacebookException

use of com.facebook.FacebookException in project Klyph by jonathangerbaud.

the class KlyphPlacePickerFragment method onSearchTextTimerTriggered.

private void onSearchTextTimerTriggered() {
    if (hasSearchTextChangedSinceLastQuery) {
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {

            @Override
            public void run() {
                FacebookException error = null;
                try {
                    loadData(true);
                } catch (FacebookException fe) {
                    error = fe;
                } catch (Exception e) {
                    error = new FacebookException(e);
                } finally {
                    if (error != null) {
                        OnErrorListener onErrorListener = getOnErrorListener();
                        if (onErrorListener != null) {
                            onErrorListener.onError(KlyphPlacePickerFragment.this, error);
                        } else {
                            Logger.log(LoggingBehavior.REQUESTS, TAG, "Error loading data : %s", error);
                        }
                    }
                }
            }
        });
    } else {
        // Nothing has changed in 2 seconds. Invalidate and forget about this timer.
        // Next time the user types, we will fire a query immediately again.
        searchTextTimer.cancel();
        searchTextTimer = null;
    }
}
Also used : FacebookException(com.facebook.FacebookException) Handler(android.os.Handler) FacebookException(com.facebook.FacebookException)

Example 10 with FacebookException

use of com.facebook.FacebookException in project Klyph by jonathangerbaud.

the class UserTimeline method publishFeedDialog.

private void publishFeedDialog() {
    Bundle params = new Bundle();
    params.putString("from", KlyphSession.getSessionUserId());
    params.putString("to", getElementId());
    WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(getActivity(), Session.getActiveSession(), params)).setOnCompleteListener(new WebDialog.OnCompleteListener() {

        @Override
        public void onComplete(Bundle values, FacebookException error) {
            if (error == null) {
                final String postId = values.getString("post_id");
                if (postId != null) {
                    Toast.makeText(getActivity(), R.string.message_successfully_published, Toast.LENGTH_SHORT).show();
                    loadNewest();
                } else {
                    // User clicked the Cancel button
                    Toast.makeText(getActivity().getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                }
            } else if (error instanceof FacebookOperationCanceledException) {
            // User clicked the "x" button
            // Toast.makeText(getActivity().getApplicationContext(),
            // "Publish cancelled",
            // Toast.LENGTH_SHORT).show();
            } else {
                AlertUtil.showAlert(getActivity(), R.string.error, R.string.publish_message_unknown_error, R.string.ok);
            }
        }
    }).build();
    feedDialog.show();
}
Also used : FacebookOperationCanceledException(com.facebook.FacebookOperationCanceledException) Bundle(android.os.Bundle) WebDialog(com.facebook.widget.WebDialog) FacebookException(com.facebook.FacebookException)

Aggregations

FacebookException (com.facebook.FacebookException)70 Bundle (android.os.Bundle)24 JSONObject (org.json.JSONObject)24 JSONException (org.json.JSONException)19 Bitmap (android.graphics.Bitmap)13 GraphRequest (com.facebook.GraphRequest)10 JSONArray (org.json.JSONArray)10 Intent (android.content.Intent)9 Uri (android.net.Uri)8 GraphResponse (com.facebook.GraphResponse)8 URISyntaxException (java.net.URISyntaxException)8 AccessToken (com.facebook.AccessToken)7 FacebookOperationCanceledException (com.facebook.FacebookOperationCanceledException)5 FacebookRequestError (com.facebook.FacebookRequestError)5 LoginResult (com.facebook.login.LoginResult)5 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)5 HttpURLConnection (java.net.HttpURLConnection)5 URL (java.net.URL)5