Search in sources :

Example 6 with CommentTimeLineData

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

the class CommentsByMeTimeLineFragment 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();
            } 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 7 with CommentTimeLineData

use of org.qii.weiciyuan.bean.android.CommentTimeLineData 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 8 with CommentTimeLineData

use of org.qii.weiciyuan.bean.android.CommentTimeLineData 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 9 with CommentTimeLineData

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

the class AppNotificationCenter method addDatabaseUnreadMentionsComment.

private void addDatabaseUnreadMentionsComment(String accountId, CommentListBean mentions) {
    CommentTimeLineData dbData = MentionCommentsTimeLineDBTask.getCommentLineMsgList(accountId);
    List<CommentBean> itemList = dbData.cmtList.getItemList();
    TimeLinePosition position = dbData.position;
    TreeSet<Long> newMsgIds = position.newMsgIds;
    HashMap<Long, CommentBean> map = new HashMap<>();
    for (CommentBean msg : itemList) {
        map.put(msg.getIdLong(), msg);
    }
    for (Object object : newMsgIds) {
        long id;
        if (object instanceof Double) {
            Double value = (Double) object;
            id = value.longValue();
        } else {
            id = (Long) object;
        }
        CommentBean msg = map.get(id);
        if (msg != null) {
            mentions.getItemList().add(msg);
        }
    }
}
Also used : HashMap(java.util.HashMap) CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Aggregations

CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)9 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)7 CommentBean (org.qii.weiciyuan.bean.CommentBean)5 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)5 Cursor (android.database.Cursor)3 Gson (com.google.gson.Gson)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)1 UnreadBean (org.qii.weiciyuan.bean.UnreadBean)1 MentionTimeLineData (org.qii.weiciyuan.bean.android.MentionTimeLineData)1 MainCommentsTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MainCommentsTimeLineDao)1 MentionsCommentTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsCommentTimeLineDao)1 MentionsWeiboTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsWeiboTimeLineDao)1 UnreadDao (org.qii.weiciyuan.dao.unread.UnreadDao)1