Search in sources :

Example 1 with PostRequest

use of com.ferg.awfulapp.task.PostRequest in project Awful.apk by Awful.

the class ThreadDisplayFragment method syncThread.

/**
 * Reload the current thread page
 */
private void syncThread() {
    final Activity activity = getActivity();
    if (activity != null) {
        Timber.i("Syncing - reloading from site (thread %d, page %d) to update DB", getThreadId(), getPageNumber());
        // cancel pending post loading requests
        NetworkUtils.cancelRequests(PostRequest.REQUEST_TAG);
        bodyHtml = "";
        // call this with cancelOnDestroy=false to retain the request's specific type tag
        final int pageNumber = getPageNumber();
        int userId = postFilterUserId == null ? BLANK_USER_ID : postFilterUserId;
        queueRequest(new PostRequest(activity, getThreadId(), pageNumber, userId).build(this, new AwfulRequest.AwfulResultCallback<Integer>() {

            @Override
            public void success(Integer result) {
                refreshInfo();
                setProgress(75);
                refreshPosts();
            }

            @Override
            public void failure(VolleyError error) {
                Timber.w("Failed to sync thread! Error: %s", error.getMessage());
                refreshInfo();
                refreshPosts();
            }
        }), false);
    }
}
Also used : VolleyError(com.android.volley.VolleyError) SinglePostRequest(com.ferg.awfulapp.task.SinglePostRequest) PostRequest(com.ferg.awfulapp.task.PostRequest) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity)

Aggregations

Activity (android.app.Activity)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 VolleyError (com.android.volley.VolleyError)1 PostRequest (com.ferg.awfulapp.task.PostRequest)1 SinglePostRequest (com.ferg.awfulapp.task.SinglePostRequest)1