use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class PhotoAdapter method doLikeAction.
private void doLikeAction(final PhotoHolder holder, final Photo photo) {
// manageLikeButton(holder, stream, subStream, false);
final Context context = getContext(holder.getAuthorProfileImage());
if (!photo.getLike_info().getUser_likes()) {
photo.getLike_info().setUser_likes(true);
photo.getLike_info().setLike_count(photo.getLike_info().getLike_count() + 1);
manageLikeButton(holder, photo);
holder.getLikeButton().setEnabled(false);
new AsyncRequest(Query.POST_LIKE, photo.getObject_id(), "", 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();
photo.getLike_info().setUser_likes(false);
photo.getLike_info().setLike_count(photo.getLike_info().getLike_count() - 1);
}
holder.getLikeButton().setEnabled(true);
manageLikeButton(holder, photo);
parentAdapter.notifyDataSetChanged();
}
}).execute();
parentAdapter.notifyDataSetChanged();
} else {
photo.getLike_info().setUser_likes(false);
photo.getLike_info().setLike_count(photo.getLike_info().getLike_count() - 1);
manageLikeButton(holder, photo);
holder.getLikeButton().setEnabled(false);
new AsyncRequest(Query.POST_UNLIKE, photo.getObject_id(), "", 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();
photo.getLike_info().setUser_likes(true);
photo.getLike_info().setLike_count(photo.getLike_info().getLike_count() + 1);
}
holder.getLikeButton().setEnabled(true);
manageLikeButton(holder, photo);
parentAdapter.notifyDataSetChanged();
}
}).execute();
parentAdapter.notifyDataSetChanged();
}
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class AlbumSpinner method createAlbum.
@Override
public void createAlbum(final Album album, String privacy) {
Bundle bundle = new Bundle();
bundle.putString("name", album.getName());
bundle.putString("location", album.getLocation());
bundle.putString("message", album.getDescription());
bundle.putString("privacy", privacy);
final AlertDialog dialog = AlertUtil.showAlert(getActivity(), R.string.new_album, R.string.creating_album);
new AsyncRequest(Query.NEW_ALBUM, "", bundle, new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
dialog.dismiss();
if (response.getError() == null) {
Log.d("AlbumSpinner", "createAlbum id = " + response.getReturnedId());
album.setObject_id(response.getReturnedId());
((SpinnerAdapter) spinner.getAdapter()).add(album);
((SpinnerAdapter) spinner.getAdapter()).notifyDataSetChanged();
spinner.setSelection(spinner.getCount() - 1);
} else {
Toast.makeText(getActivity(), R.string.request_error, Toast.LENGTH_SHORT).show();
}
}
}).execute();
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class AlbumSpinner method loadAlbums.
private void loadAlbums() {
AsyncRequest request = new AsyncRequest(Query.UPLOADABLE_ALBUM, KlyphSession.getSessionUserId(), "", new AsyncRequest.Callback() {
public void onComplete(Response response) {
onRequestComplete(response);
}
});
request.execute();
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class EventFragment method sendRequest.
private void sendRequest(int query) {
final EventResponse eventResponse;
switch(query) {
case Query.POST_EVENT_ATTEND:
{
eventResponse = EventResponse.ATTENDING;
break;
}
case Query.POST_EVENT_UNSURE:
{
eventResponse = EventResponse.UNSURE;
break;
}
case Query.POST_EVENT_DECLINE:
{
eventResponse = EventResponse.DECLINED;
break;
}
default:
{
eventResponse = EventResponse.NOT_REPLIED;
break;
}
}
final AlertDialog publishing = new AlertDialog.Builder(getActivity()).setTitle(R.string.event_response_dialog_title).setMessage(R.string.event_response_dialog_message).setCancelable(false).create();
publishing.show();
new AsyncRequest(query, event.getEid(), "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
publishing.dismiss();
onRequestComplete(response, eventResponse);
}
}).execute();
}
use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.
the class ImageFragment method postComment.
private void postComment() {
if (sendTextEdit.getText().toString().length() > 0) {
Bundle params = new Bundle();
params.putString("message", sendTextEdit.getText().toString());
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(sendTextEdit.getWindowToken(), 0);
final AlertDialog publishing = new AlertDialog.Builder(getActivity()).setTitle(R.string.publish_comment_dialog_title).setMessage(R.string.publish_comment_dialog_message).setCancelable(false).create();
publishing.show();
new AsyncRequest(Query.POST_COMMENT, getElementId(), params, new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
publishing.hide();
onCommentRequestComplete(response);
}
}).execute();
} else {
new AlertDialog.Builder(getActivity()).setTitle(R.string.error).setMessage(R.string.define_comment_before_publish).setPositiveButton(R.string.ok, null).create().show();
}
}
Aggregations