Search in sources :

Example 1 with FavouriteTimeLineData

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

the class FavouriteDBTask method getFavouriteMsgList.

public static FavouriteTimeLineData getFavouriteMsgList(String accountId) {
    FavListBean result = new FavListBean();
    List<FavBean> msgList = new ArrayList<FavBean>();
    String sql = "select * from " + FavouriteTable.FavouriteDataTable.TABLE_NAME + " where " + FavouriteTable.FavouriteDataTable.ACCOUNTID + "  = " + accountId + " order by " + FavouriteTable.FavouriteDataTable.MBLOGID + " desc";
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(FavouriteTable.FavouriteDataTable.JSONDATA));
        try {
            FavBean value = gson.fromJson(json, FavBean.class);
            if (value != null && !value.getStatus().isMiddleUnreadItem()) {
                value.getStatus().getListViewSpannableString();
            }
            msgList.add(value);
        } catch (JsonSyntaxException e) {
            AppLogger.e(e.getMessage());
        }
    }
    result.setFavorites(msgList);
    c.close();
    sql = "select * from " + FavouriteTable.TABLE_NAME + " where " + FavouriteTable.ACCOUNTID + "  = " + accountId;
    c = getRsd().rawQuery(sql, null);
    int page = 0;
    while (c.moveToNext()) {
        page = c.getInt(c.getColumnIndex(FavouriteTable.PAGE));
    }
    c.close();
    return new FavouriteTimeLineData(result, page, getPosition(accountId));
}
Also used : FavBean(org.qii.weiciyuan.bean.FavBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) FavListBean(org.qii.weiciyuan.bean.FavListBean) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) FavouriteTimeLineData(org.qii.weiciyuan.bean.android.FavouriteTimeLineData) 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 FavBean (org.qii.weiciyuan.bean.FavBean)1 FavListBean (org.qii.weiciyuan.bean.FavListBean)1 FavouriteTimeLineData (org.qii.weiciyuan.bean.android.FavouriteTimeLineData)1