Search in sources :

Example 21 with MessageListBean

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

Example 22 with MessageListBean

use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.

the class MentionWeiboTimeLineDBTask method getRepostLineMsgList.

public static MentionTimeLineData getRepostLineMsgList(String accountId) {
    TimeLinePosition position = getPosition(accountId);
    Gson gson = new Gson();
    MessageListBean result = new MessageListBean();
    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;
    List<MessageBean> msgList = new ArrayList<MessageBean>();
    String sql = "select * from " + RepostsTable.RepostDataTable.TABLE_NAME + " where " + RepostsTable.RepostDataTable.ACCOUNTID + "  = " + accountId + " order by " + RepostsTable.RepostDataTable.MBLOGID + " desc limit " + limit;
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(RepostsTable.RepostDataTable.JSONDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                MessageBean value = gson.fromJson(json, MessageBean.class);
                if (!value.isMiddleUnreadItem()) {
                    value.getListViewSpannableString();
                }
                msgList.add(value);
            } catch (JsonSyntaxException e) {
                AppLogger.e(e.getMessage());
            }
        } else {
            msgList.add(null);
        }
    }
    result.setStatuses(msgList);
    c.close();
    MentionTimeLineData mentionTimeLineData = new MentionTimeLineData(result, position);
    return mentionTimeLineData;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) JsonSyntaxException(com.google.gson.JsonSyntaxException) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) MentionTimeLineData(org.qii.weiciyuan.bean.android.MentionTimeLineData) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) Cursor(android.database.Cursor)

Example 23 with MessageListBean

use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.

the class MentionWeiboTimeLineDBTask method asyncReplace.

public static void asyncReplace(final MessageListBean list, final String accountId) {
    final MessageListBean data = new MessageListBean();
    data.replaceData(list);
    new Thread(new Runnable() {

        @Override
        public void run() {
            deleteAllReposts(accountId);
            addRepostLineMsg(data, accountId);
        }
    }).start();
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean)

Example 24 with MessageListBean

use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.

the class StatusesByIdLoader method loadData.

public MessageListBean loadData() throws WeiboException {
    StatusesTimeLineDao dao = new StatusesTimeLineDao(token, uid);
    if (TextUtils.isEmpty(uid)) {
        dao.setScreen_name(screenName);
    }
    if (!TextUtils.isEmpty(count)) {
        dao.setCount(count);
    }
    dao.setSince_id(sinceId);
    dao.setMax_id(maxId);
    MessageListBean result = null;
    lock.lock();
    try {
        result = dao.getGSONMsgList();
    } finally {
        lock.unlock();
    }
    return result;
}
Also used : MessageListBean(org.qii.weiciyuan.bean.MessageListBean) StatusesTimeLineDao(org.qii.weiciyuan.dao.user.StatusesTimeLineDao)

Example 25 with MessageListBean

use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.

the class MainFriendsTimeLineDao method getGSONMsgList.

public MessageListBean getGSONMsgList() throws WeiboException {
    String json = getMsgListJson();
    Gson gson = new Gson();
    MessageListBean value = null;
    try {
        value = gson.fromJson(json, MessageListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
        throw new WeiboException(e.getMessage());
    }
    if (value != null && value.getItemList().size() > 0) {
        TimeLineUtility.filterMessage(value);
        TimeLineUtility.filterHomeTimeLineSinaWeiboAd(value);
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) WeiboException(org.qii.weiciyuan.support.error.WeiboException) MessageListBean(org.qii.weiciyuan.bean.MessageListBean) Gson(com.google.gson.Gson)

Aggregations

MessageListBean (org.qii.weiciyuan.bean.MessageListBean)25 Gson (com.google.gson.Gson)8 JsonSyntaxException (com.google.gson.JsonSyntaxException)8 MessageBean (org.qii.weiciyuan.bean.MessageBean)8 ArrayList (java.util.ArrayList)6 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)5 Cursor (android.database.Cursor)4 UnreadBean (org.qii.weiciyuan.bean.UnreadBean)4 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)4 MentionTimeLineData (org.qii.weiciyuan.bean.android.MentionTimeLineData)3 MessageTimeLineData (org.qii.weiciyuan.bean.android.MessageTimeLineData)3 AccountBean (org.qii.weiciyuan.bean.AccountBean)2 MentionsWeiboTimeLineDao (org.qii.weiciyuan.dao.maintimeline.MentionsWeiboTimeLineDao)2 Notification (android.app.Notification)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bitmap (android.graphics.Bitmap)1