Search in sources :

Example 21 with GraphObject

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

the class GalleryFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    loadingView = (ProgressBar) view.findViewById(android.R.id.progress);
    setListVisible(false);
    super.onViewCreated(view, savedInstanceState);
    imageUris = new ArrayList<String>();
    getGridView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    getGridView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> gridView, View view, int position, long id) {
            GraphObject o = getAdapter().getItem(position);
            if (o instanceof CameraObject) {
                Intent intent = new Intent(getActivity(), GalleryActivity.class);
                intent.putExtra(KlyphBundleExtras.CAMERA_PICTURES, true);
                intent.putStringArrayListExtra(KlyphBundleExtras.PHOTO_LIST_URI, (ArrayList<String>) initUris);
                startActivityForResult(intent, CAMERA_GALLERY_CODE);
            } else {
                if (!Android.isMinAPI(11)) {
                    CheckableGalleryLayout cgl = (CheckableGalleryLayout) view;
                    cgl.toggle();
                    Picture image = (Picture) o;
                    image.setSelected(cgl.isChecked());
                }
                if (actionMode == null)
                    actionMode = getActivity().startActionMode(mActionModeCallback);
                refreshActionModeTitle();
            }
        }
    });
    showCamera = !getActivity().getIntent().getBooleanExtra(KlyphBundleExtras.CAMERA_PICTURES, false);
    hasCamera = getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) || getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    defineEmptyText(R.string.empty_list_no_photo);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) Intent(android.content.Intent) GalleryActivity(com.abewy.android.apps.klyph.app.GalleryActivity) 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) CheckableGalleryLayout(com.abewy.android.apps.klyph.widget.CheckableGalleryLayout)

Example 22 with GraphObject

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

the class SearchUserRequest method handleResult.

@Override
public List<GraphObject> handleResult(JSONArray result) {
    Log.d("SearchUser", "handleResult");
    List<GraphObject> list = new ArrayList<GraphObject>();
    int n = result.length();
    for (int i = 0; i < n; i++) {
        Friend friend = new Friend();
        JSONObject json = result.optJSONObject(i);
        friend.setUid(json.optString("id"));
        friend.setName(json.optString("name"));
        JSONObject pic = json.optJSONObject("picture");
        JSONObject data = pic.optJSONObject("data");
        friend.setPic(data.optString("url"));
        list.add(friend);
    }
    setHasMoreData(false);
    return list;
}
Also used : Friend(com.abewy.android.apps.klyph.core.fql.Friend) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 23 with GraphObject

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

the class ThreadRequest method handleResult.

@Override
public ArrayList<GraphObject> handleResult(JSONArray[] result) {
    JSONArray data = result[0];
    JSONArray users = result[1];
    JSONArray recipients = result[2];
    JSONArray user_pics = result[3];
    assocData(recipients, users, "id", "uid", "first_name", "first_name");
    assocData(recipients, user_pics, "id", "id", "pic", "url");
    assocData(recipients, recipients, "id", "id", "uid", "id");
    assocData3(data, recipients, "recipients", "id", "recipients_friends");
    MessageThreadDeserializer deserializer = new MessageThreadDeserializer();
    ArrayList<GraphObject> mts = (ArrayList<GraphObject>) deserializer.deserializeArray(data);
    setHasMoreData(mts.size() >= 15);
    return mts;
}
Also used : JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) MessageThreadDeserializer(com.abewy.android.apps.klyph.core.fql.serializer.MessageThreadDeserializer) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 24 with GraphObject

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

the class KlyphFragment method populate.

protected void populate(List<GraphObject> data) {
    if (getView() != null) {
        MultiObjectAdapter adapter = getAdapter();
        for (GraphObject graphObject : data) {
            adapter.add(graphObject);
        }
        // adapter.addAll(data); is only available in api 11
        endLoading();
        boolean requestHasMoreData = request != null && request.hasMoreData();
        if (data.size() == 0 || !requestHasMoreData)
            noMoreData = true;
        offset = String.valueOf(adapter.getCount());
    }
}
Also used : MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 25 with GraphObject

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

the class EventFragment method populate.

@Override
protected void populate(List<GraphObject> data) {
    Log.d("EventFragment", "populate: " + data.size());
    if (data.size() > 0) {
        GraphObject o = data.get(0);
        if (o instanceof Event) {
            event = (Event) o;
            data.remove(0);
            if (getActivity() != null)
                getActivity().setTitle(event.getName());
            List<GraphObject> list = new ArrayList<GraphObject>();
            list.add(event);
            EventData eventData = new EventData(event);
            list.add(eventData);
            EventResponseItem responseItem = new EventResponseItem(event);
            responseItem.setAttendButtonListener(attendButtonListener);
            responseItem.setUnsureButtonListener(unsureButtonListener);
            responseItem.setDeclineButtonListener(declinedButtonListener);
            list.add(responseItem);
            EventAttendees attendeesItem = new EventAttendees(event);
            attendeesItem.setInvitedListener(invitedGuestListener);
            attendeesItem.setGoingListener(goingGuestListener);
            attendeesItem.setUnsureListener(unsureGuestListener);
            attendeesItem.setDeclinedListener(declinedGuestListener);
            list.add(attendeesItem);
            list.addAll(data);
            data = list;
            getActivity().invalidateOptionsMenu();
        }
    }
    super.populate(data);
    setNoMoreData(true);
}
Also used : ArrayList(java.util.ArrayList) Event(com.abewy.android.apps.klyph.core.fql.Event) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

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