use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class MyStatusDBTask method getPosition.
private static TimeLinePosition getPosition(String accountId) {
String sql = "select * from " + MyStatusTable.TABLE_NAME + " where " + MyStatusTable.ACCOUNTID + " = " + accountId;
Cursor c = getRsd().rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(MyStatusTable.TIMELINEDATA));
if (!TextUtils.isEmpty(json)) {
try {
TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
c.close();
return value;
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
}
}
c.close();
return TimeLinePosition.empty();
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class FriendsTimeLineFragment method savePositionToDB.
//must create new position every time onpause, pulltorefresh wont call onListViewScrollStop
private void savePositionToDB() {
savePositionToPositionsCache();
TimeLinePosition position = positionCache.get(currentGroupId);
if (position != null) {
position.newMsgIds = newMsgTipBar.getValues();
final String groupId = currentGroupId;
FriendsTimeLineDBTask.asyncUpdatePosition(position, GlobalContext.getInstance().getCurrentAccountId(), groupId);
AppLogger.i("Save FriendsTimeLineFragment position to database current first visible item id " + position.firstItemId);
}
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class FriendsTimeLineFragment method setListViewPositionFromPositionsCache.
private void setListViewPositionFromPositionsCache() {
final TimeLinePosition timeLinePosition = positionCache.get(currentGroupId);
AppLogger.i("Memory cached position first visible item id " + (timeLinePosition != null ? timeLinePosition.firstItemId : 0));
int position = timeLinePosition != null ? timeLinePosition.getPosition(bean) : 0;
int top = timeLinePosition != null ? timeLinePosition.top : 0;
AppLogger.i("Set ListView position from memory cached position position " + position + " top " + top);
Utility.setListViewAdapterPosition(getListView(), position, top, new Runnable() {
@Override
public void run() {
setListViewUnreadTipBar(timeLinePosition);
}
});
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class FriendsTimeLineFragment method saveNewMsgCountToPositionsCache.
private void saveNewMsgCountToPositionsCache() {
final TimeLinePosition position = positionCache.get(currentGroupId);
position.newMsgIds = newMsgTipBar.getValues();
}
use of org.qii.weiciyuan.bean.android.TimeLinePosition in project weiciyuan by qii.
the class CommentsToMeTimeLineFragment method saveTimeLinePositionToDB.
private void saveTimeLinePositionToDB() {
TimeLinePosition current = Utility.getCurrentPositionFromListView(getListView());
if (!current.isEmpty()) {
timeLinePosition = current;
timeLinePosition.newMsgIds = newMsgTipBar.getValues();
AppLogger.i("Current ListView position first visible item id " + current.firstItemId + " , save to memory cache");
} else {
AppLogger.i("Cant get correct current ListView position, so use previous database data");
}
if (timeLinePosition != null) {
CommentToMeTimeLineDBTask.asyncUpdatePosition(timeLinePosition, accountBean.getUid());
}
}
Aggregations