use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.
the class HomeOtherGroupTimeLineDBTask method addHomeLineMsg.
private static void addHomeLineMsg(MessageListBean list, String accountId, String groupId) {
if (list == null || list.getSize() == 0) {
return;
}
Gson gson = new Gson();
List<MessageBean> msgList = list.getItemList();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), HomeOtherGroupTable.HomeOtherGroupDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.JSONDATA);
final int groupidColumn = ih.getColumnIndex(HomeOtherGroupTable.HomeOtherGroupDataTable.GROUPID);
try {
getWsd().beginTransaction();
for (int i = 0; i < msgList.size(); i++) {
MessageBean msg = msgList.get(i);
ih.prepareForInsert();
if (msg != null) {
ih.bind(mblogidColumn, msg.getId());
ih.bind(accountidColumn, accountId);
String json = gson.toJson(msg);
ih.bind(jsondataColumn, json);
ih.bind(groupidColumn, groupId);
} else {
ih.bind(mblogidColumn, "-1");
ih.bind(accountidColumn, accountId);
ih.bind(jsondataColumn, "");
ih.bind(groupidColumn, groupId);
}
ih.execute();
}
getWsd().setTransactionSuccessful();
} catch (SQLException e) {
} finally {
getWsd().endTransaction();
ih.close();
}
reduceHomeOtherGroupTable(accountId, groupId);
}
use of org.qii.weiciyuan.bean.MessageBean 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;
}
use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.
the class MentionWeiboTimeLineDBTask method addRepostLineMsg.
public static void addRepostLineMsg(MessageListBean list, String accountId) {
Gson gson = new Gson();
List<MessageBean> msgList = list.getItemList();
int size = msgList.size();
DatabaseUtils.InsertHelper ih = new DatabaseUtils.InsertHelper(getWsd(), RepostsTable.RepostDataTable.TABLE_NAME);
final int mblogidColumn = ih.getColumnIndex(RepostsTable.RepostDataTable.MBLOGID);
final int accountidColumn = ih.getColumnIndex(RepostsTable.RepostDataTable.ACCOUNTID);
final int jsondataColumn = ih.getColumnIndex(RepostsTable.RepostDataTable.JSONDATA);
try {
getWsd().beginTransaction();
for (int i = 0; i < size; i++) {
MessageBean msg = msgList.get(i);
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();
}
reduceRepostTable(accountId);
}
use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.
the class UserInfoFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data == null) {
return;
}
MessageBean msg = (MessageBean) data.getParcelableExtra("msg");
if (msg != null) {
for (int i = 0; i < getList().getSize(); i++) {
if (msg.equals(getList().getItem(i))) {
getList().getItem(i).setReposts_count(msg.getReposts_count());
getList().getItem(i).setComments_count(msg.getComments_count());
break;
}
}
getAdapter().notifyDataSetChanged();
}
}
use of org.qii.weiciyuan.bean.MessageBean in project weiciyuan by qii.
the class MyFavListFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//use Up instead of Back to reach this fragment
if (data == null) {
return;
}
final MessageBean msg = (MessageBean) data.getParcelableExtra("msg");
if (msg != null) {
for (int i = 0; i < getList().getSize(); i++) {
if (msg.equals(getList().getItem(i))) {
MessageBean ori = getList().getItem(i);
if (ori.getComments_count() != msg.getComments_count() || ori.getReposts_count() != msg.getReposts_count()) {
ori.setReposts_count(msg.getReposts_count());
ori.setComments_count(msg.getComments_count());
FavouriteDBTask.asyncReplace(getList(), page, account.getUid());
getAdapter().notifyDataSetChanged();
}
break;
}
}
}
}
Aggregations