use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class FriendsTimeLineFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
userBean = getArguments().getParcelable(ARGUMENTS_USER_EXTRA);
accountBean = getArguments().getParcelable(ARGUMENTS_ACCOUNT_EXTRA);
token = getArguments().getString(ARGUMENTS_TOKEN_EXTRA);
switch(getCurrentState(savedInstanceState)) {
case FIRST_TIME_START:
if (Utility.isTaskStopped(dbTask) && getList().getSize() == 0) {
dbTask = new DBCacheTask(this, accountBean.getUid());
dbTask.executeOnIO();
GroupInfoTask groupInfoTask = new GroupInfoTask(GlobalContext.getInstance().getSpecialToken(), GlobalContext.getInstance().getCurrentAccountId());
groupInfoTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
getAdapter().notifyDataSetChanged();
refreshLayout(getList());
}
groupDataCache.put(ALL_GROUP_ID, new MessageListBean());
groupDataCache.put(BILATERAL_GROUP_ID, new MessageListBean());
if (getList().getSize() > 0) {
groupDataCache.put(ALL_GROUP_ID, getList().copy());
}
buildActionBarNav();
break;
case SCREEN_ROTATE:
//nothing
refreshLayout(getList());
buildActionBarNav();
setListViewPositionFromPositionsCache();
break;
case ACTIVITY_DESTROY_AND_CREATE:
if (Utility.isTaskStopped(dbTask) && getList().getSize() == 0) {
dbTask = new DBCacheTask(this, accountBean.getUid());
dbTask.executeOnIO();
GroupInfoTask groupInfoTask = new GroupInfoTask(GlobalContext.getInstance().getSpecialToken(), GlobalContext.getInstance().getCurrentAccountId());
groupInfoTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
getAdapter().notifyDataSetChanged();
refreshLayout(getList());
}
groupDataCache.put(ALL_GROUP_ID, new MessageListBean());
groupDataCache.put(BILATERAL_GROUP_ID, new MessageListBean());
if (getList().getSize() > 0) {
groupDataCache.put(ALL_GROUP_ID, getList().copy());
}
buildActionBarNav();
break;
}
super.onActivityCreated(savedInstanceState);
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class FriendsMsgLoader method get.
private MessageListBean get(String token, String groupId, String sinceId, String maxId) throws WeiboException {
MainFriendsTimeLineDao dao;
if (currentGroupId.equals(FriendsTimeLineFragment.BILATERAL_GROUP_ID)) {
dao = new BilateralTimeLineDao(token);
} else if (currentGroupId.equals(FriendsTimeLineFragment.ALL_GROUP_ID)) {
dao = new MainFriendsTimeLineDao(token);
} else {
dao = new FriendGroupTimeLineDao(token, currentGroupId);
}
dao.setSince_id(sinceId);
dao.setMax_id(maxId);
MessageListBean result = null;
lock.lock();
try {
result = dao.getGSONMsgList();
} finally {
lock.unlock();
}
return result;
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class FriendsMsgLoader method loadData.
public MessageListBean loadData() throws WeiboException {
MessageListBean result = null;
MessageListBean tmp = get(token, currentGroupId, sinceId, maxId);
result = tmp;
if (isLoadNewData() && Utility.isWifi(getContext()) && SettingUtility.isWifiUnlimitedMsgCount()) {
int retryCount = 0;
while (tmp.getReceivedCount() >= Integer.valueOf(SettingUtility.getMsgCount()) && retryCount < MAX_RETRY_COUNT) {
String tmpMaxId = tmp.getItemList().get(tmp.getItemList().size() - 1).getId();
tmp = get(token, currentGroupId, sinceId, tmpMaxId);
result.addOldData(tmp);
retryCount++;
}
if (tmp.getReceivedCount() >= Integer.valueOf(SettingUtility.getMsgCount())) {
MessageBean middleUnreadItem = new MessageBean();
middleUnreadItem.setId(String.valueOf(System.currentTimeMillis()));
middleUnreadItem.setMiddleUnreadItem(true);
result.getItemList().add(middleUnreadItem);
}
} else {
return result;
}
return result;
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class MentionsWeiboMsgLoader method loadData.
public MessageListBean loadData() throws WeiboException {
MentionsWeiboTimeLineDao dao = new MentionsWeiboTimeLineDao(token);
dao.setSince_id(sinceId);
dao.setMax_id(maxId);
MessageListBean result = null;
lock.lock();
try {
result = dao.getGSONMsgList();
} finally {
lock.unlock();
}
return result;
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class SaveToDBService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
int type = intent.getIntExtra("type", 0);
String accountId = intent.getStringExtra("accountId");
switch(type) {
case TYPE_STATUS:
AppLogger.e("start db");
MessageListBean value = (MessageListBean) intent.getParcelableExtra("value");
// FriendsTimeLineDBTask.replace(value, accountId);
AppLogger.e("end db");
break;
}
}
Aggregations