Search in sources :

Example 11 with MessageListBean

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);
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean)

Example 12 with MessageListBean

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;
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean) MainFriendsTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MainFriendsTimeLineDao) FriendGroupTimeLineDao(org.qii.weiciyuan.dao.maintimeline.FriendGroupTimeLineDao) BilateralTimeLineDao(org.qii.weiciyuan.dao.maintimeline.BilateralTimeLineDao)

Example 13 with MessageListBean

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;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) MessageListBean(org.qii.weiciyuan.bean.MessageListBean)

Example 14 with MessageListBean

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;
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean) MentionsWeiboTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MentionsWeiboTimeLineDao)

Example 15 with MessageListBean

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;
    }
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean)

Aggregations

MessageListBean (org.qii.weiciyuan.bean.MessageListBean)25 Gson (com.google.gson.Gson)8 JsonSyntaxException (com.google.gson.JsonSyntaxException)8 MessageBean (org.qii.weiciyuan.bean.MessageBean)8 ArrayList (java.util.ArrayList)6 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)5 Cursor (android.database.Cursor)4 UnreadBean (org.qii.weiciyuan.bean.UnreadBean)4 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)4 MentionTimeLineData (org.qii.weiciyuan.bean.android.MentionTimeLineData)3 MessageTimeLineData (org.qii.weiciyuan.bean.android.MessageTimeLineData)3 AccountBean (org.qii.weiciyuan.bean.AccountBean)2 MentionsWeiboTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsWeiboTimeLineDao)2 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bitmap (android.graphics.Bitmap)1