Search in sources :

Example 71 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class PeriodicNotificationRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray urls = result[1];
    JSONArray names = result[2];
    JSONArray friends = result[3];
    JSONArray events = result[4];
    JSONArray pages = result[5];
    JSONArray groups = result[6];
    JSONArray comments = result[7];
    Log.d("NotificationRequest", "size " + data.length());
    assocData(data, urls, "sender_id", "id", "sender_pic", "url");
    assocData(data, names, "sender_id", "id", "sender_name", "name");
    assocStreamToObjectById(data, friends, "object_id", "uid", "friend");
    assocStreamToObjectById(data, events, "object_id", "eid", "event");
    assocStreamToObjectById(data, pages, "object_id", "page_id", "page");
    assocStreamToObjectById(data, groups, "object_id", "gid", "group");
    assocStreamToObjectById(data, comments, "object_id", "object_id", "comment");
    NotificationDeserializer deserializer = new NotificationDeserializer();
    ArrayList<GraphObject> notifications = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    return notifications;
}
Also used : NotificationDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.NotificationDeserializer) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 72 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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 73 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class AlbumSpinner method onRequestSuccess.

private void onRequestSuccess(List<GraphObject> result) {
    if (progress != null) {
        progress.setVisibility(View.GONE);
    }
    if (// Check if view is created
    spinner != null && getActivity() != null) {
        SpinnerAdapter adapter = (SpinnerAdapter) spinner.getAdapter();
        Album album = new Album();
        album.setObject_id("me");
        album.setName(getString(R.string.upload_photo_default_album_name));
        adapter.add(album);
        for (GraphObject graphObject : result) {
            adapter.add((Album) graphObject);
        }
        adapter.notifyDataSetChanged();
        setDefaultId();
        spinner.setVisibility(View.VISIBLE);
    }
}
Also used : Album(com.abewy.android.apps.klyph.core.fql.Album) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 74 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject 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 75 with GraphObject

use of com.abewy.android.apps.klyph.core.graph.GraphObject in project Klyph by jonathangerbaud.

the class GalleryFragment method setCursor.

public void setCursor(Cursor cursor) {
    if (cursorLoaded == false) {
        MultiObjectAdapter adapter = new MultiObjectAdapter(getListView()) {

            @Override
            protected TypeAdapter<GraphObject> getAdapter(GraphObject object, int layoutType) {
                TypeAdapter<GraphObject> adapter = BaseAdapterSelector.getAdapter(object, layoutType);
                if (adapter != null)
                    return adapter;
                if (object instanceof Picture)
                    return new GalleryAdapter();
                if (object instanceof CameraObject)
                    return new CameraObjectAdapter();
                return null;
            }
        };
        if (cursor != null && cursor.isClosed() == false) {
            int n = cursor.getCount();
            int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            for (int i = 0; i < n; i++) {
                cursor.moveToPosition(i);
                imageUris.add(cursor.getString(columnIndex));
                adapter.add(new Picture(cursor.getString(columnIndex)));
            }
            if (showCamera && hasCamera) {
                adapter.insert(new CameraObject(), 0);
            }
            getGridView().setAdapter(adapter);
            getGridView().setVisibility(View.VISIBLE);
            n = adapter.getCount();
            int nSelected = 0;
            for (int i = 0; i < n; i++) {
                if (adapter.getItem(i) instanceof Picture) {
                    Picture image = (Picture) adapter.getItem(i);
                    // Log.d("GalleryFragment", "uri = " + image.getUri());
                    for (String uri : initUris) {
                        if (image.getUri().equals(uri)) {
                            getGridView().setItemChecked(i, true);
                            nSelected++;
                            break;
                        }
                    }
                }
            }
            adapter.notifyDataSetChanged();
            if (nSelected > 0) {
                if (actionMode == null)
                    actionMode = getActivity().startActionMode(mActionModeCallback);
                refreshActionModeTitle();
            }
            cursor.close();
        } else {
            if (showCamera && hasCamera) {
                adapter.insert(new CameraObject(), 0);
            }
            getGridView().setAdapter(adapter);
        }
        cursorLoaded = true;
    }
    loadingView.setVisibility(View.GONE);
    getGridView().setVisibility(View.VISIBLE);
    ((View) getGridView().getParent()).setVisibility(View.VISIBLE);
}
Also used : MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)101 ArrayList (java.util.ArrayList)71 JSONArray (org.json.JSONArray)41 JSONObject (org.json.JSONObject)16 FriendDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.FriendDeserializer)11 PhotoDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.PhotoDeserializer)9 MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)7 Stream (com.abewy.android.apps.klyph.core.fql.Stream)7 View (android.view.View)6 KlyphNotification (com.abewy.android.apps.klyph.KlyphNotification)6 Notification (com.abewy.android.apps.klyph.core.fql.Notification)6 Photo (com.abewy.android.apps.klyph.core.fql.Photo)6 JSONException (org.json.JSONException)6 StreamDeserializer (com.abewy.android.apps.klyph.core.fql.serializer.StreamDeserializer)5 Intent (android.content.Intent)4 ListView (android.widget.ListView)4 Event (com.abewy.android.apps.klyph.core.fql.Event)4 AsyncRequest (com.abewy.android.apps.klyph.request.AsyncRequest)4 TextButtonItem (com.abewy.klyph.items.TextButtonItem)4 AbsListView (android.widget.AbsListView)3