root / src / com / rackspace / cloud / android / PithosMySharedActivity.java @ 1634500c
History | View | Annotate | Download (2.1 kB)
1 |
package com.rackspace.cloud.android; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import android.util.Log; |
6 |
|
7 |
import com.rackspace.cloud.android.ContainerObjectsActivity.FileAdapter; |
8 |
import com.rackspace.cloud.files.api.client.Container; |
9 |
import com.rackspace.cloud.files.api.client.ContainerObjects; |
10 |
|
11 |
public class PithosMySharedActivity extends ContainerObjectsActivity{ |
12 |
|
13 |
@Override
|
14 |
protected Container getContainer() { |
15 |
Container myShared = new Container(); |
16 |
myShared.setName(Container.MYSHARED);
|
17 |
return myShared;
|
18 |
} |
19 |
|
20 |
|
21 |
/* load only the files that should display for the
|
22 |
* current directory in the curDirFiles[]
|
23 |
*/
|
24 |
protected void loadCurrentDirectoryFiles(){ |
25 |
ArrayList<ContainerObjects> curFiles = new ArrayList<ContainerObjects>(); |
26 |
Log.i(LOG,"loading files");
|
27 |
ContainerObjects[] files = getFiles();
|
28 |
if(files != null){ |
29 |
for(int i = 0 ; i < files.length; i ++){ |
30 |
Log.i(LOG,"loading files"+i);
|
31 |
if(fileBelongsInDir(files[i])){
|
32 |
curFiles.add(files[i]); |
33 |
} |
34 |
} |
35 |
AndroidCloudApplication app = (AndroidCloudApplication)this.getApplication();
|
36 |
app.setCurFiles(curFiles); |
37 |
} |
38 |
} |
39 |
|
40 |
/*
|
41 |
* determines if a file should be displayed in current
|
42 |
* directory
|
43 |
*/
|
44 |
protected Boolean fileBelongsInDir(ContainerObjects obj){ |
45 |
String objPath = obj.getCName();
|
46 |
String currentPath = getCurrentPath();
|
47 |
if(!objPath.startsWith(currentPath)){
|
48 |
Log.i(LOG,"Path is:"+currentPath+" "+objPath+" "+false); |
49 |
return false; |
50 |
} |
51 |
else if(objPath.endsWith("/")){ |
52 |
return true; |
53 |
} |
54 |
else{
|
55 |
objPath = objPath.substring(currentPath.length()); |
56 |
Log.i(LOG,"Path is:"+currentPath+" "+objPath+" "+!objPath.contains("/")); |
57 |
return !objPath.contains("/"); |
58 |
} |
59 |
} |
60 |
|
61 |
protected void displayCurrentFiles(){ |
62 |
AndroidCloudApplication app = (AndroidCloudApplication)this.getApplication();
|
63 |
if (app.getCurFiles().size() == 0) { |
64 |
displayNoFilesCell(); |
65 |
} else {
|
66 |
ArrayList<ContainerObjects> tempList = new ArrayList<ContainerObjects>(); |
67 |
for(int i = 0; i < app.getCurFiles().size(); i++){ |
68 |
tempList.add(app.getCurFiles().get(i)); |
69 |
} |
70 |
getListView().setDividerHeight(1); // restore divider lines |
71 |
setListAdapter(new FileAdapter());
|
72 |
} |
73 |
} |
74 |
|
75 |
|
76 |
} |