Commits

Jiangge Zhang committed 8c929c3

去掉旧用法(直接调用 Gateway)

  • Participants
  • Parent commits a59c001

Comments (0)

Files changed (2)

Project/src/com/noodle/note/activity/NotebookManageActivity.java

 		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
 		int listItemId = (Integer) listItem.get(info.position).get("id");
 		String notebookName = (String) listItem.get(info.position).get("notebookname");
-		NotebookGateway notebookListGateway = (NotebookGateway) Session.getInstance(this).query(Notebook.class);
+		Session session = Session.getInstance(this);
+		NotebookGateway query = (NotebookGateway) session.query(Notebook.class);
 
 		switch (item.getItemId()) {
 		// 长按菜单的“编辑”操作
 			break;
 		// 长按菜单的“删除”操作
 		case 1:
-			notebookListGateway.deleteById(listItemId);
+			session.delete(query.findById(listItemId));
+			session.flush();
 			Intent selfintent = new Intent();
 			selfintent.setClass(NotebookManageActivity.this, NotebookManageActivity.class);
 			startActivity(selfintent);

Project/src/com/noodle/note/gateway/NotebookGateway.java

 	}
 
 	/**
-	 * FIXME: 该方法不应该存在,表现层重构时用 delete 方法代替
-	 * 
-	 * @param id
-	 */
-	public void deleteById(int id) {
-		SQLiteDatabase db = getWritableDatabase();
-		String[] arguments = { Integer.toString(id) };
-		db.delete(TABLE, "id=?", arguments);
-		// 关闭数据库连接
-		db.close();
-	}
-
-	/**
 	 * 更新笔记本
 	 */
 	@Override