Search in sources :

Example 16 with TimeLinePosition

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

the class LeftMenuFragment method readUnreadCountFromDB.

private void readUnreadCountFromDB() {
    TimeLinePosition position = MentionWeiboTimeLineDBTask.getPosition(GlobalContext.getInstance().getCurrentAccountId());
    TreeSet<Long> hashSet = position.newMsgIds;
    if (hashSet != null) {
        mentionsWeiboUnreadCount = hashSet.size();
    }
    position = MentionCommentsTimeLineDBTask.getPosition(GlobalContext.getInstance().getCurrentAccountId());
    hashSet = position.newMsgIds;
    if (hashSet != null) {
        mentionsCommentUnreadCount = hashSet.size();
    }
    position = CommentToMeTimeLineDBTask.getPosition(GlobalContext.getInstance().getCurrentAccountId());
    hashSet = position.newMsgIds;
    if (hashSet != null) {
        commentsToMeUnreadCount = hashSet.size();
    }
}
Also used : TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition)

Example 17 with TimeLinePosition

use of org.qii.weiciyuan.bean.android.TimeLinePosition 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)

Example 18 with TimeLinePosition

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

the class AppNotificationCenter method addDatabaseUnreadMentionsWeibo.

private void addDatabaseUnreadMentionsWeibo(String accountId, MessageListBean mentions) {
    MentionTimeLineData dbData = MentionWeiboTimeLineDBTask.getRepostLineMsgList(accountId);
    List<MessageBean> itemList = dbData.msgList.getItemList();
    TimeLinePosition position = dbData.position;
    TreeSet<Long> newMsgIds = position.newMsgIds;
    HashMap<Long, MessageBean> map = new HashMap<>();
    for (MessageBean 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;
        }
        MessageBean msg = map.get(id);
        if (msg != null) {
            mentions.getItemList().add(msg);
        }
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) HashMap(java.util.HashMap) MentionTimeLineData(org.qii.weiciyuan.bean.android.MentionTimeLineData) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition)

Example 19 with TimeLinePosition

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

the class FavouriteDBTask method getPosition.

private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + FavouriteTable.TABLE_NAME + " where " + FavouriteTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(FavouriteTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) Cursor(android.database.Cursor)

Example 20 with TimeLinePosition

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

the class FriendsTimeLineDBTask method getPosition.

private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + HomeTable.TABLE_NAME + " where " + HomeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) Cursor(android.database.Cursor)

Aggregations

TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)30 Cursor (android.database.Cursor)12 Gson (com.google.gson.Gson)12 JsonSyntaxException (com.google.gson.JsonSyntaxException)12 CommentBean (org.qii.weiciyuan.bean.CommentBean)7 ArrayList (java.util.ArrayList)5 CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)5 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)4 ViewTreeObserver (android.view.ViewTreeObserver)3 HashMap (java.util.HashMap)3 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)3 MessageBean (org.qii.weiciyuan.bean.MessageBean)3 MessageTimeLineData (org.qii.weiciyuan.bean.android.MessageTimeLineData)3 MentionTimeLineData (org.qii.weiciyuan.bean.android.MentionTimeLineData)2 View (android.view.View)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 GroupBean (org.qii.weiciyuan.bean.GroupBean)1