@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean ret = super.onCreateOptionsMenu(menu);
- menu.add(Menu.NONE, Menu.FIRST, Menu.NONE, "リネーム");
- menu.add(Menu.NONE, Menu.FIRST + 1, Menu.NONE, "設定");
+ menu.add(Menu.NONE, Menu.FIRST + 0, Menu.NONE, "カット");
+ menu.add(Menu.NONE, Menu.FIRST + 1, Menu.NONE, "ペースト");
+ menu.add(Menu.NONE, Menu.FIRST + 2, Menu.NONE, "リネーム");
+ menu.add(Menu.NONE, Menu.FIRST + 3, Menu.NONE, "設定");
return ret;
}
Intent intent;
try {
switch (item.getItemId()) {
- case Menu.FIRST:
- selectMenuRename();
+ case Menu.FIRST + 0:
+ selectMenuCut();
break;
case Menu.FIRST + 1:
+ selectMenuPast();
+ break;
+ case Menu.FIRST + 2:
+ selectMenuRename();
+ break;
+ case Menu.FIRST + 3:
intent = new Intent(this, (Class<?>) SettingActivity.class);
startActivityForResult(intent, 0);
break;
}
private void selectMenuRename(){
- FolderUtil util = FolderUtil.getInstance();
LabelIconView target = layout.getSelectedTarget();
+ if (target == null){
+ return;
+ }
+
long id = target.getNodeId();
NodeDao dao = (NodeDao) NodeDao.getInstance();
Node node = dao.searchById(id);
setStatus(ScreenStatus.RenameNode);
}
}
+
+ private void selectMenuCut(){
+ LabelIconView target = layout.getSelectedTarget();
+ if (target == null){
+ return;
+ }
+
+ layout.setCutTarget(target);
+ layout.refresh();
+ }
+
+ private void selectMenuPast(){
+ LabelIconView srcTarget = layout.getCutTarget();
+ if (srcTarget == null){
+ return;
+ }
+
+ LabelIconView dstTarget = layout.getSelectedTarget();
+ if (dstTarget == null){
+ return;
+ }
+
+ layout.setCutTarget(null);
+
+ long srcId = srcTarget.getNodeId();
+ long dstId = dstTarget.getNodeId();
+ execute(srcId, dstId);
+ }
private void updateList() {
NodeDao dao = (NodeDao) NodeDao.getInstance();
}
layout.removeAllViews();
updateList(top);
+ layout.refresh();
}
private void updateList(Node parent) {
private LabelIconView target = null;
private LabelIconView destTarget = null;
private LabelIconView selectedTarget = null;
+ private LabelIconView cutTarget = null;
private List<LabelIconView> labelIconViewList = new ArrayList<LabelIconView>();
private Animation anime;
- private int startX;
- private int startY;
private int currentX;
private int currentY;
private int offsetX;
labelIconViewList.add(child);
}
-// public void removeView(LabelIconView child) {
-// super.removeView(child);
-// labelIconViewList.remove(child);
-// }
-
public void removeAllViews(){
super.removeAllViews();
labelIconViewList.clear();
return null;
}
+ public void setScrollView(final IconScrollView scrollView) {
+ this.scrollView = scrollView;
+ this.setOnLongClickListener(this);
+ //this.setLongClickable(true);
+
+ anime = AnimationUtils.loadAnimation(context, R.anim.sample);
+ anime.setAnimationListener(new AnimationListener() {
+ public void onAnimationStart(Animation animation) {
+ }
+
+ public void onAnimationRepeat(Animation animation) {
+ }
+
+ public void onAnimationEnd(Animation animation) {
+ // if (isBt2Click) {
+ // bt2.performClick();
+ // isBt2Click = false;
+ // }
+ target = null;
+ destTarget = null;
+
+ scrollView.setScrollable(true);
+ scrollView.requestDisallowInterceptTouchEvent(false);
+ scrollView.invalidate();
+ }
+ });
+ }
+
+ public void refresh(){
+ if (selectedTarget != null){
+ long id = selectedTarget.getNodeId();
+ for (LabelIconView view : labelIconViewList){
+ if (view.getNodeId() == id){
+ selectedTarget = view;
+ target = view;
+ selectedTarget.setAlpha(255);
+ selectedTarget.setColorFilter(Color.RED, Mode.LIGHTEN);
+ }
+ }
+ }
+ if (cutTarget != null){
+ long id = cutTarget.getNodeId();
+ for (LabelIconView view : labelIconViewList){
+ if (view.getNodeId() == id){
+ cutTarget = view;
+ cutTarget.clearColorFilter();
+ cutTarget.setAlpha(64);
+ }
+ }
+ }
+ }
+
+ public LabelIconView getCutTarget(){
+ return cutTarget;
+ }
+
+ public void setCutTarget(LabelIconView cutTarget){
+ this.cutTarget = cutTarget;
+ selectedTarget = null;
+ target = null;
+ }
+
@Override
public boolean onTouchEvent(MotionEvent event) {
try {
currentX = obj.getLeft();
currentY = obj.getTop();
+ target.setAlpha(255);
target.setColorFilter(Color.RED, Mode.LIGHTEN);
selectedTarget = target;
activity.targetSelectedChanged(true);
longClickFlg = true;
return true;
}
-
- public void setScrollView(final IconScrollView scrollView) {
- this.scrollView = scrollView;
- this.setOnLongClickListener(this);
- //this.setLongClickable(true);
-
- anime = AnimationUtils.loadAnimation(context, R.anim.sample);
- anime.setAnimationListener(new AnimationListener() {
- public void onAnimationStart(Animation animation) {
- }
-
- public void onAnimationRepeat(Animation animation) {
- }
-
- public void onAnimationEnd(Animation animation) {
- // if (isBt2Click) {
- // bt2.performClick();
- // isBt2Click = false;
- // }
- target = null;
- destTarget = null;
-
- scrollView.setScrollable(true);
- scrollView.requestDisallowInterceptTouchEvent(false);
- scrollView.invalidate();
- }
- });
- }
}