Search in sources :

Example 6 with TimeLinePosition

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

the class HomeOtherGroupTimeLineDBTask method getPosition.

static TimeLinePosition getPosition(String accountId, String groupId) {
    String sql = "select * from " + HomeOtherGroupTable.TABLE_NAME + " where " + HomeOtherGroupTable.ACCOUNTID + "  = " + accountId + " and " + HomeOtherGroupTable.GROUPID + " = " + groupId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeOtherGroupTable.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 7 with TimeLinePosition

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

the class MentionCommentsTimeLineDBTask method getCommentLineMsgList.

public static CommentTimeLineData getCommentLineMsgList(String accountId) {
    TimeLinePosition position = getPosition(accountId);
    int limit = position.position + AppConfig.DB_CACHE_COUNT_OFFSET > AppConfig.DEFAULT_MSG_COUNT_50 ? position.position + AppConfig.DB_CACHE_COUNT_OFFSET : AppConfig.DEFAULT_MSG_COUNT_50;
    CommentListBean result = new CommentListBean();
    List<CommentBean> msgList = new ArrayList<CommentBean>();
    String sql = "select * from " + MentionCommentsTable.MentionCommentsDataTable.TABLE_NAME + " where " + MentionCommentsTable.MentionCommentsDataTable.ACCOUNTID + "  = " + accountId + " order by " + MentionCommentsTable.MentionCommentsDataTable.MBLOGID + " desc limit " + limit;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MentionCommentsTable.MentionCommentsDataTable.JSONDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                CommentBean value = gson.fromJson(json, CommentBean.class);
                if (!value.isMiddleUnreadItem()) {
                    value.getListViewSpannableString();
                }
                msgList.add(value);
            } catch (JsonSyntaxException e) {
                AppLogger.e(e.getMessage());
            }
        } else {
            msgList.add(null);
        }
    }
    result.setComments(msgList);
    c.close();
    CommentTimeLineData mentionTimeLineData = new CommentTimeLineData(result, position);
    return mentionTimeLineData;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) CommentTimeLineData(org.qii.weiciyuan.bean.android.CommentTimeLineData) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) Cursor(android.database.Cursor) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 8 with TimeLinePosition

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

the class MentionCommentsTimeLineDBTask method getPosition.

public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + MentionCommentsTable.TABLE_NAME + " where " + MentionCommentsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MentionCommentsTable.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 9 with TimeLinePosition

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

the class MentionWeiboTimeLineDBTask method getPosition.

public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + RepostsTable.TABLE_NAME + " where " + RepostsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(RepostsTable.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 10 with TimeLinePosition

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

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