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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations