Search in sources :

Example 31 with MessageBean

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

the class SendRepostService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    int lastNotificationId = intent.getIntExtra("lastNotificationId", -1);
    if (lastNotificationId != -1) {
        NotificationUtility.cancel(lastNotificationId);
    }
    String token = intent.getStringExtra("token");
    AccountBean account = (AccountBean) intent.getParcelableExtra("account");
    String content = intent.getStringExtra("content");
    MessageBean oriMsg = (MessageBean) intent.getParcelableExtra("oriMsg");
    String is_comment = intent.getStringExtra("is_comment");
    RepostDraftBean repostDraftBean = (RepostDraftBean) intent.getParcelableExtra("draft");
    WeiboSendTask task = new WeiboSendTask(token, account, content, oriMsg, is_comment, repostDraftBean);
    task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    tasksResult.put(task, false);
    return START_REDELIVER_INTENT;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) RepostDraftBean(org.qii.weiciyuan.support.database.draftbean.RepostDraftBean) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 32 with MessageBean

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

the class BigTextNotificationService method getPendingIntent.

private PendingIntent getPendingIntent(Intent clickToOpenAppPendingIntentInner, Parcelable itemBean, AccountBean accountBean) {
    clickToOpenAppPendingIntentInner.setExtrasClassLoader(getClass().getClassLoader());
    UnreadTabIndex unreadTabIndex = UnreadTabIndex.NONE;
    if (itemBean instanceof MessageBean) {
        unreadTabIndex = UnreadTabIndex.MENTION_WEIBO;
    } else if (itemBean instanceof CommentBean) {
        CommentBean commentBean = (CommentBean) itemBean;
        MessageBean messageBean = commentBean.getStatus();
        if (messageBean != null) {
            UserBean userBean = messageBean.getUser();
            if (accountBean.getInfo().equals(userBean)) {
                unreadTabIndex = UnreadTabIndex.COMMENT_TO_ME;
            } else {
                unreadTabIndex = UnreadTabIndex.MENTION_COMMENT;
            }
        } else {
            unreadTabIndex = UnreadTabIndex.MENTION_COMMENT;
        }
    }
    clickToOpenAppPendingIntentInner.putExtra(BundleArgsConstants.OPEN_NAVIGATION_INDEX_EXTRA, unreadTabIndex);
    PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), getMentionsWeiboNotificationId(accountBean), clickToOpenAppPendingIntentInner, PendingIntent.FLAG_UPDATE_CURRENT);
    return pendingIntent;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) UnreadTabIndex(org.qii.weiciyuan.bean.android.UnreadTabIndex) UserBean(org.qii.weiciyuan.bean.UserBean) PendingIntent(android.app.PendingIntent) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 33 with MessageBean

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

the class AppNotificationCenter method showNotification.

private void showNotification(Context context, AccountBean accountBean, MessageListBean mentionsWeiboData, CommentListBean commentsToMeData, CommentListBean mentionsCommentData, UnreadBean unreadBean) {
    Intent clickNotificationToOpenAppPendingIntentInner = MainTimeLineActivity.newIntent(accountBean, mentionsWeiboData, mentionsCommentData, commentsToMeData, unreadBean);
    clickNotificationToOpenAppPendingIntentInner.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    String accountId = accountBean.getUid();
    Set<String> dbUnreadMentionsWeibo = NotificationDBTask.getUnreadMsgIds(accountId, NotificationDBTask.UnreadDBType.mentionsWeibo);
    Set<String> dbUnreadMentionsComment = NotificationDBTask.getUnreadMsgIds(accountId, NotificationDBTask.UnreadDBType.mentionsComment);
    Set<String> dbUnreadCommentsToMe = NotificationDBTask.getUnreadMsgIds(accountId, NotificationDBTask.UnreadDBType.commentsToMe);
    if (mentionsWeiboData != null && mentionsWeiboData.getSize() > 0) {
        List<MessageBean> msgList = mentionsWeiboData.getItemList();
        Iterator<MessageBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            MessageBean msg = iterator.next();
            if (dbUnreadMentionsWeibo.contains(msg.getId())) {
                iterator.remove();
            }
        }
    }
    if (mentionsCommentData != null && mentionsCommentData.getSize() > 0) {
        List<CommentBean> msgList = mentionsCommentData.getItemList();
        Iterator<CommentBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            CommentBean msg = iterator.next();
            if (dbUnreadMentionsComment.contains(msg.getId())) {
                iterator.remove();
            }
        }
    }
    if (commentsToMeData != null && commentsToMeData.getSize() > 0) {
        List<CommentBean> msgList = commentsToMeData.getItemList();
        Iterator<CommentBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            CommentBean msg = iterator.next();
            if (dbUnreadCommentsToMe.contains(msg.getId())) {
                iterator.remove();
            }
        }
    }
    boolean mentionsWeibo = (mentionsWeiboData != null && mentionsWeiboData.getSize() > 0);
    boolean mentionsComment = (mentionsCommentData != null && mentionsCommentData.getSize() > 0);
    boolean commentsToMe = (commentsToMeData != null && commentsToMeData.getSize() > 0);
    if (!mentionsWeibo && !mentionsComment && !commentsToMe) {
        return;
    }
    String ticker = NotificationUtility.getTicker(unreadBean, mentionsWeiboData, mentionsCommentData, commentsToMeData);
    Intent intent = BigTextNotificationService.newIntent(accountBean, mentionsWeiboData, commentsToMeData, mentionsCommentData, unreadBean, clickNotificationToOpenAppPendingIntentInner, ticker, 0);
    context.startService(intent);
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) Intent(android.content.Intent) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 34 with MessageBean

use of org.qii.weiciyuan.bean.MessageBean 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 35 with MessageBean

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

the class DraftDBManager method getDraftList.

public List<DraftListViewItemBean> getDraftList(String accountId) {
    Gson gson = new Gson();
    List<DraftListViewItemBean> result = new ArrayList<DraftListViewItemBean>();
    String sql = "select * from " + DraftTable.TABLE_NAME + " where " + DraftTable.ACCOUNTID + "  = " + accountId + " order by " + DraftTable.ID + " desc";
    Cursor c = rsd.rawQuery(sql, null);
    while (c.moveToNext()) {
        DraftListViewItemBean item = new DraftListViewItemBean();
        int type = c.getInt(c.getColumnIndex(DraftTable.TYPE));
        item.setType(type);
        item.setId(c.getString(c.getColumnIndex(DraftTable.ID)));
        String content;
        switch(type) {
            case DraftTable.TYPE_WEIBO:
                content = c.getString(c.getColumnIndex(DraftTable.CONTENT));
                StatusDraftBean bean = new StatusDraftBean();
                bean.setId(c.getString(c.getColumnIndex(DraftTable.ID)));
                bean.setContent(content);
                bean.setAccountId(accountId);
                String gpsJson = c.getString(c.getColumnIndex(DraftTable.GPS));
                if (!TextUtils.isEmpty(gpsJson)) {
                    bean.setGps(new Gson().fromJson(gpsJson, GeoBean.class));
                }
                bean.setPic(c.getString(c.getColumnIndex(DraftTable.PIC)));
                item.setStatusDraftBean(bean);
                result.add(item);
                break;
            case DraftTable.TYPE_REPOST:
                content = c.getString(c.getColumnIndex(DraftTable.CONTENT));
                RepostDraftBean repostDraftBean = new RepostDraftBean();
                repostDraftBean.setId(c.getString(c.getColumnIndex(DraftTable.ID)));
                repostDraftBean.setContent(content);
                repostDraftBean.setAccountId(accountId);
                MessageBean messageBean = gson.fromJson(c.getString(c.getColumnIndex(DraftTable.JSONDATA)), MessageBean.class);
                repostDraftBean.setMessageBean(messageBean);
                item.setRepostDraftBean(repostDraftBean);
                result.add(item);
                break;
            case DraftTable.TYPE_COMMENT:
                content = c.getString(c.getColumnIndex(DraftTable.CONTENT));
                CommentDraftBean commentDraftBean = new CommentDraftBean();
                commentDraftBean.setId(c.getString(c.getColumnIndex(DraftTable.ID)));
                commentDraftBean.setContent(content);
                commentDraftBean.setAccountId(accountId);
                MessageBean commentMessageBean = gson.fromJson(c.getString(c.getColumnIndex(DraftTable.JSONDATA)), MessageBean.class);
                commentDraftBean.setMessageBean(commentMessageBean);
                item.setCommentDraftBean(commentDraftBean);
                result.add(item);
                break;
            case DraftTable.TYPE_REPLY:
                content = c.getString(c.getColumnIndex(DraftTable.CONTENT));
                ReplyDraftBean replyDraftBean = new ReplyDraftBean();
                replyDraftBean.setId(c.getString(c.getColumnIndex(DraftTable.ID)));
                replyDraftBean.setContent(content);
                replyDraftBean.setAccountId(accountId);
                CommentBean commentBean = gson.fromJson(c.getString(c.getColumnIndex(DraftTable.JSONDATA)), CommentBean.class);
                replyDraftBean.setCommentBean(commentBean);
                item.setReplyDraftBean(replyDraftBean);
                result.add(item);
                break;
        }
    }
    c.close();
    return result;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) ReplyDraftBean(org.qii.weiciyuan.support.database.draftbean.ReplyDraftBean) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) DraftListViewItemBean(org.qii.weiciyuan.support.database.draftbean.DraftListViewItemBean) Cursor(android.database.Cursor) CommentBean(org.qii.weiciyuan.bean.CommentBean) GeoBean(org.qii.weiciyuan.bean.GeoBean) StatusDraftBean(org.qii.weiciyuan.support.database.draftbean.StatusDraftBean) RepostDraftBean(org.qii.weiciyuan.support.database.draftbean.RepostDraftBean) CommentDraftBean(org.qii.weiciyuan.support.database.draftbean.CommentDraftBean)

Aggregations

MessageBean (org.qii.weiciyuan.bean.MessageBean)52 Gson (com.google.gson.Gson)21 JsonSyntaxException (com.google.gson.JsonSyntaxException)16 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)8 Cursor (android.database.Cursor)7 Intent (android.content.Intent)6 CommentBean (org.qii.weiciyuan.bean.CommentBean)6 UserBean (org.qii.weiciyuan.bean.UserBean)6 DatabaseUtils (android.database.DatabaseUtils)4 SQLException (android.database.SQLException)4 View (android.view.View)4 PendingIntent (android.app.PendingIntent)3 Drawable (android.graphics.drawable.Drawable)3 SpannableString (android.text.SpannableString)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 RelativeLayout (android.widget.RelativeLayout)3 TextView (android.widget.TextView)3