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);
}
}
}
}
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);
}
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);
}
}
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;
}
}
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();
}
Aggregations