Search in sources :

Example 11 with CommentListBean

use of org.qii.weiciyuan.bean.CommentListBean in project weiciyuan by qii.

the class CommentsToMeTimeLineFragment 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);
    super.onActivityCreated(savedInstanceState);
    switch(getCurrentState(savedInstanceState)) {
        case FIRST_TIME_START:
            getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
            break;
        case ACTIVITY_DESTROY_AND_CREATE:
            timeLinePosition = (TimeLinePosition) savedInstanceState.getSerializable(ARGUMENTS_TIMELINE_POSITION_EXTRA);
            Loader<CommentTimeLineData> loader = getLoaderManager().getLoader(DB_CACHE_LOADER_ID);
            if (loader != null) {
                getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
            }
            CommentListBean savedBean = savedInstanceState.getParcelable(ARGUMENTS_DATA_EXTRA);
            if (savedBean != null && savedBean.getSize() > 0) {
                clearAndReplaceValue(savedBean);
                timeLineAdapter.notifyDataSetChanged();
                refreshLayout(getList());
                //                    setListViewPositionFromPositionsCache();
                AppNotificationCenter.getInstance().addCallback(callback);
            } else {
                getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
            }
            break;
    }
}
Also used : CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) CommentListBean(org.qii.weiciyuan.bean.CommentListBean)

Example 12 with CommentListBean

use of org.qii.weiciyuan.bean.CommentListBean in project weiciyuan by qii.

the class CommentsToMeMsgLoader method loadData.

public CommentListBean loadData() throws WeiboException {
    MainCommentsTimeLineDao dao = new MainCommentsTimeLineDao(token);
    dao.setSince_id(sinceId);
    dao.setMax_id(maxId);
    CommentListBean result = null;
    lock.lock();
    try {
        result = dao.getGSONMsgList();
    } finally {
        lock.unlock();
    }
    return result;
}
Also used : MainCommentsTimeLineDao(org.qii.weiciyuan.dao.maintimeline.MainCommentsTimeLineDao) CommentListBean(org.qii.weiciyuan.bean.CommentListBean)

Example 13 with CommentListBean

use of org.qii.weiciyuan.bean.CommentListBean in project weiciyuan by qii.

the class MentionsCommentTimeLineFragment 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);
    super.onActivityCreated(savedInstanceState);
    switch(getCurrentState(savedInstanceState)) {
        case FIRST_TIME_START:
            getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
            break;
        case ACTIVITY_DESTROY_AND_CREATE:
            timeLinePosition = (TimeLinePosition) savedInstanceState.getSerializable(ARGUMENTS_TIMELINE_POSITION_EXTRA);
            CommentListBean savedBean = savedInstanceState.getParcelable(ARGUMENTS_DATA_EXTRA);
            Loader<CommentTimeLineData> loader = getLoaderManager().getLoader(DB_CACHE_LOADER_ID);
            if (loader != null) {
                getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
            }
            if (savedBean != null && savedBean.getSize() > 0) {
                clearAndReplaceValue(savedBean);
                timeLineAdapter.notifyDataSetChanged();
                refreshLayout(getList());
                AppNotificationCenter.getInstance().addCallback(callback);
            } else {
                getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
            }
            break;
    }
}
Also used : CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) CommentListBean(org.qii.weiciyuan.bean.CommentListBean)

Example 14 with CommentListBean

use of org.qii.weiciyuan.bean.CommentListBean in project weiciyuan by qii.

the class AppNotificationCenter method showAndroidNotification.

public void showAndroidNotification(AccountBean account) {
    UnreadBean unreadBean = unreadBeans.get(account);
    MessageListBean mentions = unreadMentions.get(account);
    CommentListBean comments = unreadComments.get(account);
    CommentListBean mentionsComment = unreadMentionsComment.get(account);
    String accountId = account.getUid();
    if (mentions == null) {
        mentions = new MessageListBean();
    }
    addDatabaseUnreadMentionsWeibo(accountId, mentions);
    Utility.removeDuplicateAndSortStatus(mentions.getItemList());
    if (comments == null) {
        comments = new CommentListBean();
    }
    addDatabaseUnreadCommentsToMe(accountId, comments);
    Utility.removeDuplicateAndSortComment(comments.getItemList());
    if (mentionsComment == null) {
        mentionsComment = new CommentListBean();
    }
    addDatabaseUnreadMentionsComment(accountId, mentionsComment);
    Utility.removeDuplicateAndSortComment(mentionsComment.getItemList());
    showNotification(GlobalContext.getInstance(), account, mentions, comments, mentionsComment, unreadBean);
}
Also used : UnreadBean(org.qii.weiciyuan.bean.UnreadBean) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) CommentListBean(org.qii.weiciyuan.bean.CommentListBean)

Example 15 with CommentListBean

use of org.qii.weiciyuan.bean.CommentListBean in project weiciyuan by qii.

the class CommentToMeTimeLineDBTask method asyncReplace.

public static void asyncReplace(final CommentListBean list, final String accountId) {
    final CommentListBean data = new CommentListBean();
    data.replaceAll(list);
    new Thread(new Runnable() {

        @Override
        public void run() {
            deleteAllComments(accountId);
            addCommentLineMsg(data, accountId);
        }
    }).start();
}
Also used : CommentListBean(org.qii.weiciyuan.bean.CommentListBean)

Aggregations

CommentListBean (org.qii.weiciyuan.bean.CommentListBean)22 CommentBean (org.qii.weiciyuan.bean.CommentBean)7 CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)7 Gson (com.google.gson.Gson)6 JsonSyntaxException (com.google.gson.JsonSyntaxException)6 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)5 ArrayList (java.util.ArrayList)4 UnreadBean (org.qii.weiciyuan.bean.UnreadBean)4 Cursor (android.database.Cursor)3 HashMap (java.util.HashMap)3 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)3 AccountBean (org.qii.weiciyuan.bean.AccountBean)2 MainCommentsTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MainCommentsTimeLineDao)2 MentionsCommentTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao)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