Search in sources :

Example 21 with AsyncRequest

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

Example 22 with AsyncRequest

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();
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) ImageButton(android.widget.ImageButton) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback) Callback(com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback) TagCallback(com.abewy.android.apps.klyph.util.TextViewUtil.TagCallback) ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView)

Example 23 with AsyncRequest

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

Example 24 with AsyncRequest

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();
    }
}
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 25 with AsyncRequest

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

Aggregations

AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)37 Response (com.abewy.android.apps.klyph.core.request.Response)34 IFbPermissionCallback (com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)17 AlertDialog (android.app.AlertDialog)9 ArrayList (java.util.ArrayList)6 Bundle (android.os.Bundle)4 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)4 Callback (com.abewy.android.apps.klyph.core.request.BaseAsyncRequest.Callback)4 Context (android.content.Context)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 UiLifecycleHelper (com.facebook.UiLifecycleHelper)2 Uri (android.net.Uri)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 ViewGroup (android.view.ViewGroup)1