Search in sources :

Example 11 with AsyncRequest

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

the class KlyphFragment method refresh.

protected void refresh() {
    startLoading();
    if (KlyphFlags.LOG_REQUEST_EXEC)
        Log.d(TAG, "request = " + requestType + ", id = " + elementId + ", offset = " + offset);
    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)

Example 12 with AsyncRequest

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

the class KlyphFragment2 method refresh.

protected void refresh() {
    startLoading();
    if (KlyphFlags.LOG_REQUEST_EXEC)
        Log.d(TAG, "request = " + requestType + ", id = " + elementId + ", offset = " + offset);
    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)

Example 13 with AsyncRequest

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

the class Notifications method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_dismiss) {
        List<GraphObject> list = new ArrayList<GraphObject>();
        List<List<AsyncRequest>> batchs = new ArrayList<List<AsyncRequest>>();
        List<AsyncRequest> requests = new ArrayList<AsyncRequest>();
        batchs.add(requests);
        for (GraphObject o : getAdapter().getItems()) {
            if (o instanceof Notification || o instanceof FriendRequest) {
                if (o instanceof Notification) {
                    Notification n = (Notification) o;
                    if (requests.size() == 40) {
                        requests = new ArrayList<AsyncRequest>();
                        batchs.add(requests);
                    }
                    requests.add(new AsyncRequest(Query.POST_READ_NOTIFICATION, n.getNotification_id(), "", null));
                    n.setIs_unread(false);
                }
                list.add(o);
            }
        }
        populate(list);
        unreadCount = 0;
        getActivity().invalidateOptionsMenu();
        for (List<AsyncRequest> batch : batchs) {
            if (batch.size() > 0)
                AsyncRequest.executeBatch(batch);
        }
        ((NotificationsListener) getActivity()).onNewNotifications();
        return true;
    } else if (item.getItemId() == R.id.menu_refresh) {
        onRefreshClicked();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FriendRequest(com.abewy.android.apps.klyph.core.fql.FriendRequest) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) Notification(com.abewy.android.apps.klyph.core.fql.Notification) KlyphNotification(com.abewy.android.apps.klyph.KlyphNotification)

Example 14 with AsyncRequest

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

the class PageTimeline method doLikeAction.

private void doLikeAction() {
    final Page page = (Page) getElement();
    if (page.getIs_fan() == false) {
        page.setIs_fan(true);
        ((FragmentActivity) getActivity()).invalidateOptionsMenu();
        new AsyncRequest(Query.POST_LIKE, page.getPage_id(), "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                Log.i("onComplete", "" + response.getError());
                onLikeRequestComplete(response);
            }
        }).execute();
    } else {
        page.setIs_fan(false);
        ((FragmentActivity) getActivity()).invalidateOptionsMenu();
        new AsyncRequest(Query.POST_UNLIKE, page.getPage_id(), "", new AsyncRequest.Callback() {

            @Override
            public void onComplete(Response response) {
                Log.i("onComplete", "" + response.getError());
                onUnlikeRequestComplete(response);
            }
        }).execute();
    }
}
Also used : Response(com.abewy.android.apps.klyph.core.request.Response) FragmentActivity(android.support.v4.app.FragmentActivity) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) Page(com.abewy.android.apps.klyph.core.fql.Page)

Example 15 with AsyncRequest

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

the class StreamListFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    MultiObjectAdapter adapter = /* KlyphPreferences.areBannerAdsEnabled() ? new NewsfeedAdapter(getListView()) : */
    new MultiObjectAdapter(getListView());
    if (KlyphPreferences.animateCards()) {
        GoogleCardStyleAdapter gcsAdapter = new GoogleCardStyleAdapter(adapter);
        gcsAdapter.setAbsListView(getListView());
        setListAdapter(gcsAdapter);
    } else {
        setListAdapter(adapter);
    }
    defineEmptyText(R.string.empty_list_no_stream);
    // getListView().setPadding(0, 8, 0, 0);
    // getListView().setDivider(getResources().getDrawable(R.drawable.hdivider_transparent));
    // getGridView().setVerticalSpacing(16);
    // getListView().setItemsCanFocus(false);
    getListView().setDrawSelectorOnTop(true);
    getListView().setSelector(AttrUtil.getResourceId(getActivity(), R.attr.streamSelector));
    setListVisible(false);
    if (KlyphData.getFriendLists() == null) {
        new AsyncRequest(Query.FRIEND_LISTS, "", "", new Callback() {

            @Override
            public void onComplete(Response response) {
                onRequestComplete(response);
            }
        }).execute();
    }
    super.onViewCreated(view, savedInstanceState);
}
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) MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) GoogleCardStyleAdapter(com.abewy.android.apps.klyph.adapter.animation.GoogleCardStyleAdapter)

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