Search in sources :

Example 26 with AsyncRequest

use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.

the class AlbumPhotos method downloadAlbum.

private void downloadAlbum() {
    if (hasNoMoreData() == false) {
        Toast.makeText(getActivity(), R.string.fetch_photos_from_album, Toast.LENGTH_SHORT).show();
        new AsyncRequest(Query.ALBUM_PHOTOS_ALL, getElementId(), "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                if (response.getError() == null) {
                    downloadAlbum(response.getGraphObjectList());
                }
            }
        }).execute();
    } else {
        List<GraphObject> photos = new ArrayList<GraphObject>();
        for (GraphObject graphObject : getAdapter().getItems()) {
            photos.add(graphObject);
        }
        downloadAlbum(photos);
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 27 with AsyncRequest

use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.

the class AlbumVideos method downloadAlbum.

private void downloadAlbum() {
    if (hasNoMoreData() == false) {
        Toast.makeText(getActivity(), R.string.fetch_videos_from_album, Toast.LENGTH_SHORT).show();
        new AsyncRequest(Query.ALBUM_VIDEOS_ALL, getElementId(), "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                if (response.getError() == null) {
                    downloadAlbum(response.getGraphObjectList());
                }
            }
        }).execute();
    } else {
        List<GraphObject> videos = new ArrayList<GraphObject>();
        for (GraphObject graphObject : getAdapter().getItems()) {
            videos.add(graphObject);
        }
        downloadAlbum(videos);
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 28 with AsyncRequest

use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.

the class KlyphFragment2 method loadNewest.

protected void loadNewest() {
    newestLoading = true;
    if (getAdapter().getFirstItem() instanceof TextButtonItem) {
        getAdapter().removeFirst();
        getAdapter().notifyDataSetChanged();
    }
    String offset = null;
    /*
		 * if (KlyphPreferences.getNewsfeedGoToTop() == false && getAdapter().getCount() > 0 && getAdapter().getCount() > insertNewestToIndex)
		 * {
		 * GraphObject first = (GraphObject) getAdapter().getItem(insertNewestToIndex);
		 * offset = getNewestOffset(first);
		 * }
		 */
    AsyncRequest request = new AsyncRequest(requestNewestType, getElementId(), offset, new AsyncRequest.Callback() {

        public void onComplete(Response response) {
            Log.i("StreamListFragment", "onCompleted");
            onRequestNewestComplete(response);
        }
    });
    request.execute();
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) TextButtonItem(com.abewy.klyph.items.TextButtonItem)

Example 29 with AsyncRequest

use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.

the class Notifications method setNotificationRead.

private void setNotificationRead(Notification notification) {
    notification.setIs_unread(false);
    new AsyncRequest(Query.POST_READ_NOTIFICATION, notification.getNotification_id(), "", new AsyncRequest.Callback() {

        @Override
        public void onComplete(Response response) {
            Log.d("NotificationsNotifications", "result " + response.getError());
        }
    }).execute();
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) OnDismissCallback(com.haarman.listviewanimations.itemmanipulation.OnDismissCallback) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Example 30 with AsyncRequest

use of com.abewy.android.apps.klyph.request.AsyncRequest in project Klyph by jonathangerbaud.

the class PostShare method initWithIntent.

public void initWithIntent(Intent intent) {
    String photoId = intent.getStringExtra(KlyphBundleExtras.SHARE_PHOTO_ID);
    String videoId = intent.getStringExtra(KlyphBundleExtras.SHARE_VIDEO_ID);
    String albumId = intent.getStringExtra(KlyphBundleExtras.SHARE_ALBUM_ID);
    Stream post = intent.getParcelableExtra(KlyphBundleExtras.SHARE_POST_ID);
    String linkUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_URL);
    if (photoId != null) {
        url = PHOTO + photoId;
        new AsyncRequest(Query.PHOTO, photoId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onPhotoRequestComplete(response);
            }
        }).execute();
    } else if (videoId != null) {
        url = VIDEO + videoId;
        new AsyncRequest(Query.VIDEO, videoId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onVideoRequestComplete(response);
            }
        }).execute();
    } else if (albumId != null) {
        url = ALBUM + albumId;
        new AsyncRequest(Query.ALBUM, albumId, "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                onAlbumRequestComplete(response);
            }
        }).execute();
    } else if (post != null) {
        url = post.getPermalink();
        if (post.isStatus()) {
            fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
            getActivity().setTitle(R.string.post_share_status);
        } else {
            Attachment att = post.getAttachment();
            if (att.isPhoto() || att.isVideo() || att.isAlbum()) {
                Media media = att.getMedia().get(0);
                if (att.isAlbum()) {
                    fillViews(post.getActor_name(), att.getName(), media.getSrc());
                } else {
                    fillViews(post.getActor_name(), media.getAlt(), media.getSrc());
                }
                if (att.isPhoto())
                    getActivity().setTitle(R.string.post_share_photo);
                else if (att.isVideo())
                    getActivity().setTitle(R.string.post_share_video);
                else
                    getActivity().setTitle(R.string.post_share_album);
            } else {
                getActivity().setTitle(R.string.post_share_status);
                fillViews(post.getActor_name(), post.getMessage(), post.getActor_pic());
            }
        }
    } else if (linkUrl != null) {
        isLink = true;
        url = linkUrl;
        imageUrl = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_IMAGE_URL);
        String linkName = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_NAME);
        String linkDesc = intent.getStringExtra(KlyphBundleExtras.SHARE_LINK_DESC);
        fillViews(linkName, linkDesc, imageUrl);
        getActivity().setTitle(R.string.post_share_link);
    } else {
        Log.d("PostShare", "All null");
    }
    if (isLink == false) {
        ((ViewGroup) spinner.getParent()).setVisibility(View.GONE);
    } else {
        SpinnerAdapter adapter = new SpinnerAdapter(getActivity());
        spinner.setAdapter(adapter);
        Friend friend = new Friend();
        friend.setName(getString(R.string.post_share_on_my_wall));
        adapter.add(friend);
        friend = new Friend();
        friend.setName(getString(R.string.post_share_on_friend_wall));
        adapter.add(friend);
        adapter.notifyDataSetChanged();
        spinner.setSelection(0);
        spinner.setOnItemSelectedListener(this);
        previousPosition = 0;
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Friend(com.abewy.android.apps.klyph.core.fql.Friend) ViewGroup(android.view.ViewGroup) Media(com.abewy.android.apps.klyph.core.fql.Media) Stream(com.abewy.android.apps.klyph.core.fql.Stream) Attachment(com.abewy.android.apps.klyph.core.fql.Attachment)

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