OSDN Git Service

T28368
authorYuji Konishi <yuji.k64613@gmail.com>
Sat, 19 May 2012 04:22:28 +0000 (13:22 +0900)
committerYuji Konishi <yuji.k64613@gmail.com>
Sat, 19 May 2012 04:22:28 +0000 (13:22 +0900)
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/LabelIconView.java
source/workspace/EverFolder/src/com/yuji/ef/dao/Node.java

index b3aa1ed..f809d6a 100644 (file)
@@ -45,6 +45,7 @@ public class EverFolderActivity extends Activity /*implements OnTouchListener,
 
                scrollView = (IconScrollView) findViewById(R.id.scrollView);
                layout = (IconFrameLayout) findViewById(R.id.frameLayout);
+               layout.setActivity(this);
                layout.setScrollView(scrollView);
                //layout.setClickable(false);
                // layout = new FrameLayout(this);
@@ -94,19 +95,19 @@ public class EverFolderActivity extends Activity /*implements OnTouchListener,
                        top = new DirNode(null, null);
                        
                        Node node;
-                       node = new DirNode("\83f\83B\83\8c\83N\83g\83\8a", new LabelIconView(this));
+                       node = new DirNode("\83f\83B\83\8c\83N\83g\83\8a", null);
                        top.add(node);
-                       node.add(new FileNode("\83t\83@\83C\83\8baaa", new LabelIconView(this)));
-                       node.add(new FileNode("\83t\83@\83C\83\8bbb", new LabelIconView(this)));
-                       node.add(new FileNode("\83t\83@\83C\83\8bc", new LabelIconView(this)));
+                       node.add(new FileNode("\83t\83@\83C\83\8baaa", null));
+                       node.add(new FileNode("\83t\83@\83C\83\8bbb", null));
+                       node.add(new FileNode("\83t\83@\83C\83\8bc", null));
                        
-                       node = new DirNode("\83f\83B\83\8c\83N\83g\83\8aAAA", new LabelIconView(this));
+                       node = new DirNode("\83f\83B\83\8c\83N\83g\83\8aAAA", null);
                        top.add(node);
-                       node.add(new DirNode("directory qqqq", new LabelIconView(this)));
-                       node.add(new FileNode("\83t\83@\83C\83\8bdddddddd", new LabelIconView(this)));
-                       node.add(new FileNode("\83t\83@\83C\83\8beee", new LabelIconView(this)));
+                       node.add(new DirNode("directory qqqq", null));
+                       node.add(new FileNode("\83t\83@\83C\83\8bdddddddd", null));
+                       node.add(new FileNode("\83t\83@\83C\83\8beee", null));
 
-                       node = new FileNode("\83t\83@\83C\83\8bzzz", new LabelIconView(this));
+                       node = new FileNode("\83t\83@\83C\83\8bzzz", null);
                        top.add(node);
                        
                        updateList(top);
@@ -129,10 +130,12 @@ public class EverFolderActivity extends Activity /*implements OnTouchListener,
        }
        
        private void updateList(Node node, int x){
-               int N = 200;
+               int N = 100;
                int M = 120;
                
-               LabelIconView view = node.getView();
+               LabelIconView view = new LabelIconView(this);
+               node.setView(view);
+               
                Resources r = getResources();
                Bitmap bmp = BitmapFactory.decodeResource(r, node.getIconId());
                createIconImageView(view, bmp, node.getName(), x, viewY);
@@ -266,6 +269,25 @@ public class EverFolderActivity extends Activity /*implements OnTouchListener,
                // startActivity(intent);
        }
 
+       public void execute(Node src, Node dst){
+               removeAllNodeView();
+               
+               if (dst instanceof DirNode){
+                       src.getParent().remove(src);
+                       dst.add(src);                   
+               }
+               else if (dst instanceof FileNode){
+                       src.getParent().remove(src);
+                       dst.getParent().add(src);                       
+               }
+               
+               updateList(top);                
+       }
+       
+       public void removeAllNodeView(){
+               layout.removeAllViews();
+       }
+       
 //     @Override
 //     public boolean onTouch(View v, MotionEvent event) {
 //             int x = (int) event.getRawX();
index 7fd94d4..ebac719 100644 (file)
@@ -3,6 +3,8 @@ package com.yuji.ef;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.yuji.ef.dao.Node;
+
 import android.content.Context;
 import android.graphics.Color;
 import android.graphics.Point;
@@ -18,6 +20,8 @@ import android.view.animation.Animation.AnimationListener;
 import android.widget.FrameLayout;
 
 public class IconFrameLayout extends FrameLayout implements OnLongClickListener {
+       private EverFolderActivity activity = null;
+
        private LabelIconView target = null;
        private LabelIconView dest = null;
        private List<LabelIconView> list = new ArrayList<LabelIconView>();
@@ -45,6 +49,10 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                super(context, attrs, defStyle);
        }
 
+       public void setActivity(EverFolderActivity activity) {
+               this.activity = activity;
+       }
+       
        @Override
        protected void onLayout(boolean changed, int left, int top, int right,
                        int bottom) {
@@ -70,6 +78,11 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                list.remove(child);
        }
 
+       public void removeAllViews(){
+               super.removeAllViews();
+               list.clear();
+       }
+       
        public void moveTop(LabelIconView child){
                this.removeView(child);
                this.addView(child);
@@ -208,10 +221,10 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                                }
                                obj = target;
 
-                               obj.setAnimation(anime);
-                               obj.startAnimation(anime);
                                // obj.setVisibility(View.GONE);
                                if (dest == null) {
+                                       obj.setAnimation(anime);
+                                       obj.startAnimation(anime);
                                        // \8fÁ\82·\8fê\8d\87
                                        // layout.removeView(obj);
 
@@ -222,19 +235,32 @@ public class IconFrameLayout extends FrameLayout implements OnLongClickListener
                                                        + target.getHeight());
                                        target.setAlpha(255);
                                } else {
-                                       int srcX = target.getInitX();
-                                       int srcY = target.getInitY();
-                                       int dstX = dest.getInitX();
-                                       int dstY = dest.getInitY();
+                                       // \83A\83j\83\81\81[\83V\83\87\83\93
+//                                     int srcX = target.getInitX();
+//                                     int srcY = target.getInitY();
+//                                     int dstX = dest.getInitX();
+//                                     int dstY = dest.getInitY();
+//
+//                                     target.layout(dstX, dstY, dstX + target.getWidth(), dstY
+//                                                     + target.getHeight());
+//                                     target.init(dstX, dstY);
+//                                     target.setAlpha(255);
+//                                     dest.layout(srcX, srcY, srcX + dest.getWidth(),
+//                                                     srcY + dest.getHeight());
+//                                     dest.init(srcX, srcY);
+//                                     dest.setAlpha(255);
+                                       Node src = target.getNode();
+                                       Node dst = dest.getNode();
+                                       activity.execute(src, dst);
+                                       
+                                       // TODO
+                                       // \83A\83j\83\81\81[\83V\83\87\83\93\8cã\82Ì\8f\88\97\9d\82æ\82è
+                                       target = null;
+                                       dest = null;
 
-                                       target.layout(dstX, dstY, dstX + target.getWidth(), dstY
-                                                       + target.getHeight());
-                                       target.init(dstX, dstY);
-                                       target.setAlpha(255);
-                                       dest.layout(srcX, srcY, srcX + dest.getWidth(),
-                                                       srcY + dest.getHeight());
-                                       dest.init(srcX, srcY);
-                                       dest.setAlpha(255);
+                                       scrollView.setScrollable(true);
+                                       scrollView.requestDisallowInterceptTouchEvent(false);
+                                       scrollView.invalidate();
                                }
 
                                //this.getParent().requestDisallowInterceptTouchEvent(false);
index be10429..ff6562b 100644 (file)
@@ -7,6 +7,8 @@ import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import com.yuji.ef.dao.Node;
+
 public class LabelIconView extends LinearLayout {
        private boolean isInit = false;
        private int initX = 0;
@@ -14,11 +16,16 @@ public class LabelIconView extends LinearLayout {
        
        private ImageView imageView = null;
        private TextView textView = null;
-
+       private Node node = null;
+       
        public LabelIconView(Context context) {
                super(context);
        }
 
+       public Node getNode() {
+               return node;
+       }
+
        public void init(int x, int y, Bitmap bmp, String text) {
                init(x, y);
                Context context = this.getContext();
@@ -29,10 +36,20 @@ public class LabelIconView extends LinearLayout {
                textView = new TextView(context);
                textView.setText(text);
                
+               if (imageView != null){
+                       this.removeView(imageView);
+               }
+               if (textView != null){
+                       this.removeView(textView);
+               }
                this.addView(imageView);
                this.addView(textView);
        }
 
+       public void setNode(Node node) {
+               this.node = node;
+       }
+
        public int getInitX() {
                return initX;
        }
index b7196df..3c084f0 100644 (file)
@@ -1,43 +1,70 @@
 package com.yuji.ef.dao;
 
-import java.util.ArrayList;
 import java.util.List;
 
+import android.view.View;
+import android.widget.FrameLayout;
+
 import com.yuji.ef.LabelIconView;
 
 public class Node {
-       //private Node parent = null;
+       private Node parent = null;
        protected String guid = null;
        protected String name = null;
        protected LabelIconView view = null;
        protected List<Node> children = null;
 
-       public Node(String name, LabelIconView view){
+       public Node(String name, LabelIconView view) {
                this.name = name;
                this.view = view;
+
+               if (view != null) {
+                       view.setNode(this);
+               }
+       }
+
+       public void setView(LabelIconView view) {
+               this.view = view;
+               if (view != null) {
+                       view.setNode(this);
+               }
+       }
+
+       public Node getParent() {
+               return parent;
+       }
+
+       public void setParent(Node parent) {
+               this.parent = parent;
        }
-       
+
        public List<Node> getChildren() {
                return children;
        }
-       
+
        public String getGuid() {
                return guid;
        }
-       
-       public String getName(){
+
+       public String getName() {
                return name;
        }
-       
-       public void add(Node node){
+
+       public void add(Node node) {
                children.add(node);
+               node.setParent(this);
        }
-       
+
+       public void remove(Node node) {
+               children.remove(node);
+               node.setParent(null);
+       }
+
        public LabelIconView getView() {
                return view;
        }
-       
-       public int getIconId(){
+
+       public int getIconId() {
                return -1;
        }
 }