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);
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);
}
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);
// 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();
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;
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>();
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) {
list.remove(child);
}
+ public void removeAllViews(){
+ super.removeAllViews();
+ list.clear();
+ }
+
public void moveTop(LabelIconView child){
this.removeView(child);
this.addView(child);
}
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);
+ 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);
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;
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();
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;
}
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;
}
}