root / src / com / rackspace / cloud / android / PithosOthersActivity.java @ db9092dd
History | View | Annotate | Download (2.1 kB)
1 |
package com.rackspace.cloud.android; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.List; |
5 |
|
6 |
import android.os.Bundle; |
7 |
import android.view.Menu; |
8 |
import android.view.MenuInflater; |
9 |
|
10 |
import com.rackspace.cloud.android.ListContainerActivity.FileAdapter; |
11 |
import com.rackspace.cloud.files.api.client.Container; |
12 |
import com.rackspace.cloud.files.api.client.ContainerManager; |
13 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
14 |
|
15 |
public class PithosOthersActivity extends ListContainerActivity{ |
16 |
@Override
|
17 |
public void onCreate(Bundle savedInstanceState) { |
18 |
super.onCreate(savedInstanceState);
|
19 |
trackPageView(GoogleAnalytics.PAGE_CONTAINERS); |
20 |
context = getApplicationContext(); |
21 |
restoreState(savedInstanceState); |
22 |
} |
23 |
|
24 |
@Override
|
25 |
protected void onSaveInstanceState(Bundle outState) { |
26 |
super.onSaveInstanceState(outState);
|
27 |
outState.putSerializable("container", containers);
|
28 |
outState.putBoolean("loading", loading);
|
29 |
} |
30 |
|
31 |
private void restoreState(Bundle state) { |
32 |
if (state != null && state.containsKey("loading") |
33 |
&& state.getBoolean("loading")) {
|
34 |
loadContainers(); |
35 |
registerForContextMenu(getListView()); |
36 |
} else if (state != null && state.containsKey("container") |
37 |
&& state.getSerializable("container") != null) { |
38 |
containers = (Container[]) state.getSerializable("container"); |
39 |
if (containers.length == 0) { |
40 |
displayNoServersCell(); |
41 |
} else {
|
42 |
getListView().setDividerHeight(1); // restore divider lines |
43 |
setListAdapter(new FileAdapter());
|
44 |
} |
45 |
} else {
|
46 |
loadContainers(); |
47 |
registerForContextMenu(getListView()); |
48 |
} |
49 |
} |
50 |
@Override
|
51 |
public boolean onCreateOptionsMenu(Menu menu) { |
52 |
super.onCreateOptionsMenu(menu);
|
53 |
menu.findItem(R.id.add_container).setVisible(false);
|
54 |
return true; |
55 |
} |
56 |
protected ArrayList<Container> loadContainersInner() throws CloudServersException{ |
57 |
ArrayList<Container> result = new ArrayList<Container>(); |
58 |
List<String> users = ((AndroidCloudApplication)getContext().getApplicationContext()).getOthers(); |
59 |
for(String u :users){ |
60 |
ArrayList<Container> c = (new ContainerManager(getContext())).createOthersList(u,true); |
61 |
result.addAll(c); |
62 |
} |
63 |
return result;
|
64 |
} |
65 |
} |