7 |
7 |
import java.util.Iterator;
|
8 |
8 |
|
9 |
9 |
import android.app.Activity;
|
|
10 |
import android.app.AlertDialog;
|
|
11 |
import android.content.DialogInterface;
|
10 |
12 |
import android.os.AsyncTask;
|
11 |
13 |
import android.os.Bundle;
|
12 |
14 |
import android.view.View;
|
... | ... | |
16 |
18 |
import android.widget.ArrayAdapter;
|
17 |
19 |
import android.widget.Button;
|
18 |
20 |
import android.widget.EditText;
|
|
21 |
import android.widget.ProgressBar;
|
19 |
22 |
import android.widget.SeekBar;
|
20 |
23 |
import android.widget.SeekBar.OnSeekBarChangeListener;
|
21 |
24 |
import android.widget.Spinner;
|
... | ... | |
57 |
60 |
}
|
58 |
61 |
|
59 |
62 |
protected void restoreState(Bundle state){
|
60 |
|
super.restoreState(state);
|
|
63 |
|
61 |
64 |
serverName = (EditText) findViewById(R.id.server_name);
|
62 |
65 |
((Button) findViewById(R.id.save_button)).setOnClickListener(this);
|
63 |
66 |
((TextView)findViewById(R.id.names_number)).setText(" ");
|
... | ... | |
187 |
190 |
server.setName(serverName.getText().toString());
|
188 |
191 |
server.setImageId(selectedImageId);
|
189 |
192 |
server.setFlavorId(selectedFlavorId);
|
190 |
|
new SaveServerTask().execute((Void[]) null);
|
|
193 |
|
191 |
194 |
}
|
192 |
195 |
}
|
193 |
196 |
|
... | ... | |
219 |
222 |
setActivityIndicatorsVisibility(View.INVISIBLE);
|
220 |
223 |
}
|
221 |
224 |
|
222 |
|
private class SaveServerTask extends AsyncTask<Void, Void, Server> {
|
223 |
|
|
224 |
|
private CloudServersException exception;
|
225 |
|
|
226 |
|
@Override
|
227 |
|
protected void onPreExecute(){
|
228 |
|
showDialog();
|
229 |
|
}
|
230 |
|
|
231 |
|
@Override
|
232 |
|
protected Server doInBackground(Void... arg0) {
|
233 |
|
try {
|
234 |
|
if(numberBar.getProgress() == 0){
|
235 |
|
(new ServerManager()).create(server, getContext());
|
236 |
|
}
|
237 |
|
else{
|
238 |
|
for(int i = 0; i < numberBar.getProgress() + 1; i++){
|
239 |
|
server.setName(serverName.getText().toString() + Integer.toString(i+1));
|
240 |
|
(new ServerManager()).create(server, getContext());
|
241 |
|
}
|
242 |
|
}
|
243 |
|
} catch (CloudServersException e) {
|
244 |
|
exception = e;
|
245 |
|
}
|
246 |
|
return server;
|
247 |
|
}
|
248 |
|
|
249 |
|
@Override
|
250 |
|
protected void onPostExecute(Server result) {
|
251 |
|
hideDialog();
|
252 |
|
if (exception != null) {
|
253 |
|
showAlert("Error", "There was a problem creating your server: "
|
254 |
|
+ exception.getMessage());
|
255 |
|
} else {
|
256 |
|
setResult(Activity.RESULT_OK);
|
257 |
|
finish();
|
258 |
|
}
|
259 |
|
}
|
260 |
|
}
|
|
225 |
|
261 |
226 |
|
262 |
227 |
}
|