Revision 038ac9a4 src/com/rackspacecloud/android/ListContainerActivity.java
b/src/com/rackspacecloud/android/ListContainerActivity.java | ||
---|---|---|
31 | 31 |
public class ListContainerActivity extends GaListActivity { |
32 | 32 |
|
33 | 33 |
protected static final int DELETE_ID = 0; |
34 |
|
|
34 |
|
|
35 | 35 |
private Container[] containers; |
36 | 36 |
public Container container; |
37 | 37 |
public Container cdnContainer; |
... | ... | |
42 | 42 |
public int kbConver = 1024; |
43 | 43 |
private Context context; |
44 | 44 |
private boolean loading; |
45 |
|
|
45 |
|
|
46 | 46 |
@Override |
47 | 47 |
public void onCreate(Bundle savedInstanceState) { |
48 | 48 |
super.onCreate(savedInstanceState); |
... | ... | |
59 | 59 |
} |
60 | 60 |
|
61 | 61 |
private void restoreState(Bundle state) { |
62 |
if(state != null && state.containsKey("loading") && state.getBoolean("loading")){ |
|
62 |
if (state != null && state.containsKey("loading") |
|
63 |
&& state.getBoolean("loading")) { |
|
63 | 64 |
loadContainers(); |
64 | 65 |
registerForContextMenu(getListView()); |
65 |
} |
|
66 |
else if (state != null && state.containsKey("container") && state.getSerializable("container") != null) {
|
|
66 |
} else if (state != null && state.containsKey("container")
|
|
67 |
&& state.getSerializable("container") != null) {
|
|
67 | 68 |
containers = (Container[]) state.getSerializable("container"); |
68 | 69 |
if (containers.length == 0) { |
69 | 70 |
displayNoServersCell(); |
... | ... | |
139 | 140 |
e.printStackTrace(); |
140 | 141 |
} |
141 | 142 |
} |
142 |
|
|
143 |
|
|
143 |
|
|
144 | 144 |
private class LoadContainersTask extends |
145 | 145 |
AsyncTask<Void, Void, ArrayList<Container>> { |
146 | 146 |
|
147 | 147 |
private CloudServersException exception; |
148 | 148 |
|
149 | 149 |
@Override |
150 |
protected void onPreExecute(){ |
|
150 |
protected void onPreExecute() {
|
|
151 | 151 |
loading = true; |
152 | 152 |
} |
153 |
|
|
153 |
|
|
154 | 154 |
@Override |
155 | 155 |
protected ArrayList<Container> doInBackground(Void... arg0) { |
156 | 156 |
ArrayList<Container> containers = null; |
... | ... | |
166 | 166 |
@Override |
167 | 167 |
protected void onPostExecute(ArrayList<Container> result) { |
168 | 168 |
if (exception != null) { |
169 |
Log.e("ListContainerActivity","",exception); |
|
170 |
showAlert("Error In "+ListContainerActivity.class.getName(), exception.getMessage()); |
|
169 |
Log.e("ListContainerActivity", "", exception); |
|
170 |
showAlert("Error In " + ListContainerActivity.class.getName(), |
|
171 |
exception.getMessage()); |
|
171 | 172 |
} |
172 | 173 |
ArrayList<Container> containerList = result; |
173 |
|
|
174 |
|
|
174 | 175 |
if (containerList != null) { |
175 | 176 |
containerNames = new String[containerList.size()]; |
176 | 177 |
containers = new Container[containerList.size()]; |
... | ... | |
179 | 180 |
containers[i] = container; |
180 | 181 |
containerNames[i] = container.getName(); |
181 | 182 |
} |
182 |
} |
|
183 |
else{ |
|
183 |
} else { |
|
184 | 184 |
containerNames = new String[0]; |
185 | 185 |
containers = new Container[0]; |
186 | 186 |
} |
... | ... | |
195 | 195 |
private CloudServersException exception; |
196 | 196 |
|
197 | 197 |
@Override |
198 |
protected void onPreExecute(){ |
|
198 |
protected void onPreExecute() {
|
|
199 | 199 |
loading = true; |
200 | 200 |
} |
201 |
|
|
201 |
|
|
202 | 202 |
@Override |
203 | 203 |
protected ArrayList<Container> doInBackground(Void... arg0) { |
204 | 204 |
ArrayList<Container> cdnContainers = null; |
205 | 205 |
|
206 | 206 |
try { |
207 |
cdnContainers = (new ContainerManager(context)).createCDNList(true); |
|
207 |
cdnContainers = (new ContainerManager(context)) |
|
208 |
.createCDNList(true); |
|
208 | 209 |
} catch (CloudServersException e) { |
209 | 210 |
exception = e; |
210 | 211 |
} |
... | ... | |
218 | 219 |
} |
219 | 220 |
|
220 | 221 |
ArrayList<Container> cdnContainers = result; |
221 |
Log.i("papala",cdnContainers+" ");
|
|
222 |
Log.i("papala", cdnContainers + " ");
|
|
222 | 223 |
for (int i = 0; i < containers.length; i++) { |
223 | 224 |
Container container = containers[i]; |
224 | 225 |
for (int t = 0; t < cdnContainers.size(); t++) { |
... | ... | |
248 | 249 |
switch (item.getItemId()) { |
249 | 250 |
case R.id.add_container: |
250 | 251 |
startActivityForResult( |
251 |
new Intent(this, AddContainerActivity.class), 56); // arbitrary number never used again |
|
252 |
new Intent(this, AddContainerActivity.class), 56); // arbitrary |
|
253 |
// number |
|
254 |
// never |
|
255 |
// used |
|
256 |
// again |
|
252 | 257 |
return true; |
253 | 258 |
case R.id.refresh: |
254 | 259 |
containers = null; |
... | ... | |
294 | 299 |
return (row); |
295 | 300 |
} |
296 | 301 |
} |
297 |
|
|
302 |
|
|
298 | 303 |
@Override |
299 | 304 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
300 | 305 |
super.onActivityResult(requestCode, resultCode, data); |
301 |
|
|
306 |
|
|
302 | 307 |
if (resultCode == RESULT_OK) { |
303 | 308 |
// a sub-activity kicked back, so we want to refresh the server list |
304 | 309 |
loadContainers(); |
Also available in: Unified diff