From bb8e23905f1be50bb35d7894c53be451fa7b5046 Mon Sep 17 00:00:00 2001 From: Yuji Konishi Date: Mon, 3 Sep 2012 22:53:44 +0900 Subject: [PATCH] T29439 --- .../src/com/yuji/ef/EverFolderActivity.java | 6 +- .../src/com/yuji/ef/IconFrameLayout.java | 3 + .../src/com/yuji/ef/dao/NodeCacheDao.java | 2 +- .../com/yuji/ef/service/NoteUpdatorService.java | 3 +- .../src/com/yuji/ef/task/NoteUpdateTask.java | 2 + .../src/com/yuji/ef/utility/EvernoteUtil.java | 259 +++++++++++++-------- .../src/com/yuji/ef/utility/FolderUtil.java | 11 + 7 files changed, 183 insertions(+), 103 deletions(-) diff --git a/source/workspace/EverFolder/src/com/yuji/ef/EverFolderActivity.java b/source/workspace/EverFolder/src/com/yuji/ef/EverFolderActivity.java index 987ca73..a156c7a 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/EverFolderActivity.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/EverFolderActivity.java @@ -640,7 +640,11 @@ public class EverFolderActivity extends BaseActivity implements LockListener { layout.setVisibility(View.INVISIBLE); setStatus(); } - + else { + // #29421 + updateList(); + } + // NodeDao dao = (NodeDao) NodeCacheDao.getInstance(); // if (dao.isEmpty()) { // if (isInit) { diff --git a/source/workspace/EverFolder/src/com/yuji/ef/IconFrameLayout.java b/source/workspace/EverFolder/src/com/yuji/ef/IconFrameLayout.java index c3a51a1..d4353f7 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/IconFrameLayout.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/IconFrameLayout.java @@ -196,6 +196,9 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener } public void setCutTarget(LabelIconView cutTarget, boolean isUnselected) { + if (this.cutTarget != null){ + setAlpha(this.cutTarget); + } this.cutTarget = cutTarget; if (isUnselected) { selectedTarget = null; diff --git a/source/workspace/EverFolder/src/com/yuji/ef/dao/NodeCacheDao.java b/source/workspace/EverFolder/src/com/yuji/ef/dao/NodeCacheDao.java index cd81a68..92b831f 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/dao/NodeCacheDao.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/dao/NodeCacheDao.java @@ -9,7 +9,7 @@ import android.database.sqlite.SQLiteDatabase; import com.yuji.ef.dao.Node.Status; public class NodeCacheDao extends NodeDaoImpl implements IDao, NodeDao { - private static final int MAP_SIZE = 8; + private static final int MAP_SIZE = 1024; private static IDao instance = null; //private static NodeDao dao = (NodeDao) NodeDaoImpl.getInstance(); diff --git a/source/workspace/EverFolder/src/com/yuji/ef/service/NoteUpdatorService.java b/source/workspace/EverFolder/src/com/yuji/ef/service/NoteUpdatorService.java index 2f7505a..28915f3 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/service/NoteUpdatorService.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/service/NoteUpdatorService.java @@ -83,9 +83,8 @@ public class NoteUpdatorService extends Service { } } } - - setNextTime(NoteUpdatorService.this); } finally { + setNextTime(NoteUpdatorService.this); NoteUpdatorService.this.stopSelf(); } } diff --git a/source/workspace/EverFolder/src/com/yuji/ef/task/NoteUpdateTask.java b/source/workspace/EverFolder/src/com/yuji/ef/task/NoteUpdateTask.java index e08ae64..1295d89 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/task/NoteUpdateTask.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/task/NoteUpdateTask.java @@ -35,6 +35,8 @@ public class NoteUpdateTask implements AsyncTaskIF { // TODO // 実行中は、画面操作禁止にする try { +// FolderUtil test = FolderUtil.getInstance(); +// test.createTestNote(); FolderUtil util = FolderUtil.getInstance(); util.update(isRoot, isBook, isNote); } catch (Exception e) { diff --git a/source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteUtil.java b/source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteUtil.java index 3d7c0cc..807e54b 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteUtil.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteUtil.java @@ -98,15 +98,15 @@ public class EvernoteUtil { return note; } - private NoteFilter getDefaultFilter(){ + private NoteFilter getDefaultFilter() { // 検索条件として、検索語なし、更新日順ソートを指定 NoteFilter filter = new NoteFilter(); filter.setOrder(NoteSortOrder.UPDATED.getValue()); - filter.setAscending(false); + filter.setAscending(false); return filter; } - + public List getNoteList() { NoteFilter filter = getDefaultFilter(); return getNoteList(filter); @@ -117,7 +117,7 @@ public class EvernoteUtil { filter.setNotebookGuid(notebookGuid); return getNoteList(filter); } - + public List getNoteListByTag(String tagGuid) { NoteFilter filter = getDefaultFilter(); List tagGuids = new ArrayList(); @@ -125,7 +125,7 @@ public class EvernoteUtil { filter.setTagGuids(tagGuids); return getNoteList(filter); } - + public List getNoteList(NoteFilter filter) { errorCode = Error.OTHER; @@ -136,20 +136,21 @@ public class EvernoteUtil { return null; } int index = 0; - while (true){ - NoteList noteList = noteStore.findNotes(token, filter, index, N); + while (true) { + NoteList noteList = noteStore + .findNotes(token, filter, index, N); int size = noteList.getNotesSize(); - - if (size <= 0){ + + if (size <= 0) { break; } list.add(noteList); - if (size < N){ + if (size < N) { break; } index += size; } - + errorCode = Error.NONE; } catch (EDAMUserException e) { Debug.d(this, null, e); @@ -286,13 +287,13 @@ public class EvernoteUtil { return n; } - public boolean isLoggedIn(){ + public boolean isLoggedIn() { return session != null; } - + private String getAuthenticationToken() { if (authenticationToken == null) { - authenticationToken = session.getAuthToken(); + authenticationToken = session.getAuthToken(); try { noteStore = session.createNoteStore(); } catch (TTransportException e) { @@ -302,7 +303,7 @@ public class EvernoteUtil { } return authenticationToken; } - + private String getAuthenticationTokenBak() { try { if (authenticationToken == null) { @@ -370,90 +371,150 @@ public class EvernoteUtil { this.session = session; } + public void createNotes(String guid, String title, int size){ + Note note; + String token = getAuthenticationToken(); + if (token == null) { + return; + } + Notebook notebook; + try { + notebook = noteStore.getNotebook(token, guid); + for (int i = 0; i < size; i++){ + note = createNote(notebook, title + i); + if (note == null){ + return; + } + } + } catch (EDAMUserException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (EDAMSystemException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (EDAMNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } -// public String getErrorMessage(Context context, Error code) { -// if (code.equals(Error.NONE)) { -// return ""; -// } -// if (code.equals(Error.CONNECT)) { -// return context.getString(R.string.toastConnect); -// } -// if (code.equals(Error.INVALID_AUTH)) { -// return context.getString(R.string.toastInvalidAuth); -// } -// if (code.equals(Error.NOT_FOUND)) { -// return context.getString(R.string.toastNoteDoesNotExist); -// } -// return context.getString(R.string.toastEvernoteSystem); -// } -// -// public static com.yuji.ec.db.Note toNote(Note n, String text) { -// com.yuji.ec.db.Note note = new com.yuji.ec.db.Note(n.getGuid(), text, -// n.getCreated(), n.getUpdated()); -// return note; -// } -// -// public List getNoteContentList(List noteListList) { -// List list = new ArrayList(); -// for (NoteList noteList : noteListList){ -// List l = getNoteContentList(noteList); -// if (l == null){ -// return null; -// } -// list.addAll(l); -// } -// return list; -// } -// -// public List getNoteContentList(NoteList noteList) { -// errorCode = Error.OTHER; -// -// List list = new ArrayList(); -// HtmlParser parser = new HtmlParser(); -// -// try { -// List notes = noteList.getNotes(); -// int s = noteList.getNotesSize(); -// System.out.println("" + s); -// for (Note n : notes) { -// String guid = n.getGuid(); -// Note nc = getNote(guid); -// String content = nc.getContent(); -// if (!parser.parse(content)){ -// return null; -// } -// String text = parser.getText(); -// com.yuji.ec.db.Note note = toNote(nc, text); -// list.add(note); -// } -// notes = noteList.getNotes(); -// s = noteList.getNotesSize(); -// errorCode = Error.NONE; -// } catch (EDAMNotFoundException e) { -// errorCode = Error.NOT_FOUND; -// return null; -// } -// return list; -// } -// -// public List toNoteItemFromNoteBook(List noteList) { -// List list = new ArrayList(); -// for (Notebook notebook : noteList) { -// com.yuji.ec.db.Note item = new com.yuji.ec.db.Note( -// notebook.getGuid(), notebook.getName(), -1, -1); -// list.add(item); -// } -// return list; -// } -// -// public List toNoteItemFromTag(List tagList) { -// List list = new ArrayList(); -// for (Tag tag : tagList) { -// com.yuji.ec.db.Note item = new com.yuji.ec.db.Note(tag.getGuid(), -// tag.getName(), -1, -1); -// list.add(item); -// } -// return list; -// } + public Note createNote(Notebook notebook, String title){ + String authToken = getAuthenticationToken(); + if (authToken == null){ + return null; + } + Note note = new Note(); + note.setTitle(title); + String content = "" + + "" + + "Hello Evernote."; + note.setContent(content); + note.setNotebookGuid(notebook.getGuid()); + Note newNote = null; + try { + newNote = noteStore.createNote(authToken, note); + } catch (EDAMUserException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (EDAMSystemException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (EDAMNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newNote; + } + // public String getErrorMessage(Context context, Error code) { + // if (code.equals(Error.NONE)) { + // return ""; + // } + // if (code.equals(Error.CONNECT)) { + // return context.getString(R.string.toastConnect); + // } + // if (code.equals(Error.INVALID_AUTH)) { + // return context.getString(R.string.toastInvalidAuth); + // } + // if (code.equals(Error.NOT_FOUND)) { + // return context.getString(R.string.toastNoteDoesNotExist); + // } + // return context.getString(R.string.toastEvernoteSystem); + // } + // + // public static com.yuji.ec.db.Note toNote(Note n, String text) { + // com.yuji.ec.db.Note note = new com.yuji.ec.db.Note(n.getGuid(), text, + // n.getCreated(), n.getUpdated()); + // return note; + // } + // + // public List getNoteContentList(List + // noteListList) { + // List list = new ArrayList(); + // for (NoteList noteList : noteListList){ + // List l = getNoteContentList(noteList); + // if (l == null){ + // return null; + // } + // list.addAll(l); + // } + // return list; + // } + // + // public List getNoteContentList(NoteList noteList) { + // errorCode = Error.OTHER; + // + // List list = new ArrayList(); + // HtmlParser parser = new HtmlParser(); + // + // try { + // List notes = noteList.getNotes(); + // int s = noteList.getNotesSize(); + // System.out.println("" + s); + // for (Note n : notes) { + // String guid = n.getGuid(); + // Note nc = getNote(guid); + // String content = nc.getContent(); + // if (!parser.parse(content)){ + // return null; + // } + // String text = parser.getText(); + // com.yuji.ec.db.Note note = toNote(nc, text); + // list.add(note); + // } + // notes = noteList.getNotes(); + // s = noteList.getNotesSize(); + // errorCode = Error.NONE; + // } catch (EDAMNotFoundException e) { + // errorCode = Error.NOT_FOUND; + // return null; + // } + // return list; + // } + // + // public List toNoteItemFromNoteBook(List noteList) { + // List list = new ArrayList(); + // for (Notebook notebook : noteList) { + // com.yuji.ec.db.Note item = new com.yuji.ec.db.Note( + // notebook.getGuid(), notebook.getName(), -1, -1); + // list.add(item); + // } + // return list; + // } + // + // public List toNoteItemFromTag(List tagList) { + // List list = new ArrayList(); + // for (Tag tag : tagList) { + // com.yuji.ec.db.Note item = new com.yuji.ec.db.Note(tag.getGuid(), + // tag.getName(), -1, -1); + // list.add(item); + // } + // return list; + // } } \ No newline at end of file diff --git a/source/workspace/EverFolder/src/com/yuji/ef/utility/FolderUtil.java b/source/workspace/EverFolder/src/com/yuji/ef/utility/FolderUtil.java index b43da0f..cd0fbc5 100644 --- a/source/workspace/EverFolder/src/com/yuji/ef/utility/FolderUtil.java +++ b/source/workspace/EverFolder/src/com/yuji/ef/utility/FolderUtil.java @@ -333,4 +333,15 @@ public class FolderUtil { return 0; } + + public void createTestNote(){ + int pos = 1; + List list = nodeDao.searchBook(); + Node node = list.get(pos); + String guid = node.getGuid(); + + EvernoteUtil util = EvernoteUtil.getInstance(); + util.createNotes(guid, "テスト", 100); + + } } -- 2.11.0