@Override protected List<? extends BaseUser> doInBackground(Void... params) { if (adapter == null || microBlog == null) { return null; } List<? extends BaseUser> userList = null; boolean isFirstLoad = context.isFirstLoad(); SocialGraphDao dao = new SocialGraphDao(context); try { paging = adapter.getPaging(); if (!isFirstLoad && paging.moveToNext()) { if (relation == Relation.Followingship) { userList = dao.getFriends(user, paging); } else { userList = dao.getFollowers(user, paging); } if (paging.getPageIndex() == 1 && ListUtil.isEmpty(userList)) { isFirstLoad = true; context.setFirstLoad(isFirstLoad); } } SocialGraphCacheTask cacheTask = null; if (isFirstLoad) { // 第一次加载时,做一个缓冲task if (paging.getPageIndex() == 1 && adapter.getCount() == 0) { Paging<User> remotePaging = new Paging<User>(); adapter.setPaging(remotePaging); // 缓冲远程数据; cacheTask = new SocialGraphCacheTask(context, account, relation); } paging = adapter.getPaging(); if (paging.moveToNext()) { if (relation == Relation.Followingship) { userList = microBlog.getFriends(paging); } else { userList = microBlog.getFollowers(paging); } } } else if (paging.getPageIndex() == 1) { // 防止新关注,缓冲第一次。 cacheTask = new SocialGraphCacheTask(context, account, relation); cacheTask.setCycleTime(1); cacheTask.setPageSize(20); } if (cacheTask != null) { cacheTask.execute(); } } catch (LibException e) { if (Constants.DEBUG) Log.e(TAG, "Task", e); resultMsg = ResourceBook.getStatusCodeValue(e.getExceptionCode(), context); paging.moveToPrevious(); } return userList; }
@Override protected Integer doInBackground(Void... params) { cacheCount = 0; if (microBlog == null) { return cacheCount; } List<? extends BaseUser> userList = null; Paging<User> paging = new Paging<User>(); paging.setPageSize(pageSize); while (paging.moveToNext() && cycleTime-- > 0) { try { userList = microBlog.getGroupMembers(group.getSpGroupId(), paging); } catch (LibException e) { if (Constants.DEBUG) Log.e(TAG, "Task", e); } if (ListUtil.isNotEmpty(userList)) { cacheCount += userList.size(); this.publishProgress(userList); } } return cacheCount; }
@Override protected Boolean doInBackground(net.dev123.mblog.entity.Status... params) { boolean isSuccess = false; if (microBlog == null || params == null || params.length != 2) { return isSuccess; } net.dev123.mblog.entity.Status max = params[0]; net.dev123.mblog.entity.Status since = params[1]; Paging<net.dev123.mblog.entity.Status> paging = new Paging<net.dev123.mblog.entity.Status>(); paging.setGlobalMax(max); paging.setGlobalSince(since); if (paging.moveToNext()) { try { listStatus = microBlog.getMentions(paging); } catch (LibException e) { if (Constants.DEBUG) Log.e(TAG, "Task", e); resultMsg = ResourceBook.getStatusCodeValue(e.getExceptionCode(), adapter.getContext()); paging.moveToPrevious(); } finally { ListUtil.truncate(listStatus, paging.getMax(), paging.getSince()); } } Util.getResponseCounts(listStatus, microBlog); isSuccess = listStatus != null && listStatus.size() > 0; if (isSuccess && paging.hasNext()) { LocalStatus localStatus = StatusUtil.createDividerStatus(listStatus, account); listStatus.add(localStatus); } return isSuccess; }