use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.
the class PageTimeline method doLikeAction.
private void doLikeAction() {
final Page page = (Page) getElement();
if (page.getIs_fan() == false) {
page.setIs_fan(true);
((FragmentActivity) getActivity()).invalidateOptionsMenu();
new AsyncRequest(Query.POST_LIKE, page.getPage_id(), "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.i("onComplete", "" + response.getError());
onLikeRequestComplete(response);
}
}).execute();
} else {
page.setIs_fan(false);
((FragmentActivity) getActivity()).invalidateOptionsMenu();
new AsyncRequest(Query.POST_UNLIKE, page.getPage_id(), "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.i("onComplete", "" + response.getError());
onUnlikeRequestComplete(response);
}
}).execute();
}
}
use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.
the class StreamFragment method doLikeCommentAction.
private void doLikeCommentAction(final Comment comment) {
if (comment.getUser_likes() == false) {
comment.setUser_likes(true);
comment.setLike_count(comment.getLike_count() + 1);
String commentId = comment.getId();
// if (!commentId.contains("_"))
// commentId = comment.getObject_id() + "_" + commentId;
new AsyncRequest(Query.POST_LIKE, commentId, "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.d("onComplete", "" + response.getError());
onCommentLikeRequestComplete(response, comment);
}
}).execute();
} else {
comment.setUser_likes(false);
comment.setLike_count(comment.getLike_count() - 1);
getAdapter().notifyDataSetChanged();
String commentId = comment.getId();
// if (!commentId.contains("_"))
// commentId = comment.getObject_id() + "_" + commentId;
new AsyncRequest(Query.POST_UNLIKE, commentId, "", new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
Log.d("onComplete", "" + response.getError());
onCommentUnlikeRequestComplete(response, comment);
}
}).execute();
}
}
use of com.abewy.android.apps.klyph.core.request.Response in project Klyph by jonathangerbaud.
the class StreamFragment method handleSendReplyAction.
private void handleSendReplyAction(final Comment comment, String reply) {
if (reply.length() > 0) {
Bundle params = new Bundle();
params.putString("message", reply);
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, comment.getId(), params, new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
publishing.hide();
onReplyCommentRequestComplete(response, comment);
}
}).execute();
} else {
new AlertDialog.Builder(getActivity()).setTitle(R.string.error).setMessage(R.string.define_comment_before_publish).setPositiveButton(R.string.ok, null).create().show();
}
}
use of com.abewy.android.apps.klyph.core.request.Response 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.core.request.Response in project Klyph by jonathangerbaud.
the class StreamFragment method sendRequest.
private void sendRequest(Bundle params) {
if (dialog == null) {
dialog = AlertUtil.showAlert(getActivity(), R.string.publish_comment_dialog_title, R.string.publish_comment_dialog_message);
dialog.setCancelable(false);
}
new AsyncRequest(Query.POST_COMMENT, getElementId(), params, new AsyncRequest.Callback() {
@Override
public void onComplete(Response response) {
onCommentRequestComplete(response);
}
}).execute();
}
Aggregations