OSDN Git Service

T29561
authorYuji Konishi <yuji.k64613@gmail.com>
Sat, 15 Sep 2012 04:11:04 +0000 (13:11 +0900)
committerYuji Konishi <yuji.k64613@gmail.com>
Sat, 15 Sep 2012 04:11:04 +0000 (13:11 +0900)
T29499

28 files changed:
bin/restart_adb.sh [new file with mode: 0755]
source/workspace/EverFolder/gen/com/yuji/ef/R.java
source/workspace/EverFolder/res/values-ja/strings.xml
source/workspace/EverFolder/res/values/strings.xml
source/workspace/EverFolder/src/com/yuji/ef/BookListActivity.java
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/Initialize.java
source/workspace/EverFolder/src/com/yuji/ef/LabelIconView.java
source/workspace/EverFolder/src/com/yuji/ef/SettingActivity.java
source/workspace/EverFolder/src/com/yuji/ef/common/Constant.java
source/workspace/EverFolder/src/com/yuji/ef/dao/BookDao.java
source/workspace/EverFolder/src/com/yuji/ef/dao/DirNode.java
source/workspace/EverFolder/src/com/yuji/ef/dao/LockDao.java
source/workspace/EverFolder/src/com/yuji/ef/dao/Node.java
source/workspace/EverFolder/src/com/yuji/ef/dao/NodeCacheDao.java
source/workspace/EverFolder/src/com/yuji/ef/dao/NodeDaoImpl.java
source/workspace/EverFolder/src/com/yuji/ef/dao/NodeFactory.java
source/workspace/EverFolder/src/com/yuji/ef/exception/EfError.java
source/workspace/EverFolder/src/com/yuji/ef/exception/EfException.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/BaseActivity.java
source/workspace/EverFolder/src/com/yuji/ef/utility/Debug.java
source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteIntentUtil.java
source/workspace/EverFolder/src/com/yuji/ef/utility/EvernoteUtil.java
source/workspace/EverFolder/src/com/yuji/ef/utility/FolderUtil.java
source/workspace/EverFolder/src/com/yuji/ef/utility/LockHandler.java

diff --git a/bin/restart_adb.sh b/bin/restart_adb.sh
new file mode 100755 (executable)
index 0000000..2a5122d
--- /dev/null
@@ -0,0 +1,3 @@
+cd /home/yuji/prog/android-sdk-linux/platform-tools/
+./adb kill-server
+./adb start-server
index 386c3f4..507b743 100644 (file)
@@ -61,6 +61,7 @@ public final class R {
     }
     public static final class string {
         public static final int ErrorLogin=0x7f050024;
+        public static final int ErrorSystem=0x7f050025;
         public static final int ErrorUpdate=0x7f050023;
         public static final int MenuAdd=0x7f05001f;
         public static final int MenuCut=0x7f05001d;
@@ -71,6 +72,8 @@ public final class R {
         public static final int app_name=0x7f050000;
         public static final int cancelButton=0x7f050003;
         public static final int closeButton=0x7f050004;
+        public static final int dialogErrorTitle=0x7f050026;
+        public static final int dialogSystemError=0x7f050027;
         public static final int mainAddMsg=0x7f050008;
         public static final int mainConfirmMsg=0x7f050006;
         public static final int mainConfirmTitle=0x7f050005;
@@ -96,6 +99,7 @@ public final class R {
         public static final int settingUpdateMsg=0x7f05000f;
         public static final int settingUpdateTimeTitle=0x7f05001c;
         public static final int settingUpdateTitle=0x7f05001a;
+        public static final int toastSystem=0x7f050028;
         public static final int yesButton=0x7f050001;
     }
 }
index 0c0a322..30f16a3 100644 (file)
     <string name="MenuRename">名称変更</string>
     <string name="MenuSetting">設定</string>
             
-    <string name="ErrorUpdate">データの更新に失敗しました</string>
-    <string name="ErrorLogin">ログインに失敗しました</string>
+    <string name="dialogErrorTitle">システムエラー</string>
+    <string name="dialogSystemError">予期せぬエラーが発生しました</string>
     
+    <string name="toastSystem">予期せぬエラーが発生しました</string>
     
+    <string name="ErrorUpdate">データの更新に失敗しました</string>
+    <string name="ErrorLogin">ログインに失敗しました</string>
+    <string name="ErrorSystem">予期せぬエラーが発生しました</string>
 </resources>
\ No newline at end of file
index 2ba43bb..ca7df41 100644 (file)
     <string name="MenuDelete">Delete</string>
     <string name="MenuRename">Rename</string>
     <string name="MenuSetting">Setting</string>
-            
-    <string name="ErrorUpdate">Failed to update the data</string>
-    <string name="ErrorLogin">Failed to login</string>
+
+    <string name="dialogErrorTitle">System error</string>
+    <string name="dialogSystemError">An unexpected error has occurred</string>
     
+    <string name="toastSystem">An unexpected error has occurred</string>
     
+    <string name="ErrorUpdate">Failed to update the data</string>
+    <string name="ErrorLogin">Failed to login</string>
+    <string name="ErrorSystem">An unexpected error has occurred</string>
 </resources>
\ No newline at end of file
index d953aea..e7b85b3 100644 (file)
@@ -2,7 +2,6 @@ package com.yuji.ef;
 \r
 import java.util.List;\r
 \r
-\r
 import android.os.Bundle;\r
 import android.view.View;\r
 import android.view.View.OnClickListener;\r
@@ -15,7 +14,7 @@ import android.widget.ListView;
 import com.yuji.ef.dao.Node;\r
 import com.yuji.ef.dao.NodeCacheDao;\r
 import com.yuji.ef.dao.NodeDao;\r
-import com.yuji.ef.pref.EditPrefUtil;\r
+import com.yuji.ef.exception.EfException;\r
 import com.yuji.ef.utility.BaseActivity;\r
 import com.yuji.ef.utility.Debug;\r
 \r
@@ -56,8 +55,7 @@ public class BookListActivity extends BaseActivity {
                                                dao.updateSelected(item, selected);\r
                                        }\r
                                        catch (Exception e){\r
-                                               // TODO\r
-                                               e.printStackTrace();\r
+                                               EfException.msg(R.string.ErrorSystem);\r
                                        }\r
                                }\r
                        });\r
index b4b5799..9631cb5 100644 (file)
@@ -39,6 +39,7 @@ import com.yuji.ef.dao.NodeComparator;
 import com.yuji.ef.dao.NodeDao;
 import com.yuji.ef.dao.NodeDaoImpl;
 import com.yuji.ef.dao.RootNode;
+import com.yuji.ef.exception.EfError;
 import com.yuji.ef.exception.EfException;
 import com.yuji.ef.pref.EditPrefUtil;
 import com.yuji.ef.utility.BaseActivity;
@@ -68,8 +69,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
        private LinearLayout buttonLayout;
        private Button leftButton;
        private Button rightButton;
-       // private Button addButton;
-       // private Button deleteButton;
 
        private ScreenStatus status;
        private NodeComparator nodeComparator = new NodeComparator();
@@ -128,8 +127,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                        buttonLayout = (LinearLayout) findViewById(R.id.mainButtonLayout);
                        leftButton = (Button) findViewById(R.id.leftButton);
                        rightButton = (Button) findViewById(R.id.rightButton);
-                       // addButton = (Button) findViewById(R.id.addButton);
-                       // deleteButton = (Button) findViewById(R.id.deleteButton);
 
                        msgLayout = (LinearLayout) findViewById(R.id.mainMsgLayout);
                        confirmMsg = (TextView) findViewById(R.id.mainConfirmMsg);
@@ -150,18 +147,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                                        rightButtonOnClick();
                                }
                        });
-                       // addButton.setOnClickListener(new OnClickListener() {
-                       // @Override
-                       // public void onClick(View v) {
-                       // addButtonOnClick();
-                       // }
-                       // });
-                       // deleteButton.setOnClickListener(new OnClickListener() {
-                       // @Override
-                       // public void onClick(View v) {
-                       // deleteButtonOnClick();
-                       // }
-                       // });
 
                        msgEditText.addTextChangedListener(new TextWatcher() {
                                public void afterTextChanged(Editable s) {
@@ -212,8 +197,7 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                        leftButton.setTextSize(fSize);
                        rightButton.setTextSize(fSize);
                } catch (Exception e) {
-                       // TODO
-                       e.printStackTrace();
+                       EfException.msg(R.string.ErrorSystem);
                }
        }
 
@@ -222,7 +206,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                boolean ret = super.onCreateOptionsMenu(menu);
                int index = 0;
 
-               // TODO
                menu.add(Menu.NONE, Menu.FIRST + index++, Menu.NONE,
                                getString(R.string.MenuCut));
                menu.add(Menu.NONE, Menu.FIRST + index++, Menu.NONE,
@@ -463,7 +446,8 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
                top = dao.searchRoot();
                if (top == null) {
-                       // TODO
+                       EfException.msg(R.string.ErrorSystem);
+                       return;
                }
                updateList(top);
        }
@@ -523,7 +507,7 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                for (Long id : idList) {
                        Node n = dao.searchById(id);
                        if (n == null) {
-                               // TODO
+                               // ERROR
                                continue;
                        }
                        if (n instanceof DirNode) {
@@ -558,11 +542,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                params.y = y;
                v.setLayoutParams(params);
 
-               // LabelIconView siv = v.getStatusImageView();
-               // if (siv != null) {
-               // layout.addView(siv, false);
-               // }
-
                layout.addView(v);
                v.layout(x, y, x + v.getWidth(), y + v.getHeight());
        }
@@ -597,8 +576,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                }
 
                if (isInCycle) {
-//                     LockDao lockDao = (LockDao) LockDao.getInstance();
-//                     lock = lockDao.lock(this, Constant.LOCK_UPDATE_NOTE);
                        if (isInit) {
                                status = ScreenStatus.Normal;
 
@@ -611,24 +588,20 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                                setStatus();
                                isInit = false;
                        } else {
-                               if (lock){
+                               if (lock) {
                                        updateList();
                                }
                                setStatus();
                        }
                } else {
-                       // TODO
-                       // lock解除
+                       LockDao lockDao = (LockDao) LockDao.getInstance();
+                       lockDao.unlock(EverFolderActivity.this, Constant.LOCK_UPDATE_NOTE);
+                       lock = false;
                }
        }
 
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-               // TODO sendLockResult()、「lock解除」のため、とりあえずコメント
-               // NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
-               // if (dao.isEmpty()) {
-               // finish();
-               // }
                isResult = true;
                isInit = true;
        }
@@ -644,7 +617,7 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                isInCycle = true;
 
                LockHandler handler = new LockHandler();
-               handler.lock(this, Constant.LOCK_UPDATE_NOTE);
+               handler.lock(this, Constant.LOCK_UPDATE_NOTE, true);
                lock = false;
 
                if (isInit) {
@@ -654,38 +627,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                        // #29421
                        updateList();
                }
-
-               // TODO
-               // NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
-               // if (dao.isEmpty()) {
-               // if (isInit) {
-               // Intent intent = new Intent(this,
-               // (Class<?>) SettingActivity.class);
-               // startActivityForResult(intent, 0);
-               //
-               // isInit = false;
-               // } else {
-               // finish();
-               // isInit = true;
-               // }
-               // }
-               //
-               // LockDao lockDao = (LockDao) LockDao.getInstance();
-               // lock = lockDao.lock(this, Constant.LOCK_UPDATE_NOTE);
-               //
-               // if (isInit) {
-               // status = ScreenStatus.Normal;
-               //
-               // if (lock) {
-               // updateList();
-               // } else {
-               // layout.removeAllViews();
-               // }
-               // setStatus();
-               // isInit = false;
-               // } else {
-               // setStatus();
-               // }
        }
 
        @Override
@@ -726,25 +667,6 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                }
        }
 
-       // private void addButtonOnClick() {
-       // setStatus(ScreenStatus.AddNode);
-       // }
-       //
-       // private void deleteButtonOnClick() {
-       // FolderUtil util = FolderUtil.getInstance();
-       // LabelIconView target = layout.getSelectedTarget();
-       // long id = target.getNodeId();
-       // NodeDao dao = (NodeDao) NodeDao.getInstance();
-       // Node node = dao.searchById(id);
-       // if (node != null) {
-       // util.deleteNode(node);
-       // // TODO 三角マークも消さないといけないのでは
-       // layout.removeView(target);
-       // updateList();
-       // setStatus();
-       // }
-       // }
-
        private void msgOkButtonOnClick(View v) {
                FolderUtil util = FolderUtil.getInstance();
                LabelIconView target = layout.getSelectedTarget();
@@ -803,10 +725,10 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                        NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
 
                        if (srcId < 0) {
-                               // TODO
+                               throw new EfException(EfError.NOT_FOUND);
                        }
                        if (dstId < 0) {
-                               // TODO
+                               throw new EfException(EfError.NOT_FOUND);
                        }
 
                        Node src = dao.searchById(srcId);
@@ -828,7 +750,7 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
 
                        Node sp = dao.searchById(src.getParent());
                        if (sp == null) {
-                               // TODO
+                               throw new EfException(EfError.NOT_FOUND);
                        }
                        Node dp = null;
                        if (src.getParent() == dst.getParent()) {
@@ -837,22 +759,18 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                                dp = dao.searchById(dst.getParent());
                        }
                        if (dp == null) {
-                               // TODO
+                               throw new EfException(EfError.NOT_FOUND);
                        }
 
-                       // TODO DBへのアクセス
-                       // sp.remove(src.getId());
                        SQLiteDatabase db = DatabaseHelper.getInstance()
                                        .getSQLiteDatabase();
                        db.beginTransaction();
                        try {
                                dao.removeChildrenIdNT(sp, src.getId());
                                if (dst instanceof DirNode) {
-                                       // dst.add(src.getId());
                                        dao.updateParentNT(src, dst.getId());
                                        dao.addChildrenIdNT(dst, src.getId());
                                } else if (dst instanceof FileNode) {
-                                       // dp.add(src.getId());
                                        dao.updateParentNT(src, dp.getId());
                                        dao.addChildrenIdNT(dp, src.getId());
                                }
@@ -861,6 +779,8 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                        } finally {
                                db.endTransaction();
                        }
+               } catch (EfException e) {
+                       EfException.msg(R.string.ErrorSystem);
                } finally {
                        updateList();
                }
@@ -875,7 +795,7 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                        }
                        Node node = dao.searchById(dstId);
                        if (node == null) {
-                               // TODO エラー
+                               // ERROR
                                return false;
                        }
                        if (!(node instanceof DirNode)) {
@@ -887,19 +807,22 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
        }
 
        public void execute(long id) {
-               NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
+               try {
+                       NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
 
-               Node node = dao.searchById(id);
-               if (node == null) {
-                       // TODO
-               }
-               node.toggleStatus();
-               Status status = node.getStatus();
+                       Node node = dao.searchById(id);
+                       if (node == null) {
+                               throw new EfException(EfError.NOT_FOUND);
+                       }
+                       node.toggleStatus();
+                       Status status = node.getStatus();
 
-               dao.updateStatus(node, status);
+                       dao.updateStatus(node, status);
 
-               // removeAllNodeView();
-               updateList();
+                       updateList();
+               } catch (EfException e) {
+                       EfException.msg(R.string.ErrorSystem);
+               }
        }
 
        public void executeView(long id) {
@@ -954,41 +877,18 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
 
                        if (status == ScreenStatus.Normal) {
                                msgLayout.setVisibility(View.GONE);
-                               // mainMsgEditText.setText("");
 
                                boolean leftButtonFlag = true;
                                boolean rightButtonFlag = true;
-                               // boolean addButtonFlag = true;
-                               // boolean deleteButtonFlag = true;
 
                                if (indent <= 0) {
                                        leftButtonFlag = false;
                                }
 
-                               // LabelIconView target = layout.getSelectedTarget();
-                               // NodeDao dao = (NodeDao) NodeDao.getInstance();
-                               // long id = -1;
-                               // Node node = null;
-                               // if (target != null) {
-                               // id = target.getNodeId();
-                               // node = dao.searchById(id);
-                               // }
-                               // if (target == null || node == null || !(node instanceof
-                               // DirNode))
-                               // {
-                               // addButtonFlag = false;
-                               // }
-                               // if (target == null || (node != null && node instanceof
-                               // RootNode))
-                               // {
-                               // deleteButtonFlag = false;
-                               // }
                                layout.setElabledTouchEvent(true);
 
                                leftButton.setEnabled(leftButtonFlag);
                                rightButton.setEnabled(rightButtonFlag);
-                               // addButton.setEnabled(addButtonFlag);
-                               // deleteButton.setEnabled(deleteButtonFlag);
                        } else if (status == ScreenStatus.AddNode) {
                                msgLayout.setVisibility(View.VISIBLE);
                                msgEditText.setVisibility(View.VISIBLE);
@@ -1022,8 +922,7 @@ public class EverFolderActivity extends BaseActivity implements LockListener {
                                rightButton.setEnabled(false);
                        }
                } catch (Throwable e) {
-                       // TODO
-                       e.printStackTrace();
+                       EfException.msg(R.string.ErrorSystem);
                }
        }
 
index 0241035..41d7518 100644 (file)
@@ -204,7 +204,6 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                this.cutTarget = cutTarget;
                if (cutTarget != null){
                        if (cutTarget instanceof StatusIconView){
-                               // TODO
                                return;
                        }
                }
@@ -217,7 +216,6 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
        public void setSelectedTarget(LabelIconView selectedTarget){
                if (selectedTarget != null){
                        if (selectedTarget instanceof StatusIconView){
-                               // TODO
                                return;
                        }
                }
@@ -227,7 +225,6 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
        public void setTarget(LabelIconView target){
                if (target != null){
                        if (target instanceof StatusIconView){
-                               // TODO
                                return;
                        }
                }
@@ -384,7 +381,6 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
 
                                        offsetX = x;
                                        offsetY = y;
-                                       // TODO
                                        currentX = obj.getLeft();
                                        currentY = obj.getTop();
 
@@ -427,7 +423,6 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                                        long dst = destTarget.getNodeId();
                                        activity.execute(src, dst);
 
-                                       // TODO
                                        setTarget(null);
                                        destTarget = null;
 
index 1c8d757..7f0879e 100644 (file)
@@ -4,6 +4,8 @@ import android.content.Context;
 
 import com.yuji.ef.common.Constant;
 import com.yuji.ef.dao.DatabaseHelper;
+import com.yuji.ef.exception.EfError;
+import com.yuji.ef.exception.EfException;
 import com.yuji.ef.pref.EditPrefUtil;
 import com.yuji.ef.service.NoteUpdatorService;
 import com.yuji.ef.utility.EvernoteUtil;
@@ -12,7 +14,7 @@ public class Initialize {
        private static Context context;
        private static boolean isInit = true;
        
-       public static void initialize(Context applicatonContext) {
+       public static void initialize(Context applicatonContext) throws EfException {
                if (!isInit) {
                        return;
                }
@@ -30,11 +32,12 @@ public class Initialize {
                        DatabaseHelper.init(context);
                        
                        NoteUpdatorService.init(context);
+                       
+                       isInit = false;
                } catch (Exception e) {
-                       // TODO
-                       e.printStackTrace();
+                       EfException.msg(R.string.ErrorSystem);
+                       throw new EfException(EfError.INIT);
                }
-               isInit = false;
        }
 
        public static Context getContext() {
index a647e77..f2f81a2 100644 (file)
@@ -5,7 +5,6 @@ import android.graphics.Bitmap;
 import android.graphics.PorterDuff.Mode;
 import android.graphics.Rect;
 import android.view.Gravity;
-import android.view.MotionEvent;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -43,7 +42,6 @@ public class LabelIconView extends LinearLayout {
                        this.removeView(textView);
                }
 
-               // TODO
                if (bmp1 != null) {
                        statusImageView = new StatusIconView(context, this);
                        statusImageView.init(0, 0, null, bmp1, null);
@@ -115,12 +113,4 @@ public class LabelIconView extends LinearLayout {
        public void clearColorFilter() {
                imageView.clearColorFilter();
        }
-
-       @Override
-       public boolean onTouchEvent(MotionEvent event) {
-               // TODO
-               return super.onTouchEvent(event);
-       }
-       
-       
 }
index 2d30f31..25da493 100644 (file)
@@ -19,9 +19,7 @@ import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.Spinner;
 import android.widget.TextView;
-import android.widget.Toast;
 
-import com.yuji.ef.common.CommonUtil;
 import com.yuji.ef.common.Constant;
 import com.yuji.ef.dao.LockDao;
 import com.yuji.ef.dao.Node;
@@ -57,9 +55,7 @@ public class SettingActivity extends BaseActivity {
 
                @Override
                public void onReceive(Context context, Intent intent) {
-//                     Toast toast = Toast.makeText(getApplicationContext(), "Time over!",
-//                                     Toast.LENGTH_LONG);
-//                     toast.show();
+                       ;
                }
        }
 
@@ -260,7 +256,6 @@ public class SettingActivity extends BaseActivity {
                NoteUpdateTask task = new NoteUpdateTask(this, true, true, isAll);
 
                AsyncTaskCommand command = new AsyncTaskCommand(this, task);
-               // TODO
                // command.setTitle(getString(R.string.updatorNoteDialogTitle));
                // command.setButtonTitle(getString(R.string.cancelButton));
                command.setCancelable(false);
@@ -271,10 +266,6 @@ public class SettingActivity extends BaseActivity {
        }
 
        public void done(int errorCode) {
-//             LockDao lockDao = (LockDao) LockDao.getInstance();
-//             lockDao.unlock(this, Constant.LOCK_UPDATE_NOTE);
-//             lock = false;
-
                lock = false;
                setStatus();
        }
index cd09c42..f7d0d99 100644 (file)
@@ -1,43 +1,6 @@
 package com.yuji.ef.common;
 
-import android.content.Intent;
-
 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";
-       public static final String PREF_NOTE_ITEM_GUID = "NOTE_ITEM_GUID";
-       public static final String PREF_NOTE_ITEM_TYPE_TMP = "NOTE_ITEM_TYPE_TMP";
-       public static final String PREF_NOTE_ITEM_GUID_TMP = "NOTE_ITEM_GUID_TMP";
-       public static final String PREF_NOTE_ITEM_GUID_TYPE_TMP = "NOTE_ITEM_GUID_TYPE_TMP";
-       public static final String PREF_NOTE_ITEM_TEXT = "NOTE_ITEM_TEXT";
-       public static final String PREF_NOTE_ORDER = "NOTE_ORDER";
-       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 EXTRA_GUID = "GUID";
-       public static final String EXTRA_TITLE = "TITLE";
-
-       public static final int NOTE_ITEM_TYPE_NONE = -1;
-       public static final int NOTE_ITEM_TYPE_ALL = 0;
-       public static final int NOTE_ITEM_TYPE_NOTE_BOOK = 1;
-       public static final int NOTE_ITEM_TYPE_TAG = 2;
-       
-       public static final int NOTE_ORDER_NONE = -1;
-       public static final int NOTE_ORDER_CREATE = 0;
-       public static final int NOTE_ORDER_UPDATE = 1;
-       public static final int NOTE_ORDER_TEXT = 2;
-
-       public static final int NOTE_ORDER_BY_ASC = 0;
-       public static final int NOTE_ORDER_BY_DES = 1;
-
-       public static final int OFF = 0;
-       public static final int ON = 1;
-       
-       public static final String ACTION_UPDATE = "com.yuji.ec.UPDATE";
-*/
        public static final int OFF = 0;
        public static final int ON = 1;
 
index 067c502..3242f8f 100644 (file)
@@ -8,9 +8,7 @@ import android.database.SQLException;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteStatement;
 
-import com.yuji.ef.common.CommonUtil;
 import com.yuji.ef.utility.Debug;
-import com.yuji.ef.utility.FolderUtil;
 
 public class BookDao implements IDao<Book> {
        private static IDao<Book> instance = null;
@@ -33,9 +31,6 @@ public class BookDao implements IDao<Book> {
                db.execSQL("CREATE TABLE BOOK (" + android.provider.BaseColumns._ID
                                + " INTEGER PRIMARY KEY AUTOINCREMENT," + "TYPE INTEGER,"
                                + "GUID TEXT," + "NID INTEGER," + "NAME TEXT" + ");");
-
-               // TODO
-               // CREATE INDEX インデックス名 ON テーブル名(カラム名1, カラム名2, ...);
        }
 
        public void init(SQLiteDatabase db) {
@@ -197,7 +192,7 @@ public class BookDao implements IDao<Book> {
        }
 
        public long deleteNT(long did) {
-               long id = -1; // TODO
+               long id = -1;
                int i = 1;
 
                SQLiteStatement stmt = deleteIdStmt;
index aaacc55..89c8e13 100644 (file)
@@ -15,8 +15,6 @@ public class DirNode extends Node {
        private Status status = Status.CLOSE;
        private Category category = Category.NONE;
 
-       // private String notebookGuid = null;
-
        public DirNode(String name, LabelIconView view) {
                super(name, view);
 
@@ -44,14 +42,6 @@ public class DirNode extends Node {
                this.category = category;
        }
 
-       // public String getNotebookGuid() {
-       // return notebookGuid;
-       // }
-       //
-       // public void setNotebookGuid(String notebookGuid) {
-       // this.notebookGuid = notebookGuid;
-       // }
-
        @Override
        public int getType() {
                return CommonUtil.isNull(getGuid()) ? TYPE_DIR : TYPE_BOOK;
index 93eb7f6..6df626e 100644 (file)
@@ -4,14 +4,14 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 
-import com.yuji.ef.utility.Debug;
-
 import android.database.Cursor;
 import android.database.SQLException;
 import android.database.sqlite.SQLiteConstraintException;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteStatement;
 
+import com.yuji.ef.utility.Debug;
+
 public class LockDao implements IDao<Lock> {
        private static final int DEFAULT_PERIOD = 60 * 60; // 1時間
        
@@ -150,7 +150,6 @@ public class LockDao implements IDao<Lock> {
                        id = stmt.executeInsert();
                } catch (SQLiteConstraintException e) {
                        // error code 19: constraint failed
-                       // TODO DEBUG
                        List<Lock> list = this.search();
                        for (Lock l : list) {
                                Debug.d(this, l.toString());
@@ -180,7 +179,7 @@ public class LockDao implements IDao<Lock> {
        }
 
        public long deleteNT(String key, String clazz) {
-               long id = -1; // TODO
+               long id = -1;
                int i = 1;
 
                SQLiteStatement stmt = deleteIdStmt;
@@ -191,7 +190,7 @@ public class LockDao implements IDao<Lock> {
        }
 
        public long deleteUpdatedNT(String key, long updated) {
-               long id = -1; // TODO
+               long id = -1;
                int i = 1;
 
                SQLiteStatement stmt = deleteUpdatedStmt;
@@ -231,12 +230,11 @@ public class LockDao implements IDao<Lock> {
                }
        }
 
-       // TODO
        public void unlock(Class clazz, String key) {
                try {
                        this.delete(key, clazz.getName());
                } catch (Exception e) {
-                       // TODO
+                       ;
                }
        }
        
@@ -244,7 +242,7 @@ public class LockDao implements IDao<Lock> {
                try {
                        this.delete(key, getClazz(obj));
                } catch (Exception e) {
-                       // TODO
+                       ;
                }
        }
 
index 1694833..d4ce622 100644 (file)
@@ -25,10 +25,10 @@ public class Node {
        protected boolean selected = false;
 
        public static int getStatusCode(Status status) {
-               if (status == status.OPEN) {
+               if (status == Status.OPEN) {
                        return 1;
                }
-               if (status == status.CLOSE) {
+               if (status == Status.CLOSE) {
                        return 2;
                }
                return 0;
@@ -101,8 +101,6 @@ public class Node {
                        return;
                }
                children.add(node);
-               // TODO DB
-               // node.setParent(id);
        }
 
        public void remove(long node) {
@@ -110,8 +108,6 @@ public class Node {
                        return;
                }
                children.remove(node);
-               // TODO DB
-               // node.setParent(-1);
        }
 
        public LabelIconView getView() {
index 7c191a9..cdd6a48 100644 (file)
@@ -1,7 +1,6 @@
 package com.yuji.ef.dao;
 
 import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 
 import android.database.sqlite.SQLiteDatabase;
@@ -12,7 +11,6 @@ public class NodeCacheDao extends NodeDaoImpl implements IDao<Node>, NodeDao {
        private static final int MAP_SIZE = 1024;
 
        private static IDao<Node> instance = null;
-       //private static NodeDao dao = (NodeDao) NodeDaoImpl.getInstance();
        private static LinkedHashMap<Long, Node> map = new LinkedHashMap<Long, Node>(
                        MAP_SIZE, (float) 0.75, true) {
                @Override
@@ -32,46 +30,6 @@ public class NodeCacheDao extends NodeDaoImpl implements IDao<Node>, NodeDao {
 
        }
 
-//     @Override
-//     public void onCreate(SQLiteDatabase db) {
-//             dao.onCreate(db);
-//     }
-//
-//     @Override
-//     public void init(SQLiteDatabase db) {
-//             dao.init(db);
-//     }
-//
-//     @Override
-//     public void start(SQLiteDatabase db) {
-//             dao.start(db);
-//     }
-//
-//     @Override
-//     public void start2(SQLiteDatabase db) {
-//             dao.start2(db);
-//     }
-//
-//     @Override
-//     public List<Node> search() {
-//             return dao.search();
-//     }
-//
-//     @Override
-//     public Node searchRoot() {
-//             return dao.searchRoot();
-//     }
-//
-//     @Override
-//     public Node searchRoot(SQLiteDatabase db) {
-//             return dao.searchRoot(db);
-//     }
-//
-//     @Override
-//     public Node searchById(long id) {
-//             return dao.searchById(id);
-//     }
-
        @Override
        public Node searchById(SQLiteDatabase db, long id) {
                Node n = map.get(id);
@@ -83,95 +41,30 @@ public class NodeCacheDao extends NodeDaoImpl implements IDao<Node>, NodeDao {
                return n;
        }
 
-//     @Override
-//     public Node searchByGuid(SQLiteDatabase db, String guid) {
-//             return dao.searchByGuid(db, guid);
-//     }
-//
-//     @Override
-//     public boolean isEmpty() {
-//             return dao.isEmpty();
-//     }
-//
-//     @Override
-//     public long add(Node node) {
-//             return dao.add(node);
-//     }
-//
-//     @Override
-//     public long addNT(Node node) {
-//             return dao.addNT(node);
-//     }
-//
-//     @Override
-//     public long addChildrenId(Node node, long id) {
-//             return dao.addChildrenId(node, id);
-//     }
-//
-//     @Override
-//     public long addChildrenIdNT(Node node, long id) {
-//             return dao.addChildrenIdNT(node, id);
-//     }
-
        @Override
        public long updateChildrenNT(Node node, String children) {
                map.remove(node.getId());
                return super.updateChildrenNT(node, children);
        }
 
-//     @Override
-//     public long removeChildrenId(Node node, long id) {
-//             return dao.removeChildrenId(node, id);
-//     }
-
        @Override
        public long removeChildrenIdNT(Node node, long id) {
                map.remove(node.getId());
                return super.removeChildrenIdNT(node, id);
        }
 
-//     @Override
-//     public long updateStatus(Node node, Status status) {
-//             return dao.updateStatus(node, status);
-//     }
-//
-//     @Override
-//     public long updateStatus(SQLiteDatabase db, Node node, Status status) {
-//             return dao.updateStatus(db, node, status);
-//     }
-
        @Override
        public long updateStatusNT(Node node, Status status) {
                map.remove(node.getId());
                return super.updateStatusNT(node, status);
        }
 
-//     @Override
-//     public long updateName(Node node, String name) {
-//             return dao.updateName(node, name);
-//     }
-//
-//     @Override
-//     public long updateName(SQLiteDatabase db, Node node, String name) {
-//             return dao.updateName(db, node, name);
-//     }
-
        @Override
        public long updateNameNT(Node node, String name) {
                map.remove(node.getId());
                return super.updateNameNT(node, name);
        }
 
-//     @Override
-//     public long updateParent(Node node, long parent) {
-//             return dao.updateParent(node, parent);
-//     }
-//
-//     @Override
-//     public long updateParent(SQLiteDatabase db, Node node, long parent) {
-//             return dao.updateParent(db, node, parent);
-//     }
-
        @Override
        public long updateSelectedNT(Node node, boolean isSelected) {
                map.remove(node.getId());
@@ -190,44 +83,18 @@ public class NodeCacheDao extends NodeDaoImpl implements IDao<Node>, NodeDao {
                return super.updateParentNT(node, parent);
        }
 
-//     @Override
-//     public long updateChildren(Node node, String children) {
-//             return dao.updateChildren(node, children);
-//     }
-//
-//     @Override
-//     public long delete(long id) {
-//             return dao.delete(id);
-//     }
-//
-//     @Override
-//     public long delete(SQLiteDatabase db, long did) {
-//             return dao.delete(db, did);
-//     }
-
        @Override
        public long deleteNT(long did) {
                map.remove(did);
                return super.deleteNT(did);
        }
 
-//     @Override
-//     public long delete() {
-//             return dao.delete();
-//     }
-//
-//     @Override
-//     public long delete(SQLiteDatabase db) {
-//             return dao.delete(db);
-//     }
-
        @Override
        public void deleteNT() {
                map.clear();
                super.deleteNT();
        }
 
-
        @Override
        public void clear() {
                map.clear();            
index ebd83a3..bfc9f8f 100644 (file)
@@ -270,13 +270,6 @@ public class NodeDaoImpl implements IDao<Node>, NodeDao {
                        cursor.moveToFirst();
                        int size = cursor.getCount();
                        for (int i = 0; i < size; i++) {
-                               // TODO Factory
-                               // Node Node = new Node(
-                               // cursor.getLong(0),
-                               // cursor.getString(1),
-                               // cursor.getString(2),
-                               // cursor.getLong(3),
-                               // cursor.getLong(4));
                                Node node = factory.create(cursor.getLong(0), cursor.getInt(1),
                                                cursor.getString(2), cursor.getLong(3),
                                                cursor.getString(4), cursor.getString(5),
@@ -827,7 +820,7 @@ public class NodeDaoImpl implements IDao<Node>, NodeDao {
         */
        @Override
        public long deleteNT(long did) {
-               long id = -1; // TODO
+               long id = -1;
                int i = 1;
 
                SQLiteStatement stmt = deleteIdStmt;
index d4d506d..491215f 100644 (file)
@@ -19,16 +19,13 @@ public class NodeFactory {
                
                switch (type){
                case Node.TYPE_ROOT:
-                       // TODO
                        node = new RootNode(name, null, children, status);
                        break;
                case Node.TYPE_BOOK:
                case Node.TYPE_DIR:
-                       // TODO
                        node = new DirNode(name, null, children, status);
                        break;
                case Node.TYPE_NOTE:
-                       // TODO
                        node = new FileNode(name, null);
                        break;
                default:
index eb4ac84..01f96e9 100644 (file)
@@ -3,6 +3,7 @@ package com.yuji.ef.exception;
 public enum EfError {
        NONE,
        
+       INIT,
        NOT_FOUND,
        NO_LOGIN,       
        
index 38e1f9e..429fb64 100644 (file)
@@ -1,13 +1,12 @@
 package com.yuji.ef.exception;
 
-import com.yuji.ef.Initialize;
-import com.yuji.ef.common.Constant;
-
 import android.content.Context;
 import android.content.Intent;
-import android.os.Handler;
 import android.widget.Toast;
 
+import com.yuji.ef.Initialize;
+import com.yuji.ef.common.Constant;
+
 public class EfException extends Exception {
        /**
         * 
index e86e3cc..6800a01 100644 (file)
@@ -17,7 +17,6 @@ import com.yuji.ef.dao.LockDao;
 import com.yuji.ef.exception.EfException;
 import com.yuji.ef.pref.EditPrefUtil;
 import com.yuji.ef.task.NoteUpdateTask;
-import com.yuji.ef.utility.DateUtil;
 import com.yuji.ef.utility.Debug;
 import com.yuji.ef.utility.EvernoteUtil;
 import com.yuji.ef.utility.NetworkUtil;
@@ -33,7 +32,6 @@ public class NoteUpdatorService extends Service {
 
        public static final String ACTION = "NoteUpdatorService";
        public static final String ACTION_START = "START";
-       private static final int DS = 60;
        private EditPrefUtil pref = new EditPrefUtil(this);
        private KitchenTimerBinder binder = new KitchenTimerBinder();
        private String action = null;
index c02d204..ff59488 100644 (file)
@@ -2,11 +2,6 @@ package com.yuji.ef.task;
 
 import java.lang.ref.WeakReference;
 
-import android.R;
-import android.content.Context;
-import android.content.Intent;
-
-import com.yuji.ef.Initialize;
 import com.yuji.ef.SettingActivity;
 import com.yuji.ef.common.Constant;
 import com.yuji.ef.dao.LockDao;
@@ -15,7 +10,6 @@ import com.yuji.ef.exception.EfException;
 import com.yuji.ef.exception.RollbackException;
 import com.yuji.ef.utility.AsyncTaskIF;
 import com.yuji.ef.utility.Debug;
-import com.yuji.ef.utility.EvernoteUtil;
 import com.yuji.ef.utility.FolderUtil;
 
 public class NoteUpdateTask implements AsyncTaskIF {
@@ -81,11 +75,6 @@ public class NoteUpdateTask implements AsyncTaskIF {
                        activity.done(errorCode);
                        activityRef = null;
                }
-
-               // if (context != null) {
-               // Intent intent = new Intent(Constant.ACTION_UPDATE);
-               // context.sendBroadcast(intent);
-               // }
        }
 
        private SettingActivity getActivity() {
@@ -97,7 +86,7 @@ public class NoteUpdateTask implements AsyncTaskIF {
 
        @Override
        public int getStatus() {
-               // TODO
+               // NOT USED
                return 0;
        }
 }
index fb751f8..e8cff8d 100644 (file)
@@ -9,8 +9,10 @@ import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.Window;
 import android.view.WindowManager;
+import android.widget.Toast;
 
 import com.yuji.ef.Initialize;
+import com.yuji.ef.R;
 
 public class BaseActivity extends Activity {
        @Override
@@ -19,7 +21,7 @@ public class BaseActivity extends Activity {
                Debug.d(this, Debug.ON_CREATE);
 
                try {
-                       String name = this.getLocalClassName();
+                       //String name = this.getLocalClassName();
                        Context context = getApplicationContext();
                        Initialize.initialize(context);
                }
@@ -128,20 +130,18 @@ public class BaseActivity extends Activity {
                if (t != null) {
                        Debug.d(target, null, t);
                }
-               // TODO
-//             showDialog(getString(R.string.dialogErrorTitle),
-//                             getString(R.string.dialogSystemError));
+               showDialog(getString(R.string.dialogErrorTitle),
+                               getString(R.string.dialogSystemError));
        }
 
        public void terminate(Throwable t) {
                if (t != null) {
                        Debug.d(this, null, t);
 
-                       // TODO
-//                     Toast.makeText(
-//                                     this,
-//                                     getString(R.string.toastSystem) + ":"
-//                                                     + t.getLocalizedMessage(), Toast.LENGTH_LONG);
+                       Toast.makeText(
+                                       this,
+                                       getString(R.string.toastSystem) + ":"
+                                                       + t.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
                moveTaskToBack(true);
        }
index d9c4860..94c271c 100644 (file)
@@ -85,33 +85,7 @@ public class Debug {
                        Log.d(FILTER, text, t);                 
                }
        }
-       
-//     public static void t(Context context, String msg){
-//             if (!Log.isLoggable(FILTER, Log.DEBUG)){
-//                     return;
-//             }
-//             if (context == null){
-//                     return;
-//             }
-//             Intent intent = new Intent(DelayReceiver.DEBUG);
-//             intent.putExtra("TEXT", msg);
-//             context.sendBroadcast(intent);
-//     }
-//     
-//     public static void l(String msg){
-//             if (!Log.isLoggable(FILTER, Log.DEBUG)){
-//                     return;
-//             }
-//             Calendar cal = Calendar.getInstance();
-//             Date date = cal.getTime();
-//             int ymd = DateUtil.getYmd(date);
-//             int hm = DateUtil.getHm(date);
-//             com.td.db.Log log = new com.td.db.Log(ymd, hm, msg);
-//             
-//             LogDao dao = LogDao.getInstance();
-//             dao.add(log);
-//     }
-       
+               
        public static boolean isDebug(){
                return Log.isLoggable(FILTER, Log.DEBUG);
        }
index f3d2f66..4b21e57 100644 (file)
@@ -35,8 +35,6 @@ public class EvernoteIntentUtil {
        }
 
        public void viewNote(Context context, String noteGuid) {
-               //String noteGuid = "8323550a-8e99-4100-b638-d4f07fd1c815";
-               //boolean hideTitleBar = true;
                boolean hideTitleBar = false;
 
                Intent intent = new Intent();
@@ -46,7 +44,7 @@ public class EvernoteIntentUtil {
                try {
                        context.startActivity(intent);
                } catch (android.content.ActivityNotFoundException ex) {
-                       // TODO
+                       ;
                }
        }
 
index e6e542d..b2be7a6 100644 (file)
@@ -297,7 +297,6 @@ public class EvernoteUtil {
                        try {
                                noteStore = session.createNoteStore();
                        } catch (TTransportException e) {
-                               // TODO
                                authenticationToken = null;
                        }
                }
@@ -388,17 +387,13 @@ public class EvernoteUtil {
                                }
                        }
                } catch (EDAMUserException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (EDAMSystemException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (EDAMNotFoundException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (TException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                }
        }
        
@@ -418,17 +413,13 @@ public class EvernoteUtil {
                try {
                        newNote = noteStore.createNote(authToken, note);
                } catch (EDAMUserException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (EDAMSystemException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (EDAMNotFoundException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (TException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                }
                return newNote;
        }
@@ -458,17 +449,13 @@ public class EvernoteUtil {
                        Notebook  memoSchedule = createHelpBook(token, "スケジュール");
                        
                } catch (EDAMUserException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (EDAMSystemException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (TException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                } catch (EDAMNotFoundException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
+                       Debug.d(this,  null, e);
                }
        }
 
@@ -481,91 +468,4 @@ public class EvernoteUtil {
        public Note createHelpNote(String toke, Notebook notebook, String name) throws EDAMUserException, EDAMSystemException, EDAMNotFoundException, TException{
                return createNote(notebook, name);
        }       
-       
-       // 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 60ec565..3b44f5f 100644 (file)
@@ -3,13 +3,8 @@ package com.yuji.ef.utility;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.thrift.TException;
-
 import android.database.sqlite.SQLiteDatabase;
 
-import com.evernote.edam.error.EDAMNotFoundException;
-import com.evernote.edam.error.EDAMSystemException;
-import com.evernote.edam.error.EDAMUserException;
 import com.evernote.edam.notestore.NoteList;
 import com.evernote.edam.type.Note;
 import com.evernote.edam.type.Notebook;
@@ -41,9 +36,12 @@ public class FolderUtil {
 
        }
 
-       public void updateNotebook(SQLiteDatabase db, List<Long> removeList) {
+       public void updateNotebook(SQLiteDatabase db, List<Long> removeList) throws RollbackException {
                List<Notebook> noteBookList = util.getNoteBookList();
-
+               if (noteBookList == null){
+                       throw new RollbackException(EfError.SYSTEM);
+               }
+               
                long id;
                Node top = nodeDao.searchRoot(db);
 
@@ -70,6 +68,9 @@ public class FolderUtil {
 
                // 削除
                List<Node> list = nodeDao.searchBook(db);
+               if (list == null){
+                       throw new RollbackException(EfError.SYSTEM);
+               }
                for (Node node : list) {
                        boolean isFound = false;
                        for (Notebook book : noteBookList) {
@@ -106,9 +107,15 @@ public class FolderUtil {
        
        public void updateNote(SQLiteDatabase db) throws RollbackException {
                List<Node> list = nodeDao.searchSelectedBook(db);
+               if (list == null){
+                       throw new RollbackException(EfError.SYSTEM);
+               }
                for (Node node : list) {
                        String guid = node.getGuid();
                        List<NoteList> noteListList = util.getNoteListByNotebook(guid);
+                       if (noteListList == null){
+                               throw new RollbackException(EfError.SYSTEM);
+                       }
                        updateNote(db, noteListList);
                }
        }
@@ -177,8 +184,11 @@ public class FolderUtil {
                }
        }
 
-       private void deleteNode(SQLiteDatabase db) {
+       private void deleteNode(SQLiteDatabase db) throws RollbackException {
                List<Node> list = nodeDao.searchNoteByFlag(db, 0);
+               if (list == null){
+                       throw new RollbackException(EfError.SYSTEM);
+               }
                for (Node node : list) {
                        nodeDao.deleteNT(node.getId());
                        long pid = node.getParent();
@@ -225,6 +235,9 @@ public class FolderUtil {
                        
                        db.setTransactionSuccessful();
                        nodeDao.clear();
+               }
+               catch (RuntimeException e){
+                       throw e;
                } finally {
                        db.endTransaction();
                }
index 6284ea5..a8a3718 100644 (file)
@@ -6,12 +6,11 @@ import android.os.Message;
 import com.yuji.ef.dao.LockDao;
 
 public class LockHandler {
-       private LockListener target;
+       private final static int N = 64;
        private LockDao dao = (LockDao) LockDao.getInstance();
 
-       public void lock(final LockListener target, final String key) {
-               this.target = target;
-
+       public void lock(final LockListener target, final String key,
+                       final boolean wait) {
                final Handler handler = new Handler() {
                        public void handleMessage(Message msg) {
                                target.sendLockResult(msg.what != 0);
@@ -20,9 +19,26 @@ public class LockHandler {
                Thread t = new Thread(new Runnable() {
                        @Override
                        public void run() {
-                               boolean lock = dao.lock(target, key);
-                               
-                               handler.sendEmptyMessage(lock? 1 : 0);
+                               int n = 1;
+                               while (true) {
+                                       boolean lock = dao.lock(target, key);
+
+                                       if (wait) {
+                                               if (!lock) {
+                                                       try {
+                                                               Thread.sleep(n * 1000);
+                                                       } catch (InterruptedException e) {
+                                                               ;
+                                                       }
+                                                       if (n < N){
+                                                               n *= 2;
+                                                       }
+                                                       continue;
+                                               }
+                                       }
+                                       handler.sendEmptyMessage(lock ? 1 : 0);
+                                       break;
+                               }
                        }
                });
                t.start();