Code example for AsyncTaskLoader

Methods: deliverResult

0
     
    @Override 
    public void deliverResult(RESTResponse data) {
        // Here we cache our response. 
        mRestResponse = data;
        super.deliverResult(data);
    } 
     
    @Override 
    protected void onStartLoading() { 
        if (mRestResponse != null) {
            // We have a cached result, so we can just 
            // return right away. 
            super.deliverResult(mRestResponse);
        } 
         
        // If our response is null or we have hung onto it for a long time, 
        // then we perform a force load. 
        if (mRestResponse == null || System.currentTimeMillis() - mLastLoad >= STALE_DELTA) forceLoad();
        mLastLoad = System.currentTimeMillis();
    }