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;
}
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;
}
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);
}
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);
}
}
}
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;
}
Aggregations