Revision 240418be src/com/rackspacecloud/android/ContainerObjectsActivity.java
b/src/com/rackspacecloud/android/ContainerObjectsActivity.java | ||
---|---|---|
42 | 42 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
43 | 43 |
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser; |
44 | 44 |
|
45 |
/**
|
|
45 |
/** |
|
46 | 46 |
* |
47 | 47 |
* @author Phillip Toohill |
48 |
* |
|
48 |
*
|
|
49 | 49 |
*/ |
50 | 50 |
public class ContainerObjectsActivity extends ListActivity { |
51 |
|
|
52 | 51 |
|
53 | 52 |
private static final int deleteContainer = 0; |
54 | 53 |
private ContainerObjects[] files; |
... | ... | |
59 | 58 |
public Object kiloBytes; |
60 | 59 |
public int bConver = 1048576; |
61 | 60 |
public int kbConver = 1024; |
62 |
|
|
61 |
|
|
63 | 62 |
@Override |
64 |
public void onCreate(Bundle savedInstanceState) {
|
|
65 |
super.onCreate(savedInstanceState);
|
|
66 |
container = (Container) this.getIntent().getExtras().get("container");
|
|
67 |
if (container.isCdnEnabled()== true){
|
|
68 |
cdnEnabledIs = "true";
|
|
69 |
}else{
|
|
70 |
cdnEnabledIs = "false";
|
|
71 |
}
|
|
72 |
restoreState(savedInstanceState);
|
|
73 |
}
|
|
74 |
|
|
63 |
public void onCreate(Bundle savedInstanceState) {
|
|
64 |
super.onCreate(savedInstanceState);
|
|
65 |
container = (Container) this.getIntent().getExtras().get("container");
|
|
66 |
if (container.isCdnEnabled() == true) {
|
|
67 |
cdnEnabledIs = "true";
|
|
68 |
} else {
|
|
69 |
cdnEnabledIs = "false";
|
|
70 |
}
|
|
71 |
restoreState(savedInstanceState);
|
|
72 |
}
|
|
73 |
|
|
75 | 74 |
@Override |
76 | 75 |
protected void onSaveInstanceState(Bundle outState) { |
77 | 76 |
super.onSaveInstanceState(outState); |
78 | 77 |
outState.putSerializable("container", files); |
79 | 78 |
} |
80 | 79 |
|
81 |
private void restoreState(Bundle state) {
|
|
82 |
if (state != null && state.containsKey("container")) {
|
|
83 |
files = (ContainerObjects[]) state.getSerializable("container");
|
|
84 |
if (files.length == 0) {
|
|
85 |
displayNoServersCell();
|
|
86 |
} else {
|
|
87 |
getListView().setDividerHeight(1); // restore divider lines
|
|
88 |
setListAdapter(new FileAdapter());
|
|
89 |
|
|
90 |
}
|
|
91 |
} else {
|
|
92 |
loadFiles();
|
|
93 |
|
|
94 |
}
|
|
95 |
}
|
|
96 |
|
|
80 |
private void restoreState(Bundle state) {
|
|
81 |
if (state != null && state.containsKey("container")) {
|
|
82 |
files = (ContainerObjects[]) state.getSerializable("container");
|
|
83 |
if (files.length == 0) {
|
|
84 |
displayNoServersCell();
|
|
85 |
} else {
|
|
86 |
getListView().setDividerHeight(1); // restore divider lines
|
|
87 |
setListAdapter(new FileAdapter());
|
|
88 |
|
|
89 |
}
|
|
90 |
} else {
|
|
91 |
loadFiles();
|
|
92 |
|
|
93 |
}
|
|
94 |
}
|
|
95 |
|
|
97 | 96 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
98 |
if (files != null && files.length > 0) {
|
|
99 |
Intent viewIntent = new Intent(this, ContainerObjectDetails.class);
|
|
100 |
viewIntent.putExtra("container", files[position]);
|
|
101 |
viewIntent.putExtra("cdnUrl", container.getCdnUrl());
|
|
102 |
viewIntent.putExtra("containerNames", container.getName());
|
|
103 |
viewIntent.putExtra("isCdnEnabled", cdnEnabledIs);
|
|
104 |
startActivityForResult(viewIntent, 55); // arbitrary number; never used again
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
private void loadFiles() { |
|
109 |
displayLoadingCell();
|
|
110 |
new LoadFilesTask().execute((Void[]) null);
|
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
|
|
97 |
if (files != null && files.length > 0) { |
|
98 |
Intent viewIntent = new Intent(this, ContainerObjectDetails.class);
|
|
99 |
viewIntent.putExtra("container", files[position]);
|
|
100 |
viewIntent.putExtra("cdnUrl", container.getCdnUrl());
|
|
101 |
viewIntent.putExtra("containerNames", container.getName());
|
|
102 |
viewIntent.putExtra("isCdnEnabled", cdnEnabledIs);
|
|
103 |
startActivityForResult(viewIntent, 55); // arbitrary number; never
|
|
104 |
// used again
|
|
105 |
}
|
|
106 |
} |
|
107 |
|
|
108 |
private void loadFiles() {
|
|
109 |
displayLoadingCell();
|
|
110 |
new LoadFilesTask().execute((Void[]) null); |
|
111 |
|
|
112 |
} |
|
113 |
|
|
115 | 114 |
private void setFileList(ArrayList<ContainerObjects> files) { |
116 |
if (files == null) {
|
|
117 |
files = new ArrayList<ContainerObjects>();
|
|
118 |
}
|
|
119 |
String[] fileNames = new String[files.size()];
|
|
120 |
this.files = new ContainerObjects[files.size()];
|
|
121 |
|
|
122 |
if (files != null) {
|
|
115 |
if (files == null) {
|
|
116 |
files = new ArrayList<ContainerObjects>();
|
|
117 |
}
|
|
118 |
String[] fileNames = new String[files.size()];
|
|
119 |
this.files = new ContainerObjects[files.size()];
|
|
120 |
|
|
121 |
if (files != null) { |
|
123 | 122 |
for (int i = 0; i < files.size(); i++) { |
124 |
ContainerObjects file= files.get(i); |
|
123 |
ContainerObjects file = files.get(i);
|
|
125 | 124 |
this.files[i] = file; |
126 | 125 |
fileNames[i] = file.getName(); |
127 | 126 |
} |
128 | 127 |
} |
129 |
|
|
128 |
|
|
130 | 129 |
if (fileNames.length == 0) { |
131 | 130 |
displayNoServersCell(); |
132 | 131 |
} else { |
133 |
getListView().setDividerHeight(1); // restore divider lines
|
|
132 |
getListView().setDividerHeight(1); // restore divider lines |
|
134 | 133 |
setListAdapter(new FileAdapter()); |
135 | 134 |
} |
136 |
} |
|
137 |
|
|
138 |
private void displayLoadingCell() { |
|
139 |
String a[] = new String[1]; |
|
140 |
a[0] = "Loading..."; |
|
141 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.loadingcell, R.id.loading_label, a)); |
|
142 |
getListView().setTextFilterEnabled(true); |
|
143 |
getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
|
144 |
getListView().setItemsCanFocus(false); |
|
145 |
} |
|
146 |
|
|
147 |
private void displayNoServersCell() { |
|
148 |
String a[] = new String[1]; |
|
149 |
a[0] = "No Files"; |
|
150 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.noobjectscell, R.id.no_files_label, a)); |
|
151 |
getListView().setTextFilterEnabled(true); |
|
152 |
getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
|
153 |
getListView().setItemsCanFocus(false); |
|
154 |
} |
|
155 |
|
|
156 |
private void showAlert(String title, String message) { |
|
157 |
//Can't create handler inside thread that has not called Looper.prepare() |
|
158 |
//Looper.prepare(); |
|
159 |
try { |
|
160 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
|
161 |
alert.setTitle(title); |
|
162 |
alert.setMessage(message); |
|
163 |
alert.setButton("OK", new DialogInterface.OnClickListener() { |
|
164 |
public void onClick(DialogInterface dialog, int which) { |
|
165 |
return; |
|
166 |
} }); |
|
167 |
alert.show(); |
|
168 |
} catch (Exception e) { |
|
169 |
e.printStackTrace(); |
|
170 |
} |
|
171 |
} |
|
172 |
|
|
173 |
|
|
174 |
private class LoadFilesTask extends AsyncTask<Void, Void, ArrayList<ContainerObjects>> { |
|
175 |
|
|
176 |
private CloudServersException exception; |
|
177 |
|
|
135 |
} |
|
136 |
|
|
137 |
private void displayLoadingCell() { |
|
138 |
String a[] = new String[1]; |
|
139 |
a[0] = "Loading..."; |
|
140 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.loadingcell, |
|
141 |
R.id.loading_label, a)); |
|
142 |
getListView().setTextFilterEnabled(true); |
|
143 |
getListView().setDividerHeight(0); // hide the dividers so it won't look |
|
144 |
// like a list row |
|
145 |
getListView().setItemsCanFocus(false); |
|
146 |
} |
|
147 |
|
|
148 |
private void displayNoServersCell() { |
|
149 |
String a[] = new String[1]; |
|
150 |
a[0] = "No Files"; |
|
151 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.noobjectscell, |
|
152 |
R.id.no_files_label, a)); |
|
153 |
getListView().setTextFilterEnabled(true); |
|
154 |
getListView().setDividerHeight(0); // hide the dividers so it won't look |
|
155 |
// like a list row |
|
156 |
getListView().setItemsCanFocus(false); |
|
157 |
} |
|
158 |
|
|
159 |
private void showAlert(String title, String message) { |
|
160 |
// Can't create handler inside thread that has not called |
|
161 |
// Looper.prepare() |
|
162 |
// Looper.prepare(); |
|
163 |
try { |
|
164 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
|
165 |
alert.setTitle(title); |
|
166 |
alert.setMessage(message); |
|
167 |
alert.setButton("OK", new DialogInterface.OnClickListener() { |
|
168 |
public void onClick(DialogInterface dialog, int which) { |
|
169 |
return; |
|
170 |
} |
|
171 |
}); |
|
172 |
alert.show(); |
|
173 |
} catch (Exception e) { |
|
174 |
e.printStackTrace(); |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
private class LoadFilesTask extends |
|
179 |
AsyncTask<Void, Void, ArrayList<ContainerObjects>> { |
|
180 |
|
|
181 |
private CloudServersException exception; |
|
182 |
|
|
178 | 183 |
@Override |
179 | 184 |
protected ArrayList<ContainerObjects> doInBackground(Void... arg0) { |
180 | 185 |
ArrayList<ContainerObjects> files = null; |
181 | 186 |
try { |
182 |
files = (new ContainerObjectManager()).createList(true, container.getName()); |
|
187 |
files = (new ContainerObjectManager()).createList(true, |
|
188 |
container.getName()); |
|
183 | 189 |
} catch (CloudServersException e) { |
184 | 190 |
exception = e; |
185 | 191 |
e.printStackTrace(); |
186 | 192 |
} |
187 | 193 |
return files; |
188 | 194 |
} |
189 |
|
|
195 |
|
|
190 | 196 |
@Override |
191 | 197 |
protected void onPostExecute(ArrayList<ContainerObjects> result) { |
192 | 198 |
if (exception != null) { |
193 | 199 |
showAlert("Error", exception.getMessage()); |
194 |
}
|
|
200 |
} |
|
195 | 201 |
setFileList(result); |
196 | 202 |
} |
197 |
} |
|
198 |
class FileAdapter extends ArrayAdapter<ContainerObjects> { |
|
203 |
} |
|
204 |
|
|
205 |
class FileAdapter extends ArrayAdapter<ContainerObjects> { |
|
199 | 206 |
FileAdapter() { |
200 |
super(ContainerObjectsActivity.this, R.layout.listcontainerobjectcell, files); |
|
207 |
super(ContainerObjectsActivity.this, |
|
208 |
R.layout.listcontainerobjectcell, files); |
|
201 | 209 |
} |
202 |
|
|
210 |
|
|
203 | 211 |
public View getView(int position, View convertView, ViewGroup parent) { |
204 |
|
|
212 |
|
|
205 | 213 |
ContainerObjects file = files[position]; |
206 | 214 |
LayoutInflater inflater = getLayoutInflater(); |
207 |
View row = inflater.inflate(R.layout.listcontainerobjectcell, parent, false); |
|
215 |
View row = inflater.inflate(R.layout.listcontainerobjectcell, |
|
216 |
parent, false); |
|
208 | 217 |
|
209 | 218 |
TextView label = (TextView) row.findViewById(R.id.label); |
210 | 219 |
label.setText(file.getCName()); |
211 |
|
|
212 | 220 |
|
213 | 221 |
if (file.getBytes() >= bConver) { |
214 |
megaBytes = Math.abs(file.getBytes()/bConver + 0.2);
|
|
215 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel);
|
|
216 |
sublabel.setText(megaBytes + " MB");
|
|
217 |
} else if (file.getBytes() >= kbConver){ |
|
218 |
kiloBytes = Math.abs(file.getBytes()/kbConver + 0.2);
|
|
219 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel);
|
|
220 |
sublabel.setText(kiloBytes + " KB");
|
|
222 |
megaBytes = Math.abs(file.getBytes() / bConver + 0.2);
|
|
223 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
|
224 |
sublabel.setText(megaBytes + " MB"); |
|
225 |
} else if (file.getBytes() >= kbConver) {
|
|
226 |
kiloBytes = Math.abs(file.getBytes() / kbConver + 0.2);
|
|
227 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
|
228 |
sublabel.setText(kiloBytes + " KB"); |
|
221 | 229 |
} else { |
222 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel);
|
|
223 |
sublabel.setText( file.getBytes() + " B");
|
|
230 |
TextView sublabel = (TextView) row.findViewById(R.id.sublabel); |
|
231 |
sublabel.setText(file.getBytes() + " B");
|
|
224 | 232 |
} |
225 |
|
|
226 |
return(row); |
|
233 |
|
|
234 |
return (row);
|
|
227 | 235 |
} |
228 |
}
|
|
229 |
|
|
230 |
//Create the Menu options
|
|
231 |
@Override
|
|
232 |
public boolean onCreateOptionsMenu(Menu menu) {
|
|
236 |
} |
|
237 |
|
|
238 |
// Create the Menu options
|
|
239 |
@Override
|
|
240 |
public boolean onCreateOptionsMenu(Menu menu) {
|
|
233 | 241 |
super.onCreateOptionsMenu(menu); |
234 | 242 |
MenuInflater inflater = getMenuInflater(); |
235 | 243 |
inflater.inflate(R.menu.view_container_object_list_menu, menu); |
236 | 244 |
return true; |
237 |
}
|
|
238 |
|
|
239 |
@Override
|
|
240 |
public boolean onOptionsItemSelected(MenuItem item) {
|
|
245 |
} |
|
246 |
|
|
247 |
@Override
|
|
248 |
public boolean onOptionsItemSelected(MenuItem item) {
|
|
241 | 249 |
switch (item.getItemId()) { |
242 | 250 |
case R.id.delete_container: |
243 | 251 |
showDialog(deleteContainer); |
244 | 252 |
return true; |
245 | 253 |
case R.id.enable_cdn: |
246 | 254 |
Intent viewIntent1 = new Intent(this, EnableCDNActivity.class); |
247 |
viewIntent1.putExtra("Cname", container.getName());
|
|
248 |
startActivityForResult(viewIntent1, 55);
|
|
255 |
viewIntent1.putExtra("Cname", container.getName());
|
|
256 |
startActivityForResult(viewIntent1, 56);
|
|
249 | 257 |
return true; |
250 | 258 |
case R.id.refresh: |
251 | 259 |
loadFiles(); |
252 |
return true;
|
|
260 |
return true;
|
|
253 | 261 |
} |
254 | 262 |
return false; |
255 |
} |
|
256 |
@Override |
|
257 |
protected Dialog onCreateDialog(int id ) { |
|
258 |
switch (id) { |
|
259 |
case deleteContainer: |
|
260 |
return new AlertDialog.Builder(ContainerObjectsActivity.this) |
|
261 |
.setIcon(R.drawable.alert_dialog_icon) |
|
262 |
.setTitle("Delete Container") |
|
263 |
.setMessage("Are you sure you want to delete this Container?") |
|
264 |
.setPositiveButton("Delete Container", new DialogInterface.OnClickListener() { |
|
265 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
266 |
// User clicked OK so do some stuff |
|
267 |
new DeleteContainerTask().execute((Void[]) null); |
|
268 |
} |
|
269 |
}) |
|
270 |
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { |
|
271 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
272 |
// User clicked Cancel so do some stuff |
|
273 |
} |
|
274 |
}) |
|
275 |
.create(); |
|
276 |
|
|
277 |
} |
|
278 |
return null; |
|
279 |
} |
|
263 |
} |
|
264 |
|
|
280 | 265 |
@Override |
281 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
|
282 |
super.onActivityResult(requestCode, resultCode, data); |
|
283 |
|
|
284 |
if (resultCode == RESULT_OK) { |
|
285 |
// a sub-activity kicked back, so we want to refresh the server list |
|
286 |
loadFiles(); |
|
287 |
|
|
288 |
} |
|
266 |
protected Dialog onCreateDialog(int id) { |
|
267 |
switch (id) { |
|
268 |
case deleteContainer: |
|
269 |
return new AlertDialog.Builder(ContainerObjectsActivity.this) |
|
270 |
.setIcon(R.drawable.alert_dialog_icon) |
|
271 |
.setTitle("Delete Container") |
|
272 |
.setMessage( |
|
273 |
"Are you sure you want to delete this Container?") |
|
274 |
.setPositiveButton("Delete Container", |
|
275 |
new DialogInterface.OnClickListener() { |
|
276 |
public void onClick(DialogInterface dialog, |
|
277 |
int whichButton) { |
|
278 |
// User clicked OK so do some stuff |
|
279 |
new DeleteContainerTask() |
|
280 |
.execute((Void[]) null); |
|
281 |
} |
|
282 |
}) |
|
283 |
.setNegativeButton("Cancel", |
|
284 |
new DialogInterface.OnClickListener() { |
|
285 |
public void onClick(DialogInterface dialog, |
|
286 |
int whichButton) { |
|
287 |
// User clicked Cancel so do some stuff |
|
288 |
} |
|
289 |
}).create(); |
|
290 |
|
|
291 |
} |
|
292 |
return null; |
|
289 | 293 |
} |
290 | 294 |
|
291 |
private CloudServersException parseCloudServersException(HttpResponse response) { |
|
292 |
CloudServersException cse = new CloudServersException(); |
|
293 |
try { |
|
294 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
295 |
String body = responseHandler.handleResponse(response); |
|
296 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
297 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
298 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
299 |
xmlReader.setContentHandler(parser); |
|
300 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
301 |
cse = parser.getException(); |
|
302 |
} catch (ClientProtocolException e) { |
|
303 |
cse = new CloudServersException(); |
|
304 |
cse.setMessage(e.getLocalizedMessage()); |
|
305 |
} catch (IOException e) { |
|
306 |
cse = new CloudServersException(); |
|
307 |
cse.setMessage(e.getLocalizedMessage()); |
|
308 |
} catch (ParserConfigurationException e) { |
|
309 |
cse = new CloudServersException(); |
|
310 |
cse.setMessage(e.getLocalizedMessage()); |
|
311 |
} catch (SAXException e) { |
|
312 |
cse = new CloudServersException(); |
|
313 |
cse.setMessage(e.getLocalizedMessage()); |
|
314 |
} catch (FactoryConfigurationError e) { |
|
315 |
cse = new CloudServersException(); |
|
316 |
cse.setMessage(e.getLocalizedMessage()); |
|
295 |
@Override |
|
296 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
|
297 |
super.onActivityResult(requestCode, resultCode, data); |
|
298 |
|
|
299 |
if (resultCode == RESULT_OK) { |
|
300 |
// a sub-activity kicked back, so we want to refresh the server list |
|
301 |
loadFiles(); |
|
302 |
} |
|
303 |
if (requestCode == 56) { |
|
304 |
if (resultCode == RESULT_OK) { |
|
305 |
Intent viewIntent1 = new Intent(this, ListContainerActivity.class); |
|
306 |
startActivityForResult(viewIntent1, 56); |
|
317 | 307 |
} |
318 |
return cse; |
|
319 |
} |
|
320 |
private class DeleteContainerTask extends AsyncTask<Void, Void, HttpResponse> { |
|
321 |
|
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
private CloudServersException parseCloudServersException( |
|
312 |
HttpResponse response) { |
|
313 |
CloudServersException cse = new CloudServersException(); |
|
314 |
try { |
|
315 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
316 |
String body = responseHandler.handleResponse(response); |
|
317 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
318 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
319 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
320 |
xmlReader.setContentHandler(parser); |
|
321 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
322 |
cse = parser.getException(); |
|
323 |
} catch (ClientProtocolException e) { |
|
324 |
cse = new CloudServersException(); |
|
325 |
cse.setMessage(e.getLocalizedMessage()); |
|
326 |
} catch (IOException e) { |
|
327 |
cse = new CloudServersException(); |
|
328 |
cse.setMessage(e.getLocalizedMessage()); |
|
329 |
} catch (ParserConfigurationException e) { |
|
330 |
cse = new CloudServersException(); |
|
331 |
cse.setMessage(e.getLocalizedMessage()); |
|
332 |
} catch (SAXException e) { |
|
333 |
cse = new CloudServersException(); |
|
334 |
cse.setMessage(e.getLocalizedMessage()); |
|
335 |
} catch (FactoryConfigurationError e) { |
|
336 |
cse = new CloudServersException(); |
|
337 |
cse.setMessage(e.getLocalizedMessage()); |
|
338 |
} |
|
339 |
return cse; |
|
340 |
} |
|
341 |
|
|
342 |
private class DeleteContainerTask extends |
|
343 |
AsyncTask<Void, Void, HttpResponse> { |
|
344 |
|
|
322 | 345 |
private CloudServersException exception; |
323 | 346 |
|
324 | 347 |
@Override |
... | ... | |
332 | 355 |
} |
333 | 356 |
return resp; |
334 | 357 |
} |
335 |
|
|
358 |
|
|
336 | 359 |
@Override |
337 |
protected void onPostExecute(HttpResponse response) {
|
|
360 |
protected void onPostExecute(HttpResponse response) { |
|
338 | 361 |
if (response != null) { |
339 | 362 |
int statusCode = response.getStatusLine().getStatusCode(); |
340 | 363 |
if (statusCode == 409) { |
341 |
showAlert("Error", "Container must be empty in order to delete"); |
|
364 |
showAlert("Error", |
|
365 |
"Container must be empty in order to delete"); |
|
342 | 366 |
} |
343 | 367 |
if (statusCode == 204) { |
344 | 368 |
setResult(Activity.RESULT_OK); |
345 | 369 |
finish(); |
346 |
|
|
370 |
|
|
347 | 371 |
} else { |
348 | 372 |
CloudServersException cse = parseCloudServersException(response); |
349 | 373 |
if ("".equals(cse.getMessage())) { |
350 |
showAlert("Error", "There was a problem deleting your container."); |
|
374 |
showAlert("Error", |
|
375 |
"There was a problem deleting your container."); |
|
351 | 376 |
} else { |
352 |
showAlert("Error", "There was a problem deleting your container: " + cse.getMessage()); |
|
377 |
showAlert("Error", |
|
378 |
"There was a problem deleting your container: " |
|
379 |
+ cse.getMessage()); |
|
353 | 380 |
} |
354 | 381 |
} |
355 | 382 |
} else if (exception != null) { |
356 |
showAlert("Error", "There was a problem deleting your server: " + exception.getMessage()); |
|
357 |
} |
|
383 |
showAlert("Error", "There was a problem deleting your server: " |
|
384 |
+ exception.getMessage()); |
|
385 |
} |
|
358 | 386 |
} |
359 |
}
|
|
387 |
}
|
|
360 | 388 |
|
361 |
|
|
362 | 389 |
} |
363 |
|
|
364 |
|
Also available in: Unified diff