use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class FriendsTimeLineDBTask method getRecentGroupData.
public static MessageTimeLineData getRecentGroupData(String accountId) {
String groupId = getRecentGroupId(accountId);
MessageListBean msgList;
TimeLinePosition position;
if (groupId.equals("0")) {
position = getPosition(accountId);
msgList = getHomeLineMsgList(accountId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
} else {
position = HomeOtherGroupTimeLineDBTask.getPosition(accountId, groupId);
msgList = HomeOtherGroupTimeLineDBTask.get(accountId, groupId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
}
return new MessageTimeLineData(groupId, msgList, position);
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class HomeOtherGroupTimeLineDBTask method getTimeLineData.
static MessageTimeLineData getTimeLineData(String accountId, String groupId) {
TimeLinePosition position = getPosition(accountId, groupId);
MessageListBean msgList = get(accountId, groupId, position.position + AppConfig.DB_CACHE_COUNT_OFFSET);
return new MessageTimeLineData(groupId, msgList, position);
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class MentionsCommentTimeLineFragment method addNewDataAndRememberPosition.
private void addNewDataAndRememberPosition(final CommentListBean newValue) {
AppLogger.i("Add new unread data to memory cache");
if (getActivity() == null || newValue.getSize() == 0) {
AppLogger.i("Activity is destroyed or new data count is zero, give up");
return;
}
final boolean isDataSourceEmpty = getList().getSize() == 0;
TimeLinePosition previousPosition = Utility.getCurrentPositionFromListView(getListView());
getList().addNewData(newValue);
if (isDataSourceEmpty) {
newMsgTipBar.setValue(newValue, true);
newMsgTipBar.clearAndReset();
getAdapter().notifyDataSetChanged();
AppLogger.i("Init data source is empty, ListView jump to zero position after refresh, first time open app? ");
getListView().setSelection(0);
saveTimeLinePositionToDB();
} else {
if (previousPosition.isEmpty() && timeLinePosition != null) {
previousPosition = timeLinePosition;
}
AppLogger.i("Previous first visible item id " + previousPosition.firstItemId);
getAdapter().notifyDataSetChanged();
List<CommentBean> unreadData = newValue.getItemList();
for (CommentBean comment : unreadData) {
if (comment != null) {
MentionsCommentTimeLineFragment.this.timeLinePosition.newMsgIds.add(comment.getIdLong());
}
}
newMsgTipBar.setValue(MentionsCommentTimeLineFragment.this.timeLinePosition.newMsgIds);
int positionInAdapter = Utility.getAdapterPositionFromItemId(getAdapter(), previousPosition.firstItemId);
//use 1 px to show newMsgTipBar
AppLogger.i("ListView restore to previous position " + positionInAdapter);
getListView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
getListView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
AppLogger.i("Save ListView position to database");
saveTimeLinePositionToDB();
}
});
Utility.setListViewAdapterPosition(getListView(), positionInAdapter, previousPosition.top - 1, null);
}
showUIUnreadCount(MentionsCommentTimeLineFragment.this.timeLinePosition.newMsgIds.size());
MentionCommentsTimeLineDBTask.asyncReplace(getList(), accountBean.getUid());
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class MentionsCommentTimeLineFragment method saveTimeLinePositionToDB.
private void saveTimeLinePositionToDB() {
TimeLinePosition current = Utility.getCurrentPositionFromListView(getListView());
if (!current.isEmpty()) {
timeLinePosition = current;
timeLinePosition.newMsgIds = newMsgTipBar.getValues();
}
if (timeLinePosition != null) {
MentionCommentsTimeLineDBTask.asyncUpdatePosition(timeLinePosition, accountBean.getUid());
}
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class MentionsWeiboTimeLineFragment method saveTimeLinePositionToDB.
private void saveTimeLinePositionToDB() {
TimeLinePosition current = Utility.getCurrentPositionFromListView(getListView());
if (!current.isEmpty()) {
timeLinePosition = current;
timeLinePosition.newMsgIds = newMsgTipBar.getValues();
}
if (timeLinePosition != null) {
MentionWeiboTimeLineDBTask.asyncUpdatePosition(timeLinePosition, accountBean.getUid());
}
}
Aggregations