/**
   * 得到
   *
   * @param top
   * @param where
   */
  public List<Blog> GetBlogListByWhere(String limit, String where, String[] args) {
    List<Blog> listBlog = new ArrayList<Blog>();
    String orderBy = "BlogID desc";
    Cursor cursor = db.query(Config.DB_BLOG_TABLE, null, where, args, null, null, orderBy, limit);
    while (cursor != null && cursor.moveToNext()) {
      Blog entity = new Blog();
      String addTimeStr = cursor.getString(cursor.getColumnIndex("Published"));
      Date addTime = AppUtil.ParseDate(addTimeStr);
      entity.SetAddTime(addTime);
      entity.SetAuthor(cursor.getString(cursor.getColumnIndex("AuthorName")));
      entity.SetAuthorUrl(cursor.getString(cursor.getColumnIndex("AuthorUrl")));
      entity.SetAvator(cursor.getString(cursor.getColumnIndex("AuthorAvatar")));
      entity.SetBlogContent(cursor.getString(cursor.getColumnIndex("Content")));
      entity.SetBlogId(cursor.getInt(cursor.getColumnIndex("BlogId")));
      entity.SetBlogTitle(cursor.getString(cursor.getColumnIndex("BlogTitle")));
      String blogUrl = "";
      if (cursor.getString(cursor.getColumnIndex("BlogUrl")) != null) {
        blogUrl = cursor.getString(cursor.getColumnIndex("BlogUrl"));
      }
      entity.SetBlogUrl(blogUrl);
      entity.SetCateId(cursor.getInt(cursor.getColumnIndex("CateId")));
      String cateName = "";
      if (cursor.getString(cursor.getColumnIndex("CateName")) != null) {
        cateName = cursor.getString(cursor.getColumnIndex("CateName"));
      }
      entity.SetCateName(cateName);
      entity.SetCommentNum(cursor.getInt(cursor.getColumnIndex("Comments")));
      entity.SetDiggsNum(cursor.getInt(cursor.getColumnIndex("Digg")));
      boolean isFull = cursor.getString(cursor.getColumnIndex("IsFull")).equals("1");
      entity.SetIsFullText(isFull);
      entity.SetSummary(cursor.getString(cursor.getColumnIndex("Summary")));
      Date updateTime = new java.util.Date();
      if (cursor.getString(cursor.getColumnIndex("Updated")) != null) {
        updateTime = AppUtil.ParseDate(cursor.getString(cursor.getColumnIndex("Updated")));
      }
      entity.SetUpdateTime(updateTime);
      entity.SetViewNum(cursor.getInt(cursor.getColumnIndex("View")));
      boolean isRead = cursor.getString(cursor.getColumnIndex("IsReaded")).equals("1");
      entity.SetIsReaded(isRead);
      entity.SetUserName(cursor.getString(cursor.getColumnIndex("UserName")));

      listBlog.add(entity);
    }
    cursor.close();

    return listBlog;
  }
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		Comment entity = list.get(position);
		if (convertView != null && convertView.getId() == R.id.comment_list) {
			viewHolder = (ViewHolder) convertView.getTag();
		} else {
			viewHolder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.comment_list_item, null);
			viewHolder.comment_id = (TextView) convertView
					.findViewById(R.id.comment_id);
			viewHolder.comment_user_name = (TextView) convertView
					.findViewById(R.id.comment_user_name);
			viewHolder.comment_user_url = (TextView) convertView
					.findViewById(R.id.comment_user_url);
			viewHolder.comment_content = (TextView) convertView
					.findViewById(R.id.comment_content);
			viewHolder.comment_format_date = (TextView) convertView
					.findViewById(R.id.comment_format_date);
			viewHolder.comment_date = (TextView) convertView
					.findViewById(R.id.comment_date);
			viewHolder.comment_floor = (TextView) convertView
					.findViewById(R.id.comment_floor);
		}

		viewHolder.comment_id.setText(String.valueOf(entity.GetCommentId()));
		viewHolder.comment_user_name.setText(entity.GetPostUserName());
		viewHolder.comment_user_url.setText(entity.GetPostUserUrl());
		// 替换掉所有的html标签
		String content = entity.GetContent();
		content = content.replace("<br />", "\r\n");
		content = HtmlRegexpUtil.filterHtml(content);
		viewHolder.comment_content.setText(content);

		viewHolder.comment_date.setText(AppUtil.ParseDateToString(entity
				.GetAddTime()));
		String simpleDateString = AppUtil.DateToChineseString(entity
				.GetAddTime());
		viewHolder.comment_format_date.setText(simpleDateString);
		// 楼层
		int floorNum = (pageIndex - 1) * Config.COMMENT_PAGE_SIZE + position
				+ 1;
		viewHolder.comment_floor.setText(String.valueOf(floorNum) + "楼:");

		convertView.setTag(viewHolder);
		return convertView;
	}
  /**
   * 插入
   *
   * @param list
   */
  public void SynchronyData2DB(List<Blog> blogList) {
    List<ContentValues> list = new ArrayList<ContentValues>();
    for (int i = 0, len = blogList.size(); i < len; i++) {
      ContentValues contentValues = new ContentValues();
      contentValues.put("BlogId", blogList.get(i).GetBlogId());
      contentValues.put("BlogTitle", blogList.get(i).GetBlogTitle());
      contentValues.put("Summary", blogList.get(i).GetSummary());
      String content = "";
      if (blogList.get(i).GetBlogContent() != null) {
        content = blogList.get(i).GetBlogContent();
      }
      contentValues.put("Content", content);
      contentValues.put("Published", AppUtil.ParseDateToString(blogList.get(i).GetAddTime()));
      Date datetime = new java.util.Date();
      String updateTime = "";
      if (blogList.get(i).GetUpdateTime() != null) {
        updateTime = AppUtil.ParseDateToString(blogList.get(i).GetUpdateTime());
      } else {
        updateTime = AppUtil.ParseDateToString(datetime);
      }
      contentValues.put("Updated", updateTime);
      contentValues.put("AuthorName", blogList.get(i).GetAuthor());
      contentValues.put("AuthorAvatar", blogList.get(i).GetAvator());
      String authorUrl = "";
      if (blogList.get(i).GetAuthorUrl() != null) {
        authorUrl = blogList.get(i).GetAuthorUrl();
      }
      contentValues.put("AuthorUrl", authorUrl);
      contentValues.put("View", blogList.get(i).GetViewNum());
      contentValues.put("Comments", blogList.get(i).GetCommentNum());
      contentValues.put("Digg", blogList.get(i).GetDiggsNum());
      contentValues.put("IsReaded", false);
      contentValues.put("CateId", blogList.get(i).GetCateId());
      String cateName = "";
      if (blogList.get(i).GetCateName() != null) {
        cateName = blogList.get(i).GetCateName();
      }
      contentValues.put("CateName", cateName);
      contentValues.put("IsFull", blogList.get(i).GetIsFullText());
      contentValues.put("BlogUrl", blogList.get(i).GetBlogUrl());
      contentValues.put("UserName", blogList.get(i).GetUserName());

      list.add(contentValues);
    }
    synchronized (_writeLock) {
      db.beginTransaction();
      try {
        // 清除已有
        // String where="IsFull=?";
        // String[] args={"0"};
        // db.delete(DB_BLOG_TABLE, where, args);
        for (int i = 0, len = list.size(); i < len; i++) {
          int blogId = list.get(i).getAsInteger("BlogId");
          boolean isExist = Exist(blogId);
          boolean isFull = IsFull(blogId);
          if (!isExist) {
            db.insert(Config.DB_BLOG_TABLE, null, list.get(i));
          } else if (!isFull) { // 如果没有写内容
            SynchronyContent2DB(
                list.get(i).getAsInteger("BlogId"), list.get(i).getAsString("Content"));
          }
        }
        db.setTransactionSuccessful();
      } finally {
        db.endTransaction();
      }
    }
  }