@Override public void onSuccess(int i, Header[] header, byte[] responseBytes) { BaseRecycleViewFragment instance = mInstance.get(); if (instance.isAdded()) { instance.executeParseTask(responseBytes, false); } }
@Override protected String doInBackground(Void... params) { BaseRecycleViewFragment instance = mInstance.get(); if (instance == null) return null; try { ListEntity data = instance.parseList(new ByteArrayInputStream(responseData)); if (!fromCache) { // ////////////// 此处需要发送广播时间,通知用户现在有新的消息 } if (!fromCache && instance.mCurrentPage == 0 && !TextUtils.isEmpty(instance.getCacheKey())) { CacheManager.setCache( instance.getCacheKey(), responseData, instance.getCacheExpire(), CacheManager.TYPE_INTERNAL); // Logger.e(TAG, "cache write success:" + instance.getCacheKey()); } list = data.getList(); } catch (Exception e) { e.printStackTrace(); parseError = true; } return null; }
@Override public void onFailure(int i, Header[] header, byte[] responseBytes, Throwable throwable) { BaseRecycleViewFragment instance = mInstance.get(); if (instance.isAdded()) { instance.executeOnLoadDataError(null); instance.executeOnLoadFinish(); } }
@Override protected void onPostExecute(BaseRecycleViewFragment target, byte[] result) { super.onPostExecute(target, result); if (target == null) { return; } if (result != null) { target.executeParseTask(result, true); return; } target.refresh(); }
@Override protected void onPostExecute(String result) { super.onPostExecute(result); BaseRecycleViewFragment instance = mInstance.get(); if (instance != null) { if (parseError) { instance.executeOnLoadDataError(null); } else { instance.executeOnLoadDataSuccess(list); if (!fromCache) { if (instance.mState == STATE_REFRESH) { instance.onRefreshNetworkSuccess(); } } instance.executeOnLoadFinish(); } } }
@Override protected byte[] doInBackground(BaseRecycleViewFragment target, Void... params) { if (target == null) { return null; } if (TextUtils.isEmpty(target.getCacheKey())) { return null; } byte[] data = CacheManager.getCache(target.getCacheKey()); if (data == null) { Logger.e(TAG, "cache data is empty. :" + target.getCacheKey()); return null; } Logger.e(TAG, "exist cache: " + target.getCacheKey() + "data:" + data); return null; // return data; }