Search in sources :

Example 1 with MyStatusTimeLineData

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

the class MyStatusDBTask method get.

public static MyStatusTimeLineData get(String accountId) {
    Gson gson = new Gson();
    MessageListBean result = new MessageListBean();
    List<MessageBean> msgList = new ArrayList<MessageBean>();
    String sql = "select * from " + MyStatusTable.StatusDataTable.TABLE_NAME + " where " + MyStatusTable.StatusDataTable.ACCOUNTID + "  = " + accountId + " order by " + MyStatusTable.StatusDataTable.MBLOGID + " desc limit 50";
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MyStatusTable.StatusDataTable.JSONDATA));
        try {
            MessageBean value = gson.fromJson(json, MessageBean.class);
            if (!value.isMiddleUnreadItem()) {
                value.getListViewSpannableString();
            }
            msgList.add(value);
        } catch (JsonSyntaxException ignored) {
        }
    }
    result.setStatuses(msgList);
    c.close();
    return new MyStatusTimeLineData(result, getPosition(accountId));
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) MyStatusTimeLineData(org.qii.weiciyuan.bean.android.MyStatusTimeLineData) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) Cursor(android.database.Cursor)

Aggregations

Cursor (android.database.Cursor)1 Gson (com.google.gson.Gson)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ArrayList (java.util.ArrayList)1 MessageBean (org.qii.weiciyuan.bean.MessageBean)1 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)1 MyStatusTimeLineData (org.qii.weiciyuan.bean.android.MyStatusTimeLineData)1