Search in sources :

Example 1 with MessageTimeLineData

use of org.qii.weiciyuan.bean.android.MessageTimeLineData in project weiciyuan by qii.

the class FriendsTimeLineDBTask method getOtherGroupData.

public static List<MessageTimeLineData> getOtherGroupData(String accountId, String exceptGroupId) {
    List<MessageTimeLineData> data = new ArrayList<MessageTimeLineData>();
    if (!"0".equals(exceptGroupId)) {
        TimeLinePosition position = getPosition(accountId);
        MessageListBean msgList = getHomeLineMsgList(accountId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
        MessageTimeLineData home = new MessageTimeLineData("0", msgList, position);
        data.add(home);
    }
    MessageTimeLineData biGroup = HomeOtherGroupTimeLineDBTask.getTimeLineData(accountId, "1");
    data.add(biGroup);
    GroupListBean groupListBean = GroupDBTask.get(accountId);
    if (groupListBean != null) {
        List<GroupBean> lists = groupListBean.getLists();
        for (GroupBean groupBean : lists) {
            MessageTimeLineData dbMsg = HomeOtherGroupTimeLineDBTask.getTimeLineData(accountId, groupBean.getId());
            data.add(dbMsg);
        }
    }
    Iterator<MessageTimeLineData> iterator = data.iterator();
    while (iterator.hasNext()) {
        MessageTimeLineData single = iterator.next();
        if (single.groupId.equals(exceptGroupId)) {
            iterator.remove();
            break;
        }
    }
    return data;
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean) ArrayList(java.util.ArrayList) GroupListBean(org.qii.weiciyuan.bean.GroupListBean) GroupBean(org.qii.weiciyuan.bean.GroupBean) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) MessageTimeLineData(org.qii.weiciyuan.bean.android.MessageTimeLineData)

Example 2 with MessageTimeLineData

use of org.qii.weiciyuan.bean.android.MessageTimeLineData in project weiciyuan by qii.

the class FriendsTimeLineFragment method handleDBCacheResultData.

private void handleDBCacheResultData(List<MessageTimeLineData> result) {
    for (MessageTimeLineData single : result) {
        putToGroupDataMemoryCache(single.groupId, single.msgList);
        positionCache.put(single.groupId, single.position);
    }
}
Also used : MessageTimeLineData(org.qii.weiciyuan.bean.android.MessageTimeLineData)

Example 3 with MessageTimeLineData

use of org.qii.weiciyuan.bean.android.MessageTimeLineData in project weiciyuan by qii.

the class FriendsTimeLineDBTask method getRecentGroupData.

public static MessageTimeLineData getRecentGroupData(String accountId) {
    String groupId = getRecentGroupId(accountId);
    MessageListBean msgList;
    TimeLinePosition position;
    if (groupId.equals("0")) {
        position = getPosition(accountId);
        msgList = getHomeLineMsgList(accountId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
    } else {
        position = HomeOtherGroupTimeLineDBTask.getPosition(accountId, groupId);
        msgList = HomeOtherGroupTimeLineDBTask.get(accountId, groupId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
    }
    return new MessageTimeLineData(groupId, msgList, position);
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) MessageTimeLineData(org.qii.weiciyuan.bean.android.MessageTimeLineData)

Example 4 with MessageTimeLineData

use of org.qii.weiciyuan.bean.android.MessageTimeLineData in project weiciyuan by qii.

the class HomeOtherGroupTimeLineDBTask method getTimeLineData.

static MessageTimeLineData getTimeLineData(String accountId, String groupId) {
    TimeLinePosition position = getPosition(accountId, groupId);
    MessageListBean msgList = get(accountId, groupId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
    return new MessageTimeLineData(groupId, msgList, position);
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) MessageTimeLineData(org.qii.weiciyuan.bean.android.MessageTimeLineData)

Example 5 with MessageTimeLineData

use of org.qii.weiciyuan.bean.android.MessageTimeLineData in project weiciyuan by qii.

the class FriendsTimeLineFragment method handleDBCacheOnProgressUpdateData.

private void handleDBCacheOnProgressUpdateData(MessageTimeLineData[] result) {
    if (result != null && result.length > 0) {
        MessageTimeLineData recentData = result[0];
        getList().replaceData(recentData.msgList);
        putToGroupDataMemoryCache(recentData.groupId, recentData.msgList);
        positionCache.put(recentData.groupId, recentData.position);
        currentGroupId = recentData.groupId;
    }
    getPullToRefreshListView().setVisibility(View.VISIBLE);
    getAdapter().notifyDataSetChanged();
    setListViewPositionFromPositionsCache();
    if (getActivity().getActionBar().getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST) {
        getActivity().getActionBar().setSelectedNavigationItem(getRecentNavIndex());
    }
    refreshLayout(getList());
    /**
         * when this account first open app,if he don't have any data in database,fetch data from server automally
         */
    if (getList().getSize() == 0) {
        getPullToRefreshListView().setRefreshing();
        loadNewMsg();
    } else {
        new RefreshReCmtCountTask(FriendsTimeLineFragment.this, getList()).executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : MessageTimeLineData(org.qii.weiciyuan.bean.android.MessageTimeLineData)

Aggregations

MessageTimeLineData (org.qii.weiciyuan.bean.android.MessageTimeLineData)5 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)3 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)3 ArrayList (java.util.ArrayList)1 GroupBean (org.qii.weiciyuan.bean.GroupBean)1 GroupListBean (org.qii.weiciyuan.bean.GroupListBean)1