OSDN Git Service

T28107
authorYuji Konishi <yuji.k64613@gmail.com>
Sat, 21 Apr 2012 07:49:58 +0000 (16:49 +0900)
committerYuji Konishi <yuji.k64613@gmail.com>
Sat, 21 Apr 2012 07:49:58 +0000 (16:49 +0900)
app/1.0.0/EverClip.apk [new file with mode: 0644]
pic/main.png [new file with mode: 0644]
pic/note_type.png [new file with mode: 0644]
pic/note_updator.png [new file with mode: 0644]
pic/setting.png [new file with mode: 0644]
pic/user.png [new file with mode: 0644]
workspace/EverClip/src/com/yuji/ec/NoteUpdatorActivity.java
workspace/EverClip/src/com/yuji/ec/SettingActivity.java
workspace/EverClip/src/com/yuji/ec/common/Constant.java
workspace/EverClip/src/com/yuji/ec/utility/EvernoteUtil.java
workspace/EverClip/src/com/yuji/ec/utility/NoteUpdator.java

diff --git a/app/1.0.0/EverClip.apk b/app/1.0.0/EverClip.apk
new file mode 100644 (file)
index 0000000..6e72da6
Binary files /dev/null and b/app/1.0.0/EverClip.apk differ
diff --git a/pic/main.png b/pic/main.png
new file mode 100644 (file)
index 0000000..12e5394
Binary files /dev/null and b/pic/main.png differ
diff --git a/pic/note_type.png b/pic/note_type.png
new file mode 100644 (file)
index 0000000..216e020
Binary files /dev/null and b/pic/note_type.png differ
diff --git a/pic/note_updator.png b/pic/note_updator.png
new file mode 100644 (file)
index 0000000..8cd13c7
Binary files /dev/null and b/pic/note_updator.png differ
diff --git a/pic/setting.png b/pic/setting.png
new file mode 100644 (file)
index 0000000..982ed64
Binary files /dev/null and b/pic/setting.png differ
diff --git a/pic/user.png b/pic/user.png
new file mode 100644 (file)
index 0000000..d18aef2
Binary files /dev/null and b/pic/user.png differ
index 2edf66b..6d1bb1e 100644 (file)
@@ -186,10 +186,6 @@ public class NoteUpdatorActivity extends BaseActivity {
        }
 
        private void setStatus() {
-               //int srcNoteItemType = pref.getInt(Constant.PREF_NOTE_ITEM_TYPE,
-               //              Constant.NOTE_ITEM_TYPE_ALL);
-               //String srcGuid = pref.get(Constant.PREF_NOTE_ITEM_GUID);
-
                int noteItemType = noteTypeSpinner.getSelectedItemPosition();
                int guidType = pref.getInt(Constant.PREF_NOTE_ITEM_GUID_TYPE_TMP, -1);
 
index 5d9723b..3c2c51c 100644 (file)
@@ -45,11 +45,6 @@ public class SettingActivity extends BaseActivity {
        private LinearLayout messageLayout = null;
        private TextView messageView = null;
        private Button userButton = null;
-       // private LinearLayout noteTypeLayout = null;
-       // private Spinner noteTypeSpinner = null;
-       // private TextView noteTypeView = null;
-       // private Button noteTypeButton = null;
-       // private Button updateButton = null;
        private Button noteButton = null;
        private Spinner sortSpinner = null;
        private RadioGroup sortRadioGroup = null;
@@ -61,7 +56,6 @@ public class SettingActivity extends BaseActivity {
        private Button timeButton = null;
        private Button closeButton = null;
 
-       //private String guid = null;
        private long updateTime = -1;
 
        private class NoteUpdatorReceiver extends BroadcastReceiver {
@@ -71,12 +65,6 @@ public class SettingActivity extends BaseActivity {
                        Toast toast = Toast.makeText(getApplicationContext(), "Time over!",
                                        Toast.LENGTH_LONG);
                        toast.show();
-                       // MediaPlayer mp = MediaPlayer.create(Main.this, R.raw.alarm);
-                       // try {
-                       // mp.start();
-                       // } catch (Exception e) {
-                       // // \97á\8aO\82Í\94­\90\82µ\82È\82¢
-                       // }
                }
        }
 
@@ -102,13 +90,6 @@ public class SettingActivity extends BaseActivity {
                messageLayout = (LinearLayout) this.findViewById(R.id.settingLayout);
                messageView = (TextView) this.findViewById(R.id.settingMessage);
                userButton = (Button) this.findViewById(R.id.settingUserButton);
-               // noteTypeSpinner = (Spinner)
-               // this.findViewById(R.id.settingNoteSpinner);
-               // noteTypeLayout = (LinearLayout) this
-               // .findViewById(R.id.settingNoteLayout);
-               // noteTypeView = (TextView) this.findViewById(R.id.settingNoteText);
-               // noteTypeButton = (Button) this.findViewById(R.id.settingNoteButton);
-               // updateButton = (Button) this.findViewById(R.id.settingUpdateButton);
                noteButton = (Button) this.findViewById(R.id.settingNoteButton);
                sortSpinner = (Spinner) this.findViewById(R.id.settingSortSpinner);
                sortRadioGroup = (RadioGroup) this
@@ -127,27 +108,6 @@ public class SettingActivity extends BaseActivity {
                                userButtonOnClick();
                        }
                });
-               // noteTypeSpinner.setOnItemSelectedListener(new
-               // OnItemSelectedListener() {
-               // public void onItemSelected(AdapterView<?> parent, View view,
-               // int position, long id) {
-               // noteTypeSpinnerItemSelected(parent, view, position, id);
-               // }
-               //
-               // public void onNothingSelected(AdapterView<?> view) {
-               // ;
-               // }
-               // });
-               // noteTypeButton.setOnClickListener(new OnClickListener() {
-               // public void onClick(View view) {
-               // noteTypeButtonOnClick();
-               // }
-               // });
-               // updateButton.setOnClickListener(new OnClickListener() {
-               // public void onClick(View view) {
-               // updateButtonOnClick();
-               // }
-               // });
 
                noteButton.setOnClickListener(new OnClickListener() {
                        public void onClick(View view) {
@@ -194,13 +154,6 @@ public class SettingActivity extends BaseActivity {
                        }
                });
 
-               // ArrayAdapter<CharSequence> noteTypeAdapter = ArrayAdapter
-               // .createFromResource(this, R.array.note_item_array,
-               // android.R.layout.simple_spinner_item);
-               // noteTypeAdapter
-               // .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-               // noteTypeSpinner.setAdapter(noteTypeAdapter);
-
                ArrayAdapter<CharSequence> noteOrderAdapter = ArrayAdapter
                                .createFromResource(this, R.array.note_order_array,
                                                android.R.layout.simple_spinner_item);
@@ -215,14 +168,6 @@ public class SettingActivity extends BaseActivity {
        public void onStart() {
                super.onStart();
 
-               // int noteItemType = pref.getInt(Constant.PREF_NOTE_ITEM_TYPE,
-               // Constant.NOTE_ITEM_TYPE_ALL);
-               // noteTypeSpinner.setSelection(noteItemType);
-               //
-               // guid = pref.get(Constant.PREF_NOTE_ITEM_GUID);
-               // String title = pref.get(Constant.PREF_NOTE_ITEM_TEXT);
-               // noteTypeView.setText(title);
-
                int noteOrder = pref.getInt(Constant.PREF_NOTE_ORDER,
                                Constant.NOTE_ORDER_CREATE);
                sortSpinner.setSelection(noteOrder);
@@ -249,9 +194,6 @@ public class SettingActivity extends BaseActivity {
 
        @Override
        public void onPause() {
-               // int noteItemType = noteTypeSpinner.getSelectedItemPosition();
-               // pref.put(Constant.PREF_NOTE_ITEM_TYPE, noteItemType);
-
                int noteOrder = sortSpinner.getSelectedItemPosition();
                pref.put(Constant.PREF_NOTE_ORDER, noteOrder);
 
@@ -325,17 +267,6 @@ public class SettingActivity extends BaseActivity {
 
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-               // if (resultCode == RESULT_OK) {
-               // Bundle ex = data.getExtras();
-               // String guid = ex.getString(Constant.EXTRA_GUID);
-               // String title = ex.getString(Constant.EXTRA_TITLE);
-               //
-               // pref.put(Constant.PREF_NOTE_ITEM_GUID, guid);
-               // pref.put(Constant.PREF_NOTE_ITEM_TEXT, title);
-               // pref.update();
-               //
-               // noteTypeView.setText(title);
-               // }
 
                setStatus();
        }
@@ -361,42 +292,6 @@ public class SettingActivity extends BaseActivity {
 
        }
 
-       // private void noteButtonOnClick() {
-       // NoteListActivity.init();
-       // SelectNoteListActivity.init(this);
-       //
-       // Intent intent = new Intent(this,
-       // (Class<?>) SelectNoteListActivity.class);
-       // startActivityForResult(intent, 0);
-       // }
-       //
-       // private void headerButtonOnClick() {
-       // Intent intent = new Intent(this, (Class<?>) HeaderActivity.class);
-       // startActivityForResult(intent, 0);
-       // }
-
-       // public void done(EvernoteUtil.Error errorCode) {
-       // // if (errorCode != null && !errorCode.equals(Error.NONE)) {
-       // // EvernoteUtil util = EvernoteUtil.getInstance();
-       // // Toast.makeText(this, util.getErrorMessage(this, errorCode),
-       // // Toast.LENGTH_LONG).show();
-       // // }
-       // //
-       // // if (nList == null) {
-       // // // \83L\83\83\83\93\83Z\83\8b\83{\83^\83\93\89\9f\89º\8e\9e
-       // // closeButtonOnClick();
-       // // return;
-       // // }
-       // //
-       // // List<NoteListItem> list = getNoteList(nList);
-       // // if (list == null) {
-       // // closeButtonOnClick();
-       // // return;
-       // // }
-       // // setNoteList(list);
-       // // noteList = list;
-       // }
-
        protected void timeCheckBoxOnClick(CompoundButton buttonView,
                        boolean isChecked) {
                if (isChecked) {
index 4d50f8f..61727de 100644 (file)
@@ -1,7 +1,6 @@
 package com.yuji.ec.common;
 
 public class Constant {
-
        public static final String PREF_USER = "USER";
        public static final String PREF_PASSWORD = "PASSWORD";
        public static final String PREF_NOTE_ITEM_TYPE = "NOTE_ITEM_TYPE";
@@ -14,7 +13,6 @@ public class Constant {
        public static final String PREF_NOTE_ORDER_BY = "NOTE_ORDER_BY";
        public static final String PREF_AUTO_UPDATE = "AUTO_UPDATE";
        public static final String PREF_UPDATE_TIME = "UPDATE_TIME";
-       //public static final String PREF_UPDATE_TIME_TMP = "UPDATE_TIME_TMP";
        
        public static final String EXTRA_GUID = "GUID";
        public static final String EXTRA_TITLE = "TITLE";
index 10ff414..b42cc48 100644 (file)
@@ -29,6 +29,7 @@ import com.yuji.ec.R;
 import com.yuji.ec.db.INoteItem;
 
 public class EvernoteUtil {
+       private static final int N = 50;
        private String username;
        private String password;
 
@@ -108,18 +109,18 @@ public class EvernoteUtil {
                return filter;
        }
        
-       public NoteList getNoteList() {
+       public List<NoteList> getNoteList() {
                NoteFilter filter = getDefaultFilter();
                return getNoteList(filter);
        }
 
-       public NoteList getNoteListByNotebook(String notebookGuid) {
+       public List<NoteList> getNoteListByNotebook(String notebookGuid) {
                NoteFilter filter = getDefaultFilter();
                filter.setNotebookGuid(notebookGuid);
                return getNoteList(filter);
        }
        
-       public NoteList getNoteListByTag(String tagGuid) {
+       public List<NoteList> getNoteListByTag(String tagGuid) {
                NoteFilter filter = getDefaultFilter();
                List<String> tagGuids = new ArrayList<String>();
                tagGuids.add(tagGuid);
@@ -127,33 +128,49 @@ public class EvernoteUtil {
                return getNoteList(filter);
        }
        
-       public NoteList getNoteList(NoteFilter filter) {
+       public List<NoteList> getNoteList(NoteFilter filter) {
                errorCode = Error.OTHER;
 
-               NoteList noteList = null;
+               List<NoteList> list = new ArrayList<NoteList>();
                try {
                        String token = getAuthenticationToken();
                        if (token == null) {
                                return null;
                        }
-                       // TODO #28107
-                       noteList = noteStore.findNotes(token, filter, 0, 1000);
+                       int index = 0;
+                       while (true){
+                               NoteList noteList = noteStore.findNotes(token, filter, index, N);
+                               int size = noteList.getNotesSize();
+                               
+                               if (size <= 0){
+                                       break;
+                               }
+                               list.add(noteList);
+                               if (size < N){
+                                       break;
+                               }
+                               index += size;
+                       }
                        
                        errorCode = Error.NONE;
                } catch (EDAMUserException e) {
                        Debug.d(this, null, e);
+                       list = null;
                } catch (EDAMSystemException e) {
                        Debug.d(this, null, e);
+                       list = null;
                } catch (EDAMNotFoundException e) {
                        Debug.d(this, null, e);
+                       list = null;
                } catch (TException e) {
                        Debug.d(this, null, e);
 
                        if (e.getCause() instanceof ConnectException) {
                                errorCode = Error.CONNECT;
                        }
+                       list = null;
                }
-               return noteList;
+               return list;
        }
 
        public List<Notebook> getNoteBookList() {
@@ -356,6 +373,18 @@ public class EvernoteUtil {
                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;
 
@@ -364,6 +393,8 @@ public class EvernoteUtil {
 
                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);
@@ -375,6 +406,8 @@ public class EvernoteUtil {
                                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;
index 855a3df..b63e804 100644 (file)
@@ -43,16 +43,16 @@ public class NoteUpdator {
                                return;\r
                        }\r
 \r
-                       NoteList noteList;\r
+                       List<NoteList> noteListList;\r
                        switch (noteItemType) {\r
                        case Constant.NOTE_ITEM_TYPE_NOTE_BOOK:\r
-                               noteList = util.getNoteListByNotebook(guid);\r
+                               noteListList = util.getNoteListByNotebook(guid);\r
                                break;\r
                        case Constant.NOTE_ITEM_TYPE_TAG:\r
-                               noteList = util.getNoteListByTag(guid);\r
+                               noteListList = util.getNoteListByTag(guid);\r
                                break;\r
                        default:\r
-                               noteList = util.getNoteList();\r
+                               noteListList = util.getNoteList();\r
                                break;\r
                        }\r
 \r
@@ -60,7 +60,7 @@ public class NoteUpdator {
                                return;\r
                        }\r
 \r
-                       List<Note> list = util.getNoteContentList(noteList);\r
+                       List<Note> list = util.getNoteContentList(noteListList);\r
                        if (list == null) {\r
                                // NOT_FOUND\r
                                return;\r