Search in sources :

Example 11 with TimeLinePosition

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();
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) Gson(com.google.gson.Gson) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition) Cursor(android.database.Cursor)

Example 12 with TimeLinePosition

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);
    }
}
Also used : TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition)

Example 13 with TimeLinePosition

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);
        }
    });
}
Also used : WifiAutoDownloadPictureRunnable(org.qii.weiciyuan.othercomponent.WifiAutoDownloadPictureRunnable) TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition)

Example 14 with 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();
}
Also used : TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition)

Example 15 with TimeLinePosition

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());
    }
}
Also used : TimeLinePosition(org.qii.weiciyuan.bean.android.TimeLinePosition)

Aggregations

TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)30 Cursor (android.database.Cursor)12 Gson (com.google.gson.Gson)12 JsonSyntaxException (com.google.gson.JsonSyntaxException)12 CommentBean (org.qii.weiciyuan.bean.CommentBean)7 ArrayList (java.util.ArrayList)5 CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)5 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)4 ViewTreeObserver (android.view.ViewTreeObserver)3 HashMap (java.util.HashMap)3 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)3 MessageBean (org.qii.weiciyuan.bean.MessageBean)3 MessageTimeLineData (org.qii.weiciyuan.bean.android.MessageTimeLineData)3 MentionTimeLineData (org.qii.weiciyuan.bean.android.MentionTimeLineData)2 View (android.view.View)1 WebView (android.webkit.WebView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 GroupBean (org.qii.weiciyuan.bean.GroupBean)1