Revision b6fa6007
b/AndroidManifest.xml | ||
---|---|---|
79 | 79 |
|
80 | 80 |
|
81 | 81 |
</application> |
82 |
<uses-sdk android:minSdkVersion="2" />
|
|
82 |
<uses-sdk android:minSdkVersion="4" />
|
|
83 | 83 |
|
84 | 84 |
<uses-permission android:name="android.permission.INTERNET"></uses-permission> |
85 | 85 |
</manifest> |
b/src/com/rackspacecloud/android/ContainerObjectDetails.java | ||
---|---|---|
1 |
package com.rackspacecloud.android; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
|
|
6 |
import javax.xml.parsers.FactoryConfigurationError; |
|
7 |
import javax.xml.parsers.ParserConfigurationException; |
|
8 |
import javax.xml.parsers.SAXParser; |
|
9 |
import javax.xml.parsers.SAXParserFactory; |
|
10 |
|
|
11 |
import org.apache.http.HttpResponse; |
|
12 |
import org.apache.http.client.ClientProtocolException; |
|
13 |
import org.apache.http.impl.client.BasicResponseHandler; |
|
14 |
import org.xml.sax.InputSource; |
|
15 |
import org.xml.sax.SAXException; |
|
16 |
import org.xml.sax.XMLReader; |
|
17 |
|
|
18 |
import android.app.Activity; |
|
19 |
import android.app.AlertDialog; |
|
20 |
import android.app.Dialog; |
|
21 |
import android.content.DialogInterface; |
|
22 |
import android.content.Intent; |
|
23 |
import android.net.Uri; |
|
24 |
import android.os.AsyncTask; |
|
25 |
import android.os.Bundle; |
|
26 |
import android.util.Log; |
|
27 |
import android.view.Menu; |
|
28 |
import android.view.MenuInflater; |
|
29 |
import android.view.MenuItem; |
|
30 |
import android.view.View; |
|
31 |
import android.widget.Button; |
|
32 |
import android.widget.TextView; |
|
33 |
|
|
34 |
import com.rackspace.cloud.files.api.client.ContainerObjectManager; |
|
35 |
import com.rackspace.cloud.files.api.client.ContainerObjects; |
|
36 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
|
37 |
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
* @author Phillip Toohill |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
public class ContainerObjectDetails extends Activity { |
|
47 |
|
|
48 |
private static final int deleteObject = 0; |
|
49 |
private ContainerObjects objects; |
|
50 |
private String containerNames; |
|
51 |
private String cdnURL; |
|
52 |
private String cdnEnabled; |
|
53 |
public String LOG = "ViewObject"; |
|
54 |
private int bConver = 1048576; |
|
55 |
private int kbConver = 1024; |
|
56 |
private double megaBytes; |
|
57 |
private double kiloBytes; |
|
58 |
public Button previewButton; |
|
59 |
|
|
60 |
/** Called when the activity is first created. */ |
|
61 |
@Override |
|
62 |
public void onCreate(Bundle savedInstanceState) { |
|
63 |
super.onCreate(savedInstanceState); |
|
64 |
|
|
65 |
objects = (ContainerObjects) this.getIntent().getExtras().get("container"); |
|
66 |
containerNames = (String) this.getIntent().getExtras().get("containerNames"); |
|
67 |
cdnURL = (String) this.getIntent().getExtras().get("cdnUrl"); |
|
68 |
cdnEnabled = (String) this.getIntent().getExtras().get("isCdnEnabled"); |
|
69 |
|
|
70 |
|
|
71 |
setContentView(R.layout.viewobject); |
|
72 |
restoreState(savedInstanceState); |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
protected void onSaveInstanceState(Bundle outState) { |
|
78 |
super.onSaveInstanceState(outState); |
|
79 |
outState.putSerializable("container", objects); |
|
80 |
} |
|
81 |
|
|
82 |
private void restoreState(Bundle state) { |
|
83 |
if (state != null && state.containsKey("container")) { |
|
84 |
objects = (ContainerObjects) state.getSerializable("container"); |
|
85 |
} |
|
86 |
loadObjectData(); |
|
87 |
|
|
88 |
if ( cdnEnabled.equals("true")) { |
|
89 |
this.previewButton = (Button) findViewById(R.id.preview_button); |
|
90 |
previewButton.setOnClickListener(new MyOnClickListener()); |
|
91 |
} else { |
|
92 |
this.previewButton = (Button) findViewById(R.id.preview_button); |
|
93 |
previewButton.setVisibility(View.GONE); |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
private void loadObjectData() { |
|
101 |
TextView name = (TextView) findViewById(R.id.view_container_name); |
|
102 |
name.setText(objects.getCName().toString()); |
|
103 |
|
|
104 |
if (objects.getBytes() >= bConver) { |
|
105 |
megaBytes = Math.abs(objects.getBytes()/bConver + 0.2); |
|
106 |
TextView sublabel = (TextView) findViewById(R.id.view_file_bytes); |
|
107 |
sublabel.setText(megaBytes + " MB"); |
|
108 |
} else if (objects.getBytes() >= kbConver){ |
|
109 |
kiloBytes = Math.abs(objects.getBytes()/kbConver + 0.2); |
|
110 |
TextView sublabel = (TextView) findViewById(R.id.view_file_bytes); |
|
111 |
sublabel.setText(kiloBytes + " KB"); |
|
112 |
} else { |
|
113 |
TextView sublabel = (TextView) findViewById(R.id.view_file_bytes); |
|
114 |
sublabel.setText(objects.getBytes() + " B"); |
|
115 |
} |
|
116 |
|
|
117 |
TextView cType = (TextView) findViewById(R.id.view_content_type); |
|
118 |
cType.setText(objects.getContentType().toString()); |
|
119 |
|
|
120 |
TextView lastmod = (TextView) findViewById(R.id.view_file_modification); |
|
121 |
lastmod.setText(objects.getLastMod().toString()); |
|
122 |
|
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
private class MyOnClickListener implements View.OnClickListener { |
|
127 |
@Override |
|
128 |
public void onClick(View v) { |
|
129 |
Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse(cdnURL + "/" + objects.getCName())); |
|
130 |
startActivity(viewIntent); |
|
131 |
|
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
private void showAlert(String title, String message) { |
|
136 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
|
137 |
alert.setTitle(title); |
|
138 |
alert.setMessage(message); |
|
139 |
alert.setButton("OK", new DialogInterface.OnClickListener() { |
|
140 |
public void onClick(DialogInterface dialog, int which) { |
|
141 |
return; |
|
142 |
} }); |
|
143 |
alert.show(); |
|
144 |
} |
|
145 |
//Create the Menu options |
|
146 |
@Override |
|
147 |
public boolean onCreateOptionsMenu(Menu menu) { |
|
148 |
super.onCreateOptionsMenu(menu); |
|
149 |
MenuInflater inflater = getMenuInflater(); |
|
150 |
inflater.inflate(R.menu.container_object_list_menu, menu); |
|
151 |
return true; |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public boolean onOptionsItemSelected(MenuItem item) { |
|
156 |
switch (item.getItemId()) { |
|
157 |
case R.id.delete_object: |
|
158 |
showDialog(deleteObject); |
|
159 |
return true; |
|
160 |
case R.id.refresh: |
|
161 |
loadObjectData(); |
|
162 |
return true; |
|
163 |
} |
|
164 |
return false; |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
protected Dialog onCreateDialog(int id ) { |
|
169 |
switch (id) { |
|
170 |
case deleteObject: |
|
171 |
return new AlertDialog.Builder(ContainerObjectDetails.this) |
|
172 |
.setIcon(R.drawable.alert_dialog_icon) |
|
173 |
.setTitle("Delete File") |
|
174 |
.setMessage("Are you sure you want to delete this file?") |
|
175 |
.setPositiveButton("Delete File", new DialogInterface.OnClickListener() { |
|
176 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
177 |
// User clicked OK so do some stuff |
|
178 |
new ContainerObjectDeleteTask().execute((Void[]) null); |
|
179 |
} |
|
180 |
}) |
|
181 |
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { |
|
182 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
183 |
// User clicked Cancel so do some stuff |
|
184 |
} |
|
185 |
}) |
|
186 |
.create(); |
|
187 |
} |
|
188 |
return null; |
|
189 |
} |
|
190 |
/** |
|
191 |
* @return the file |
|
192 |
*/ |
|
193 |
public ContainerObjects getViewFile() { |
|
194 |
return objects; |
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* @param File the file to set |
|
199 |
*/ |
|
200 |
public void setViewFile(ContainerObjects object) { |
|
201 |
this.objects = object; |
|
202 |
} |
|
203 |
|
|
204 |
//Task's |
|
205 |
|
|
206 |
private CloudServersException parseCloudServersException(HttpResponse response) { |
|
207 |
CloudServersException cse = new CloudServersException(); |
|
208 |
try { |
|
209 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
210 |
String body = responseHandler.handleResponse(response); |
|
211 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
212 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
213 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
214 |
xmlReader.setContentHandler(parser); |
|
215 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
216 |
cse = parser.getException(); |
|
217 |
} catch (ClientProtocolException e) { |
|
218 |
cse = new CloudServersException(); |
|
219 |
cse.setMessage(e.getLocalizedMessage()); |
|
220 |
} catch (IOException e) { |
|
221 |
cse = new CloudServersException(); |
|
222 |
cse.setMessage(e.getLocalizedMessage()); |
|
223 |
} catch (ParserConfigurationException e) { |
|
224 |
cse = new CloudServersException(); |
|
225 |
cse.setMessage(e.getLocalizedMessage()); |
|
226 |
} catch (SAXException e) { |
|
227 |
cse = new CloudServersException(); |
|
228 |
cse.setMessage(e.getLocalizedMessage()); |
|
229 |
} catch (FactoryConfigurationError e) { |
|
230 |
cse = new CloudServersException(); |
|
231 |
cse.setMessage(e.getLocalizedMessage()); |
|
232 |
} |
|
233 |
return cse; |
|
234 |
} |
|
235 |
|
|
236 |
private class ContainerObjectDeleteTask extends AsyncTask<Void, Void, HttpResponse> { |
|
237 |
|
|
238 |
private CloudServersException exception; |
|
239 |
|
|
240 |
@Override |
|
241 |
protected HttpResponse doInBackground(Void... arg0) { |
|
242 |
HttpResponse resp = null; |
|
243 |
try { |
|
244 |
resp = (new ContainerObjectManager()).deleteObject(containerNames, objects.getCName() ); |
|
245 |
Log.v(LOG, "container name " + objects.getCName() + " " + containerNames); |
|
246 |
} catch (CloudServersException e) { |
|
247 |
exception = e; |
|
248 |
} |
|
249 |
return resp; |
|
250 |
} |
|
251 |
|
|
252 |
@Override |
|
253 |
protected void onPostExecute(HttpResponse response) { |
|
254 |
if (response != null) { |
|
255 |
int statusCode = response.getStatusLine().getStatusCode(); |
|
256 |
if (statusCode == 204) { |
|
257 |
setResult(Activity.RESULT_OK); |
|
258 |
finish(); |
|
259 |
|
|
260 |
} else { |
|
261 |
CloudServersException cse = parseCloudServersException(response); |
|
262 |
if ("".equals(cse.getMessage())) { |
|
263 |
showAlert("Error", "There was a problem deleting your File."); |
|
264 |
} else { |
|
265 |
showAlert("Error", "There was a problem deleting your file: " + cse.getMessage()); |
|
266 |
} |
|
267 |
} |
|
268 |
} else if (exception != null) { |
|
269 |
showAlert("Error", "There was a problem deleting your file: " + exception.getMessage()); |
|
270 |
} |
|
271 |
} |
|
272 |
} |
|
273 |
|
|
274 |
} |
b/src/com/rackspacecloud/android/ContainerObjectsActivity.java | ||
---|---|---|
96 | 96 |
|
97 | 97 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
98 | 98 |
if (files != null && files.length > 0) { |
99 |
Intent viewIntent = new Intent(this, ContainerObjectsDetails.class);
|
|
99 |
Intent viewIntent = new Intent(this, ContainerObjectDetails.class); |
|
100 | 100 |
viewIntent.putExtra("container", files[position]); |
101 | 101 |
viewIntent.putExtra("cdnUrl", container.getCdnUrl()); |
102 | 102 |
viewIntent.putExtra("containerNames", container.getName()); |
/dev/null | ||
---|---|---|
1 |
package com.rackspacecloud.android; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
|
|
6 |
import javax.xml.parsers.FactoryConfigurationError; |
|
7 |
import javax.xml.parsers.ParserConfigurationException; |
|
8 |
import javax.xml.parsers.SAXParser; |
|
9 |
import javax.xml.parsers.SAXParserFactory; |
|
10 |
|
|
11 |
import org.apache.http.HttpResponse; |
|
12 |
import org.apache.http.client.ClientProtocolException; |
|
13 |
import org.apache.http.impl.client.BasicResponseHandler; |
|
14 |
import org.xml.sax.InputSource; |
|
15 |
import org.xml.sax.SAXException; |
|
16 |
import org.xml.sax.XMLReader; |
|
17 |
|
|
18 |
import android.app.Activity; |
|
19 |
import android.app.AlertDialog; |
|
20 |
import android.app.Dialog; |
|
21 |
import android.content.DialogInterface; |
|
22 |
import android.content.Intent; |
|
23 |
import android.net.Uri; |
|
24 |
import android.os.AsyncTask; |
|
25 |
import android.os.Bundle; |
|
26 |
import android.util.Log; |
|
27 |
import android.view.Menu; |
|
28 |
import android.view.MenuInflater; |
|
29 |
import android.view.MenuItem; |
|
30 |
import android.view.View; |
|
31 |
import android.widget.Button; |
|
32 |
import android.widget.TextView; |
|
33 |
|
|
34 |
import com.rackspace.cloud.files.api.client.ContainerObjectManager; |
|
35 |
import com.rackspace.cloud.files.api.client.ContainerObjects; |
|
36 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
|
37 |
import com.rackspace.cloud.servers.api.client.parsers.CloudServersFaultXMLParser; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
* @author Phillip Toohill |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
public class ContainerObjectsDetails extends Activity { |
|
47 |
|
|
48 |
private static final int deleteObject = 0; |
|
49 |
private ContainerObjects objects; |
|
50 |
private String containerNames; |
|
51 |
private String cdnURL; |
|
52 |
private String cdnEnabled; |
|
53 |
public String LOG = "ViewObject"; |
|
54 |
private int bConver = 1048576; |
|
55 |
private int kbConver = 1024; |
|
56 |
private double megaBytes; |
|
57 |
private double kiloBytes; |
|
58 |
public Button previewButton; |
|
59 |
|
|
60 |
/** Called when the activity is first created. */ |
|
61 |
@Override |
|
62 |
public void onCreate(Bundle savedInstanceState) { |
|
63 |
super.onCreate(savedInstanceState); |
|
64 |
|
|
65 |
objects = (ContainerObjects) this.getIntent().getExtras().get("container"); |
|
66 |
containerNames = (String) this.getIntent().getExtras().get("containerNames"); |
|
67 |
cdnURL = (String) this.getIntent().getExtras().get("cdnUrl"); |
|
68 |
cdnEnabled = (String) this.getIntent().getExtras().get("isCdnEnabled"); |
|
69 |
|
|
70 |
setContentView(R.layout.viewobject); |
|
71 |
restoreState(savedInstanceState); |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
protected void onSaveInstanceState(Bundle outState) { |
|
77 |
super.onSaveInstanceState(outState); |
|
78 |
outState.putSerializable("container", objects); |
|
79 |
} |
|
80 |
|
|
81 |
private void restoreState(Bundle state) { |
|
82 |
if (state != null && state.containsKey("container")) { |
|
83 |
objects = (ContainerObjects) state.getSerializable("container"); |
|
84 |
} |
|
85 |
loadObjectData(); |
|
86 |
|
|
87 |
if ( cdnEnabled.equals("true")) { |
|
88 |
this.previewButton = (Button) findViewById(R.id.preview_button); |
|
89 |
previewButton.setOnClickListener(new MyOnClickListener()); |
|
90 |
} else { |
|
91 |
this.previewButton = (Button) findViewById(R.id.preview_button); |
|
92 |
previewButton.setVisibility(View.GONE); |
|
93 |
} |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
private void loadObjectData() { |
|
100 |
TextView name = (TextView) findViewById(R.id.view_container_name); |
|
101 |
name.setText(objects.getCName().toString()); |
|
102 |
|
|
103 |
if (objects.getBytes() >= bConver) { |
|
104 |
megaBytes = Math.abs(objects.getBytes()/bConver + 0.2); |
|
105 |
TextView sublabel = (TextView) findViewById(R.id.view_file_bytes); |
|
106 |
sublabel.setText(megaBytes + " MB"); |
|
107 |
} else if (objects.getBytes() >= kbConver){ |
|
108 |
kiloBytes = Math.abs(objects.getBytes()/kbConver + 0.2); |
|
109 |
TextView sublabel = (TextView) findViewById(R.id.view_file_bytes); |
|
110 |
sublabel.setText(kiloBytes + " KB"); |
|
111 |
} else { |
|
112 |
TextView sublabel = (TextView) findViewById(R.id.view_file_bytes); |
|
113 |
sublabel.setText(objects.getBytes() + " B"); |
|
114 |
} |
|
115 |
|
|
116 |
TextView cType = (TextView) findViewById(R.id.view_content_type); |
|
117 |
cType.setText(objects.getContentType().toString()); |
|
118 |
|
|
119 |
TextView lastmod = (TextView) findViewById(R.id.view_file_modification); |
|
120 |
lastmod.setText(objects.getLastMod().toString()); |
|
121 |
|
|
122 |
|
|
123 |
} |
|
124 |
|
|
125 |
private class MyOnClickListener implements View.OnClickListener { |
|
126 |
@Override |
|
127 |
public void onClick(View v) { |
|
128 |
Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse(cdnURL + "/" + objects.getCName())); |
|
129 |
startActivity(viewIntent); |
|
130 |
|
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
private void showAlert(String title, String message) { |
|
135 |
AlertDialog alert = new AlertDialog.Builder(this).create(); |
|
136 |
alert.setTitle(title); |
|
137 |
alert.setMessage(message); |
|
138 |
alert.setButton("OK", new DialogInterface.OnClickListener() { |
|
139 |
public void onClick(DialogInterface dialog, int which) { |
|
140 |
return; |
|
141 |
} }); |
|
142 |
alert.show(); |
|
143 |
} |
|
144 |
//Create the Menu options |
|
145 |
@Override |
|
146 |
public boolean onCreateOptionsMenu(Menu menu) { |
|
147 |
super.onCreateOptionsMenu(menu); |
|
148 |
MenuInflater inflater = getMenuInflater(); |
|
149 |
inflater.inflate(R.menu.container_object_list_menu, menu); |
|
150 |
return true; |
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
154 |
public boolean onOptionsItemSelected(MenuItem item) { |
|
155 |
switch (item.getItemId()) { |
|
156 |
case R.id.delete_object: |
|
157 |
showDialog(deleteObject); |
|
158 |
return true; |
|
159 |
case R.id.refresh: |
|
160 |
loadObjectData(); |
|
161 |
return true; |
|
162 |
} |
|
163 |
return false; |
|
164 |
} |
|
165 |
|
|
166 |
@Override |
|
167 |
protected Dialog onCreateDialog(int id ) { |
|
168 |
switch (id) { |
|
169 |
case deleteObject: |
|
170 |
return new AlertDialog.Builder(ContainerObjectsDetails.this) |
|
171 |
.setIcon(R.drawable.alert_dialog_icon) |
|
172 |
.setTitle("Delete File") |
|
173 |
.setMessage("Are you sure you want to delete this file?") |
|
174 |
.setPositiveButton("Delete File", new DialogInterface.OnClickListener() { |
|
175 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
176 |
// User clicked OK so do some stuff |
|
177 |
new ContainerObjectDeleteTask().execute((Void[]) null); |
|
178 |
} |
|
179 |
}) |
|
180 |
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { |
|
181 |
public void onClick(DialogInterface dialog, int whichButton) { |
|
182 |
// User clicked Cancel so do some stuff |
|
183 |
} |
|
184 |
}) |
|
185 |
.create(); |
|
186 |
} |
|
187 |
return null; |
|
188 |
} |
|
189 |
/** |
|
190 |
* @return the file |
|
191 |
*/ |
|
192 |
public ContainerObjects getViewFile() { |
|
193 |
return objects; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* @param File the file to set |
|
198 |
*/ |
|
199 |
public void setViewFile(ContainerObjects object) { |
|
200 |
this.objects = object; |
|
201 |
} |
|
202 |
|
|
203 |
//Task's |
|
204 |
|
|
205 |
private CloudServersException parseCloudServersException(HttpResponse response) { |
|
206 |
CloudServersException cse = new CloudServersException(); |
|
207 |
try { |
|
208 |
BasicResponseHandler responseHandler = new BasicResponseHandler(); |
|
209 |
String body = responseHandler.handleResponse(response); |
|
210 |
CloudServersFaultXMLParser parser = new CloudServersFaultXMLParser(); |
|
211 |
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); |
|
212 |
XMLReader xmlReader = saxParser.getXMLReader(); |
|
213 |
xmlReader.setContentHandler(parser); |
|
214 |
xmlReader.parse(new InputSource(new StringReader(body))); |
|
215 |
cse = parser.getException(); |
|
216 |
} catch (ClientProtocolException e) { |
|
217 |
cse = new CloudServersException(); |
|
218 |
cse.setMessage(e.getLocalizedMessage()); |
|
219 |
} catch (IOException e) { |
|
220 |
cse = new CloudServersException(); |
|
221 |
cse.setMessage(e.getLocalizedMessage()); |
|
222 |
} catch (ParserConfigurationException e) { |
|
223 |
cse = new CloudServersException(); |
|
224 |
cse.setMessage(e.getLocalizedMessage()); |
|
225 |
} catch (SAXException e) { |
|
226 |
cse = new CloudServersException(); |
|
227 |
cse.setMessage(e.getLocalizedMessage()); |
|
228 |
} catch (FactoryConfigurationError e) { |
|
229 |
cse = new CloudServersException(); |
|
230 |
cse.setMessage(e.getLocalizedMessage()); |
|
231 |
} |
|
232 |
return cse; |
|
233 |
} |
|
234 |
|
|
235 |
private class ContainerObjectDeleteTask extends AsyncTask<Void, Void, HttpResponse> { |
|
236 |
|
|
237 |
private CloudServersException exception; |
|
238 |
|
|
239 |
@Override |
|
240 |
protected HttpResponse doInBackground(Void... arg0) { |
|
241 |
HttpResponse resp = null; |
|
242 |
try { |
|
243 |
resp = (new ContainerObjectManager()).deleteObject(containerNames, objects.getCName() ); |
|
244 |
Log.v(LOG, "container name " + objects.getCName() + " " + containerNames); |
|
245 |
} catch (CloudServersException e) { |
|
246 |
exception = e; |
|
247 |
} |
|
248 |
return resp; |
|
249 |
} |
|
250 |
|
|
251 |
@Override |
|
252 |
protected void onPostExecute(HttpResponse response) { |
|
253 |
if (response != null) { |
|
254 |
int statusCode = response.getStatusLine().getStatusCode(); |
|
255 |
if (statusCode == 204) { |
|
256 |
setResult(Activity.RESULT_OK); |
|
257 |
finish(); |
|
258 |
|
|
259 |
} else { |
|
260 |
CloudServersException cse = parseCloudServersException(response); |
|
261 |
if ("".equals(cse.getMessage())) { |
|
262 |
showAlert("Error", "There was a problem deleting your File."); |
|
263 |
} else { |
|
264 |
showAlert("Error", "There was a problem deleting your file: " + cse.getMessage()); |
|
265 |
} |
|
266 |
} |
|
267 |
} else if (exception != null) { |
|
268 |
showAlert("Error", "There was a problem deleting your file: " + exception.getMessage()); |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
} |
Also available in: Unified diff