Commits

Michael Ma committed d833cbf

BUG FIX: 删除笔记本

Comments (0)

Files changed (4)

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

 	OnItemClickListener oicl = new OnItemClickListener() {
 		public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
 			int bookmarkId = (Integer) listItem.get(position).get("bookmarkid");
-			if (-1 == bookmarkId)
+			if (-2 == bookmarkId)
 				return;
 			else {
 				int startLine = (Integer) listItem.get(position).get("bookmarkpos");
 			HashMap<String, Object> noContentMap = new HashMap<String, Object>();
 			noContentMap.put("bookmarkname", "没有书签");
 			noContentMap.put("bookmarkpos", "");
-			noContentMap.put("bookmarkid", -1);
+			noContentMap.put("bookmarkid", -2);
 			listItem.add(noContentMap);
 		}
 	}

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

 			HashMap<String, Object> noContentMap = new HashMap<String, Object>();
 			noContentMap.put("notebookName", "暂无内容");
 			noContentMap.put("noteNumber", "");
-			noContentMap.put("id", -1);
+			noContentMap.put("id", -2);
 			notebookList.add(noContentMap);
 		}
 		SimpleAdapter listAdapter = new SimpleAdapter(this, notebookList, R.layout.notebook_listview	, new String[] { "notebookName", "noteNumber" }, new int[] {
 	protected void onListItemClick(ListView l, View v, int position, long id) {
 		super.onListItemClick(l, v, position, id);
 		int pk = (Integer) notebookList.get(position).get("id");
-		if (-1 == pk)
+		if (-2 == pk)
 			return;
 		else {
 			Intent intent = new Intent();

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

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

Project/src/com/noodle/note/persistent/unitofwork/Session.java

 	public void delete(EntityModel model) {
 		// 状态转移:(waiting_for_insert|waiting_for_update|clean) ->
 		// waiting_for_delete
-		if (status.containsKey(model)) {
+		//FIXME
+		//if (status.containsKey(model)) {
 			status.put(model, ModelStatus.WAITING_FOR_DELETE);
-		}
+		//}
 	}
 
 	/**