use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class FetchNewMsgService method fetchMsg.
private void fetchMsg(AccountBean accountBean) throws WeiboException {
CommentListBean commentResult = null;
MessageListBean mentionStatusesResult = null;
CommentListBean mentionCommentsResult = null;
UnreadBean unreadBean = null;
String token = accountBean.getAccess_token();
UnreadDao unreadDao = new UnreadDao(token, accountBean.getUid());
unreadBean = unreadDao.getCount();
if (unreadBean == null) {
return;
}
int unreadCommentCount = unreadBean.getCmt();
int unreadMentionStatusCount = unreadBean.getMention_status();
int unreadMentionCommentCount = unreadBean.getMention_cmt();
if (unreadCommentCount > 0 && SettingUtility.allowCommentToMe()) {
MainCommentsTimeLineDao dao = new MainCommentsTimeLineDao(token);
CommentListBean oldData = null;
CommentTimeLineData commentTimeLineData = CommentToMeTimeLineDBTask.getCommentLineMsgList(accountBean.getUid());
if (commentTimeLineData != null) {
oldData = commentTimeLineData.cmtList;
}
if (oldData != null && oldData.getSize() > 0) {
dao.setSince_id(oldData.getItem(0).getId());
}
commentResult = dao.getGSONMsgListWithoutClearUnread();
}
if (unreadMentionStatusCount > 0 && SettingUtility.allowMentionToMe()) {
MentionsWeiboTimeLineDao dao = new MentionsWeiboTimeLineDao(token);
MessageListBean oldData = null;
MentionTimeLineData mentionStatusTimeLineData = MentionWeiboTimeLineDBTask.getRepostLineMsgList(accountBean.getUid());
if (mentionStatusTimeLineData != null) {
oldData = mentionStatusTimeLineData.msgList;
}
if (oldData != null && oldData.getSize() > 0) {
dao.setSince_id(oldData.getItem(0).getId());
}
mentionStatusesResult = dao.getGSONMsgListWithoutClearUnread();
}
if (unreadMentionCommentCount > 0 && SettingUtility.allowMentionCommentToMe()) {
MainCommentsTimeLineDao dao = new MentionsCommentTimeLineDao(token);
CommentListBean oldData = null;
CommentTimeLineData commentTimeLineData = MentionCommentsTimeLineDBTask.getCommentLineMsgList(accountBean.getUid());
if (commentTimeLineData != null) {
oldData = commentTimeLineData.cmtList;
}
if (oldData != null && oldData.getSize() > 0) {
dao.setSince_id(oldData.getItem(0).getId());
}
mentionCommentsResult = dao.getGSONMsgListWithoutClearUnread();
}
clearDatabaseUnreadInfo(accountBean.getUid(), unreadBean.getMention_status(), unreadBean.getMention_cmt(), unreadBean.getCmt());
boolean mentionsWeibo = (mentionStatusesResult != null && mentionStatusesResult.getSize() > 0);
boolean mentionsComment = (mentionCommentsResult != null && mentionCommentsResult.getSize() > 0);
boolean commentsToMe = (commentResult != null && commentResult.getSize() > 0);
if (mentionsWeibo || mentionsComment || commentsToMe) {
sendTwoKindsOfBroadcast(accountBean, commentResult, mentionStatusesResult, mentionCommentsResult, unreadBean);
} else {
// NotificationManager notificationManager = (NotificationManager) getApplicationContext()
// .getSystemService(NOTIFICATION_SERVICE);
// notificationManager.cancel(
// NotificationServiceHelper.getMentionsWeiboNotificationId(accountBean));
}
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class UnreadMsgReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
AccountBean accountBean = (AccountBean) intent.getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA);
CommentListBean commentsToMeData = (CommentListBean) intent.getParcelableExtra(BundleArgsConstants.COMMENTS_TO_ME_EXTRA);
MessageListBean mentionsWeiboData = (MessageListBean) intent.getParcelableExtra(BundleArgsConstants.MENTIONS_WEIBO_EXTRA);
CommentListBean mentionsCommentData = (CommentListBean) intent.getParcelableExtra(BundleArgsConstants.MENTIONS_COMMENT_EXTRA);
UnreadBean unreadBean = (UnreadBean) intent.getParcelableExtra(BundleArgsConstants.UNREAD_EXTRA);
showNotification(context, accountBean, mentionsWeiboData, commentsToMeData, mentionsCommentData, unreadBean);
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class FriendsTimeLineDBTask method getOtherGroupData.
public static List<MessageTimeLineData> getOtherGroupData(String accountId, String exceptGroupId) {
List<MessageTimeLineData> data = new ArrayList<MessageTimeLineData>();
if (!"0".equals(exceptGroupId)) {
TimeLinePosition position = getPosition(accountId);
MessageListBean msgList = getHomeLineMsgList(accountId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
MessageTimeLineData home = new MessageTimeLineData("0", msgList, position);
data.add(home);
}
MessageTimeLineData biGroup = HomeOtherGroupTimeLineDBTask.getTimeLineData(accountId, "1");
data.add(biGroup);
GroupListBean groupListBean = GroupDBTask.get(accountId);
if (groupListBean != null) {
List<GroupBean> lists = groupListBean.getLists();
for (GroupBean groupBean : lists) {
MessageTimeLineData dbMsg = HomeOtherGroupTimeLineDBTask.getTimeLineData(accountId, groupBean.getId());
data.add(dbMsg);
}
}
Iterator<MessageTimeLineData> iterator = data.iterator();
while (iterator.hasNext()) {
MessageTimeLineData single = iterator.next();
if (single.groupId.equals(exceptGroupId)) {
iterator.remove();
break;
}
}
return data;
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class FriendsTimeLineDBTask method getHomeLineMsgList.
private static MessageListBean getHomeLineMsgList(String accountId, int limitCount) {
Gson gson = new Gson();
MessageListBean result = new MessageListBean();
int limit = limitCount > AppConfig.DEFAULT_MSG_COUNT_50 ? limitCount : AppConfig.DEFAULT_MSG_COUNT_50;
List<MessageBean> msgList = new ArrayList<MessageBean>();
String sql = "select * from " + HomeTable.HomeDataTable.TABLE_NAME + " where " + HomeTable.HomeDataTable.ACCOUNTID + " = " + accountId + " order by " + HomeTable.HomeDataTable.ID + " asc limit " + limit;
Cursor c = getRsd().rawQuery(sql, null);
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(HomeTable.HomeDataTable.JSONDATA));
if (!TextUtils.isEmpty(json)) {
try {
MessageBean value = gson.fromJson(json, MessageBean.class);
if (!value.isMiddleUnreadItem() && !TextUtils.isEmpty(value.getText())) {
value.getListViewSpannableString();
}
msgList.add(value);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
} else {
msgList.add(null);
}
}
//delete the null flag at the head positon and the end position
for (int i = msgList.size() - 1; i >= 0; i--) {
if (msgList.get(i) == null) {
msgList.remove(i);
} else {
break;
}
}
for (int i = 0; i < msgList.size(); i++) {
if (msgList.get(i) == null) {
msgList.remove(i);
} else {
break;
}
}
result.setStatuses(msgList);
c.close();
return result;
}
use of org.qii.weiciyuan.bean.MessageListBean in project weiciyuan by qii.
the class HomeOtherGroupTimeLineDBTask method get.
static MessageListBean get(String accountId, String groupId, int limitCount) {
Gson gson = new Gson();
MessageListBean result = new MessageListBean();
int limit = limitCount > AppConfig.DEFAULT_MSG_COUNT_50 ? limitCount : AppConfig.DEFAULT_MSG_COUNT_50;
List<MessageBean> msgList = new ArrayList<MessageBean>();
String sql = "select * from " + HomeOtherGroupTable.HomeOtherGroupDataTable.TABLE_NAME + " where " + HomeOtherGroupTable.HomeOtherGroupDataTable.ACCOUNTID + " = " + accountId + " and " + HomeOtherGroupTable.HomeOtherGroupDataTable.GROUPID + " = " + groupId + " order by " + HomeOtherGroupTable.HomeOtherGroupDataTable.ID + " asc limit " + limit;
Cursor c = getRsd().rawQuery(sql, null);
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.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);
}
}
//delete the null flag at the head positon and the end position
for (int i = msgList.size() - 1; i >= 0; i--) {
if (msgList.get(i) == null) {
msgList.remove(i);
} else {
break;
}
}
for (int i = 0; i < msgList.size(); i++) {
if (msgList.get(i) == null) {
msgList.remove(i);
} else {
break;
}
}
result.setStatuses(msgList);
c.close();
return result;
}
Aggregations