use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.
the class CommentByMeTimeLineDBTask method addCommentLineMsg.
public static void addCommentLineMsg(CommentListBean list, String accountId) {
Gson gson = new Gson();
List<CommentBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), CommentByMeTable.CommentByMeDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(CommentByMeTable.CommentByMeDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(CommentByMeTable.CommentByMeDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(CommentByMeTable.CommentByMeDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (CommentBean msg : msgList) {
ih.prepareForInsert();
if (msg != null) {
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
} else {
ih.bind(mblogidColumn, "-1");
ih.bind(accountidColumn, accountId);
ih.bind(jsondataColumn, "");
}
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceCommentTable(accountId);
}
use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.
the class CommentToMeTimeLineDBTask method addCommentLineMsg.
public static void addCommentLineMsg(CommentListBean list, String accountId) {
Gson gson = new Gson();
List<CommentBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), CommentsTable.CommentsDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(CommentsTable.CommentsDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(CommentsTable.CommentsDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(CommentsTable.CommentsDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (CommentBean msg : msgList) {
ih.prepareForInsert();
if (msg != null) {
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
} else {
ih.bind(mblogidColumn, "-1");
ih.bind(accountidColumn, accountId);
ih.bind(jsondataColumn, "");
}
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceCommentTable(accountId);
}
use of org.qii.weiciyuan.bean.CommentBean 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.CommentBean in project weiciyuan by qii.
the class CommentsToMeTimeLineFragment method addNewDataAndRememberPosition.
private void addNewDataAndRememberPosition(final CommentListBean newValue, boolean ignored) /**unused**/
{
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) {
CommentsToMeTimeLineFragment.this.timeLinePosition.newMsgIds.add(comment.getIdLong());
}
}
newMsgTipBar.setValue(CommentsToMeTimeLineFragment.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(CommentsToMeTimeLineFragment.this.timeLinePosition.newMsgIds.size());
CommentToMeTimeLineDBTask.asyncReplace(getList(), accountBean.getUid());
}
use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.
the class DestroyCommentDao method destroy.
public boolean destroy() throws WeiboException {
String url = URLHelper.COMMENT_DESTROY;
Map<String, String> map = new HashMap<String, String>();
map.put("access_token", access_token);
map.put("cid", cid);
String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
Gson gson = new Gson();
try {
CommentBean value = gson.fromJson(jsonData, CommentBean.class);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
return false;
}
return true;
}
Aggregations