use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class PostActivity method sendRequest.
private void sendRequest(int query, String id, Bundle params) {
if (dialog == null) {
dialog = AlertUtil.showAlert(this, R.string.status, R.string.publishing);
dialog.setCancelable(false);
}
new AsyncRequest(query, id, params, new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
onRequestResponse(response);
}
}).execute();
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class PostPhotosActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
photoUris = new ArrayList<String>();
setTitle(R.string.publish_new_photos);
messageTextView = (TextView) findViewById(R.id.message_textview);
friendsTextView = (TextView) findViewById(R.id.friends_textview);
placeTextView = (TextView) findViewById(R.id.place_textview);
photosFragment = (PostPhotos) getFragmentManager().findFragmentById(R.id.photos_fragment);
albumsFragment = (AlbumSpinner) getFragmentManager().findFragmentById(R.id.albums_fragment);
albumsFragment.setDefaultAlbumId(getIntent().getExtras().getString(KlyphBundleExtras.ALBUM_ID));
albumsFragment.setOnSelectionChangeListener(this);
getFragmentManager().beginTransaction().hide(photosFragment).commit();
ImageButton placeDeleteButton = (ImageButton) findViewById(R.id.place_delete_button);
ImageButton friendsDeleteButton = (ImageButton) findViewById(R.id.friends_delete_button);
friendsButton = (ImageButton) findViewById(R.id.friends_button);
ImageButton add = (ImageButton) findViewById(R.id.add_button);
ImageButton place = (ImageButton) findViewById(R.id.place_button);
privacyButton = (ImageButton) findViewById(R.id.privacy_button);
privacyButton.setEnabled(false);
placeDeleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clearPlace();
}
});
friendsDeleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clearFriends();
}
});
friendsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(PostPhotosActivity.this, FriendPickerActivity.class);
if (friends != null && friends.size() > 0) {
ArrayList<String> ids = new ArrayList<String>();
ids.addAll(friends.keySet());
intent.putStringArrayListExtra(KlyphBundleExtras.FRIEND_PICKER_IDS, ids);
}
startActivityForResult(intent, FRIEND_PICKER);
}
});
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startGallery();
}
});
place.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent(PostPhotosActivity.this, PlacePickerActivity.class), PLACE_PICKER);
}
});
setPrivacyListenerApi11();
setPrivacy(KlyphPreferences.getPrivacy());
if (KlyphData.getFriendLists() == null) {
new AsyncRequest(Query.FRIEND_LISTS, "", "", new Callback() {
@Override
public void onComplete(Response response) {
onRequestComplete(response);
}
}).execute();
}
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class ImageActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
// requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
// Let the Application class know that the first launch is complete
// If we come from a notification, then do not show the ads
// When going back to main activity
KlyphApplication.getInstance().launchComplete();
isDestroyed = false;
getWindow().setBackgroundDrawableResource(R.drawable.image_background);
getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background_transparent_gradient));
setTitle("");
final ImageFragment image = (ImageFragment) getFragmentManager().findFragmentById(R.id.image_fragment);
String photoId = getIntent().getStringExtra(KlyphBundleExtras.PHOTO_ID);
Log.d("ImageActivity", "photo id " + photoId);
String userId = getIntent().getStringExtra(KlyphBundleExtras.USER_ID);
if (photoId != null) {
image.setElementId(photoId);
// image.load();
} else if (userId != null) {
AsyncRequest loadRequest = new AsyncRequest(Query.USER_PROFILE_PHOTO, userId, "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
if (response.getError() == null) {
if (response.getGraphObjectList().size() > 0 && isDestroyed == false) {
Photo photo = (Photo) response.getGraphObjectList().get(0);
image.setElementId(photo.getObject_id());
image.load();
}
}
}
});
loadRequest.execute();
}
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class StreamButtonBar method doLikeAction.
private void doLikeAction(final IStreamHolder holder, final Stream stream, final GraphObject subStream) {
manageLikeButton(holder, stream, subStream, false);
final Context context = getContext(holder.getAuthorProfileImage());
if (getUserLikes(stream, subStream) == false) {
setLikes(stream, subStream, true);
manageLikeButton(holder, stream, subStream, false);
Log.d("StreamButtonBar", "doLikeAction: " + stream.getPost_id());
Log.d("StreamButtonBar", "doLikeAction: " + subStream);
Log.d("StreamButtonBar", "doLikeAction: " + getId(stream, subStream));
new AsyncRequest(Query.POST_LIKE, getId(stream, subStream), "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.d("onComplete", "" + response.getError());
if (response.getError() != null) {
Toast.makeText(context, R.string.like_error, Toast.LENGTH_SHORT).show();
setLikes(stream, subStream, false);
}
manageLikeButton(holder, stream, subStream, true);
getParentAdapter().notifyDataSetChanged();
}
}).execute();
} else {
setLikes(stream, subStream, false);
manageLikeButton(holder, stream, subStream, false);
new AsyncRequest(Query.POST_UNLIKE, getId(stream, subStream), "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.d("onComplete", "" + response.getError());
if (response.getError() != null) {
Toast.makeText(context, R.string.unlike_error, Toast.LENGTH_SHORT).show();
setLikes(stream, subStream, true);
}
manageLikeButton(holder, stream, subStream, true);
getParentAdapter().notifyDataSetChanged();
}
}).execute();
}
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class KlyphListActivity method refresh.
protected void refresh() {
startLoading();
Log.i(TAG, "request = " + requestType + ", id = " + elementId + ", offset = " + offset);
AsyncRequest request = new AsyncRequest(requestType, elementId, offset, new AsyncRequest.Callback() {
public void onComplete(Response response) {
Log.i(TAG, "onCompleted");
onRequestComplete(response);
}
});
request.execute();
}
Aggregations