OSDN Git Service

T29439
authorYuji Konishi <yuji.k64613@gmail.com>
Mon, 3 Sep 2012 13:53:44 +0000 (22:53 +0900)
committerYuji Konishi <yuji.k64613@gmail.com>
Mon, 3 Sep 2012 13:53:44 +0000 (22:53 +0900)
source/workspace/EverFolder/src/com/yuji/ef/EverFolderActivity.java
source/workspace/EverFolder/src/com/yuji/ef/IconFrameLayout.java
source/workspace/EverFolder/src/com/yuji/ef/dao/NodeCacheDao.java
source/workspace/EverFolder/src/com/yuji/ef/service/NoteUpdatorService.java
source/workspace/EverFolder/src/com/yuji/ef/task/NoteUpdateTask.java
source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteUtil.java
source/workspace/EverFolder/src/com/yuji/ef/utility/FolderUtil.java

index 987ca73..a156c7a 100644 (file)
@@ -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) {
index c3a51a1..d4353f7 100644 (file)
@@ -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;
index cd81a68..92b831f 100644 (file)
@@ -9,7 +9,7 @@ import android.database.sqlite.SQLiteDatabase;
 import com.yuji.ef.dao.Node.Status;
 
 public class NodeCacheDao extends NodeDaoImpl implements IDao<Node>, NodeDao {
-       private static final int MAP_SIZE = 8;
+       private static final int MAP_SIZE = 1024;
 
        private static IDao<Node> instance = null;
        //private static NodeDao dao = (NodeDao) NodeDaoImpl.getInstance();
index 2f7505a..28915f3 100644 (file)
@@ -83,9 +83,8 @@ public class NoteUpdatorService extends Service {
                                                }
                                        }
                                }
-
-                               setNextTime(NoteUpdatorService.this);
                        } finally {
+                               setNextTime(NoteUpdatorService.this);
                                NoteUpdatorService.this.stopSelf();
                        }
                }
index e08ae64..1295d89 100644 (file)
@@ -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) {
index 3d7c0cc..807e54b 100644 (file)
@@ -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<NoteList> getNoteList() {
                NoteFilter filter = getDefaultFilter();
                return getNoteList(filter);
@@ -117,7 +117,7 @@ public class EvernoteUtil {
                filter.setNotebookGuid(notebookGuid);
                return getNoteList(filter);
        }
-       
+
        public List<NoteList> getNoteListByTag(String tagGuid) {
                NoteFilter filter = getDefaultFilter();
                List<String> tagGuids = new ArrayList<String>();
@@ -125,7 +125,7 @@ public class EvernoteUtil {
                filter.setTagGuids(tagGuids);
                return getNoteList(filter);
        }
-       
+
        public List<NoteList> 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<com.yuji.ec.db.Note> getNoteContentList(List<NoteList> noteListList) {
-//             List<com.yuji.ec.db.Note> list = new ArrayList<com.yuji.ec.db.Note>();
-//             for (NoteList noteList : noteListList){
-//                     List<com.yuji.ec.db.Note> l = getNoteContentList(noteList);
-//                     if (l == null){
-//                             return null;
-//                     }
-//                     list.addAll(l);
-//             }
-//             return list;
-//     }
-//     
-//     public List<com.yuji.ec.db.Note> getNoteContentList(NoteList noteList) {
-//             errorCode = Error.OTHER;
-//
-//             List<com.yuji.ec.db.Note> list = new ArrayList<com.yuji.ec.db.Note>();
-//             HtmlParser parser = new HtmlParser();
-//
-//             try {
-//                     List<Note> 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<INoteItem> toNoteItemFromNoteBook(List<Notebook> noteList) {
-//             List<INoteItem> list = new ArrayList<INoteItem>();
-//             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<INoteItem> toNoteItemFromTag(List<Tag> tagList) {
-//             List<INoteItem> list = new ArrayList<INoteItem>();
-//             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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"  
+                               + "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml.dtd\">"  
+                               + "<en-note>Hello Evernote.</en-note>";  
+               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<com.yuji.ec.db.Note> getNoteContentList(List<NoteList>
+       // noteListList) {
+       // List<com.yuji.ec.db.Note> list = new ArrayList<com.yuji.ec.db.Note>();
+       // for (NoteList noteList : noteListList){
+       // List<com.yuji.ec.db.Note> l = getNoteContentList(noteList);
+       // if (l == null){
+       // return null;
+       // }
+       // list.addAll(l);
+       // }
+       // return list;
+       // }
+       //
+       // public List<com.yuji.ec.db.Note> getNoteContentList(NoteList noteList) {
+       // errorCode = Error.OTHER;
+       //
+       // List<com.yuji.ec.db.Note> list = new ArrayList<com.yuji.ec.db.Note>();
+       // HtmlParser parser = new HtmlParser();
+       //
+       // try {
+       // List<Note> 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<INoteItem> toNoteItemFromNoteBook(List<Notebook> noteList) {
+       // List<INoteItem> list = new ArrayList<INoteItem>();
+       // 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<INoteItem> toNoteItemFromTag(List<Tag> tagList) {
+       // List<INoteItem> list = new ArrayList<INoteItem>();
+       // 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
index b43da0f..cd0fbc5 100644 (file)
@@ -333,4 +333,15 @@ public class FolderUtil {
 
                return 0;
        }
+       
+       public void createTestNote(){
+               int pos = 1;
+               List<Node> list = nodeDao.searchBook();
+               Node node = list.get(pos);
+               String guid = node.getGuid();
+               
+               EvernoteUtil util = EvernoteUtil.getInstance();
+               util.createNotes(guid, "テスト", 100);
+
+       }
 }