Search in sources :

Example 11 with Response

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();
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) FragmentActivity(android.support.v4.app.FragmentActivity) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Page(com.abewy.android.apps.klyph.core.fql.Page)

Example 12 with Response

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();
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Example 13 with Response

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();
    }
}
Also used : AlertDialog(android.app.AlertDialog) Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback) Bundle(android.os.Bundle)

Example 14 with Response

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();
    }
}
Also used : Context(android.content.Context) Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Example 15 with Response

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();
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Aggregations

Response (com.abewy.android.apps.klyph.core.request.Response)34 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)34 IFbPermissionCallback (com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)17 AlertDialog (android.app.AlertDialog)9 ArrayList (java.util.ArrayList)5 Bundle (android.os.Bundle)4 Callback (com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback)4 Context (android.content.Context)3 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)3 TagCallback (com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback)3 Intent (android.content.Intent)2 View (android.view.View)2 ImageButton (android.widget.ImageButton)2 TextView (android.widget.TextView)2 Photo (com.abewy.android.apps.klyph.core.fql.Photo)2 TextButtonItem (com.abewy.klyph.items.TextButtonItem)2 Uri (android.net.Uri)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 ViewGroup (android.view.ViewGroup)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1