OSDN Git Service

T29234
authorYuji Konishi <yuji.k64613@gmail.com>
Sat, 11 Aug 2012 06:26:51 +0000 (15:26 +0900)
committerYuji Konishi <yuji.k64613@gmail.com>
Sat, 11 Aug 2012 06:26:51 +0000 (15:26 +0900)
T28432

source/workspace/EverFolder/src/com/yuji/ef/EverFolderActivity.java
source/workspace/EverFolder/src/com/yuji/ef/IconFrameLayout.java

index 78ba2ab..26d1832 100644 (file)
@@ -142,8 +142,10 @@ public class EverFolderActivity extends BaseActivity {
        @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;
        }
 
@@ -152,10 +154,16 @@ public class EverFolderActivity extends BaseActivity {
                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;
@@ -193,8 +201,11 @@ public class EverFolderActivity extends BaseActivity {
        }
 
        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);
@@ -204,6 +215,34 @@ public class EverFolderActivity extends BaseActivity {
                        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();
@@ -213,6 +252,7 @@ public class EverFolderActivity extends BaseActivity {
                }
                layout.removeAllViews();
                updateList(top);
+               layout.refresh();
        }
 
        private void updateList(Node parent) {
index 1295fb8..ce94a00 100644 (file)
@@ -22,11 +22,10 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
        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;
@@ -75,11 +74,6 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                labelIconViewList.add(child);
        }
 
-//     public void removeView(LabelIconView child) {
-//             super.removeView(child);
-//             labelIconViewList.remove(child);
-//     }
-
        public void removeAllViews(){
                super.removeAllViews();
                labelIconViewList.clear();
@@ -113,6 +107,68 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                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 {
@@ -236,6 +292,7 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                                        currentX = obj.getLeft();
                                        currentY = obj.getTop();
        
+                                       target.setAlpha(255);
                                        target.setColorFilter(Color.RED, Mode.LIGHTEN);
                                        selectedTarget = target;
                                        activity.targetSelectedChanged(true);
@@ -314,32 +371,4 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                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();
-                       }
-               });
-       }
 }