some action for fragments ui
[pub/Android/ownCloud.git] / src / eu / alefzero / owncloud / PathLayout.java
index 9d6e751..3f5a493 100644 (file)
@@ -1,5 +1,6 @@
 package eu.alefzero.owncloud;
 
+import java.util.LinkedList;
 import java.util.Stack;
 
 import android.content.Context;
@@ -12,7 +13,7 @@ import android.widget.TextView;
 
 public class PathLayout extends LinearLayout {
 
-  private Stack<String> paths;
+  private LinkedList<String> paths;
   ScrollView internalScroll;
   LinearLayout view;
 
@@ -27,7 +28,7 @@ public class PathLayout extends LinearLayout {
   }
 
   public String pop() {
-    if (paths.empty()) {
+    if (paths.size() == 0) {
       return null;
     }
     int start = paths.size()*2-2;
@@ -37,12 +38,16 @@ public class PathLayout extends LinearLayout {
       count--;
     }
     view.removeViews(start, count);
-    return paths.pop();
+    return paths.removeLast();
   }
 
+  public void addPath(String path) {
+    for (String s : path.split("/")) if (s.length() != 0) push(s);
+  }
+  
   public void push(String path) {
     // its weird that we cannot declare static imgView as path separator
-    if (!paths.empty()) {
+    if (paths.size() != 0) {
       ImageView iv = new ImageView(getContext());
       iv.setImageDrawable(getResources().getDrawable(R.drawable.breadcrumb));
       iv.setPadding(2, 0, 2, 0);
@@ -54,15 +59,23 @@ public class PathLayout extends LinearLayout {
     view.addView(tv);
     HorizontalScrollView hsv = (HorizontalScrollView) internalScroll.getChildAt(0);
     hsv.smoothScrollTo(hsv.getMaxScrollAmount()*2, 0);
-    paths.push(path);
+    paths.addLast(path);
   }
   
   public String peek() {
     return paths.peek();
   }
 
+  public String getFullPath() {
+    String ret = new String();
+    for (int i = 0; i < paths.size(); i++) {
+      ret += "/" + paths.get(i);
+    }
+    return ret;
+  }
+  
   private void initialize() {
-    paths = new Stack<String>();
+    paths = new LinkedList<String>();
     internalScroll = new ScrollView(getContext());
     internalScroll.setFillViewport(true);
     HorizontalScrollView hsv = new HorizontalScrollView(getContext());