use of org.qii.weiciyuan.bean.android.MentionTimeLineData 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.android.MentionTimeLineData 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.android.MentionTimeLineData in project weiciyuan by qii.
the class MentionsWeiboTimeLineFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
userBean = getArguments().getParcelable(ARGUMENTS_USER_EXTRA);
accountBean = getArguments().getParcelable(ARGUMENTS_ACCOUNT_EXTRA);
token = getArguments().getString(ARGUMENTS_TOKEN_EXTRA);
super.onActivityCreated(savedInstanceState);
switch(getCurrentState(savedInstanceState)) {
case FIRST_TIME_START:
getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
break;
case ACTIVITY_DESTROY_AND_CREATE:
timeLinePosition = (TimeLinePosition) savedInstanceState.getSerializable(ARGUMENTS_TIMELINE_POSITION_EXTRA);
Loader<MentionTimeLineData> loader = getLoaderManager().getLoader(DB_CACHE_LOADER_ID);
if (loader != null) {
getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
}
MessageListBean savedBean = savedInstanceState.getParcelable(ARGUMENTS_DATA_EXTRA);
if (savedBean != null && savedBean.getSize() > 0) {
getList().replaceData(savedBean);
timeLineAdapter.notifyDataSetChanged();
refreshLayout(getList());
AppNotificationCenter.getInstance().addCallback(callback);
} else {
getLoaderManager().initLoader(DB_CACHE_LOADER_ID, null, dbCallback);
}
break;
}
}
use of org.qii.weiciyuan.bean.android.MentionTimeLineData 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;
}
Aggregations