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;
private LinearLayout buttonLayout;
private Button leftButton;
private Button rightButton;
- // private Button addButton;
- // private Button deleteButton;
private ScreenStatus status;
private NodeComparator nodeComparator = new NodeComparator();
private boolean isInit = true;
private boolean isInCycle = false;
private boolean isResult = false;
-
+ private LockHandler lockHandler = null;
+
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
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);
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) {
leftButton.setTextSize(fSize);
rightButton.setTextSize(fSize);
} catch (Exception e) {
- // TODO
- e.printStackTrace();
+ EfException.msg(R.string.ErrorSystem, e);
}
}
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,
NodeDao dao = (NodeDao) NodeCacheDao.getInstance();
top = dao.searchRoot();
if (top == null) {
- // TODO
+ // データ0件(データ未更新)
+ return;
}
updateList(top);
}
for (Long id : idList) {
Node n = dao.searchById(id);
if (n == null) {
- // TODO
+ // ERROR
continue;
}
if (n instanceof DirNode) {
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());
}
}
if (isInCycle) {
-// LockDao lockDao = (LockDao) LockDao.getInstance();
-// lock = lockDao.lock(this, Constant.LOCK_UPDATE_NOTE);
if (isInit) {
status = ScreenStatus.Normal;
setStatus();
isInit = false;
} else {
- if (lock){
+ if (lock) {
+ layout.setVisibility(View.VISIBLE);
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;
}
super.onResume();
isInCycle = true;
- LockHandler handler = new LockHandler();
- handler.lock(this, Constant.LOCK_UPDATE_NOTE);
+ // #29573
+ // 「強制的のロックを削除するためのフラグ」をOFFに
+ // →起動時の初回のみ削除を試みるため
+ boolean isUnlock = pref.getInt(Constant.PREF_DELETE_LOCK)== Constant.ON;
+ if (isUnlock){
+ pref.put(Constant.PREF_DELETE_LOCK, Constant.OFF);
+ pref.update();
+ }
+
+ lockHandler = new LockHandler();
+ lockHandler.lock(this, Constant.LOCK_UPDATE_NOTE, true, isUnlock);
lock = false;
if (isInit) {
layout.setVisibility(View.INVISIBLE);
setStatus();
} else {
- // #29421
- updateList();
+ // #29589
+ //// #29421
+ //updateList();
+ layout.setVisibility(View.INVISIBLE);
+ setStatus();
}
-
- // 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
lockDao.unlock(this, Constant.LOCK_UPDATE_NOTE);
lock = false;
+ if (lockHandler != null){
+ lockHandler.cancel();
+ lockHandler = null;
+ }
+
super.onPause();
isInCycle = false;
}
}
}
- // 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();
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);
Node sp = dao.searchById(src.getParent());
if (sp == null) {
- // TODO
+ throw new EfException(EfError.NOT_FOUND);
}
Node dp = null;
- if (src.getParent() == dst.getParent()) {
+ if (src.getParent() == dst.getParent() || dst.getParent() < 0) {
dp = sp;
} else {
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());
}
} finally {
db.endTransaction();
}
+ } catch (EfException e) {
+ EfException.msg(R.string.ErrorSystem, e);
} finally {
updateList();
}
}
Node node = dao.searchById(dstId);
if (node == null) {
- // TODO エラー
+ // ERROR
return false;
}
if (!(node instanceof DirNode)) {
}
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, e);
+ }
}
public void executeView(long id) {
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);
leftButton.setEnabled(false);
rightButton.setEnabled(false);
}
- } catch (Throwable e) {
- // TODO
- e.printStackTrace();
+ } catch (Exception e) {
+ EfException.msg(R.string.ErrorSystem, e);
}
}