Revision 51fdecfb src/com/rackspacecloud/android/ViewServerActivity.java
b/src/com/rackspacecloud/android/ViewServerActivity.java | ||
---|---|---|
30 | 30 |
import android.os.AsyncTask; |
31 | 31 |
import android.os.Bundle; |
32 | 32 |
import android.util.Log; |
33 |
import android.view.Menu; |
|
34 |
import android.view.MenuInflater; |
|
35 |
import android.view.MenuItem; |
|
33 | 36 |
import android.view.View; |
34 | 37 |
import android.view.View.OnClickListener; |
35 | 38 |
import android.widget.Button; |
... | ... | |
66 | 69 |
private boolean isPolling; |
67 | 70 |
private PollServerTask pollServerTask; |
68 | 71 |
private boolean canPoll; |
69 |
|
|
72 |
private boolean noAskForConfirm; |
|
73 |
|
|
70 | 74 |
/** Called when the activity is first created. */ |
71 | 75 |
@Override |
72 | 76 |
public void onCreate(Bundle savedInstanceState) { |
... | ... | |
81 | 85 |
protected void onSaveInstanceState(Bundle outState) { |
82 | 86 |
super.onSaveInstanceState(outState); |
83 | 87 |
outState.putSerializable("server", server); |
88 |
outState.putBoolean("noAskForConfirm", noAskForConfirm); |
|
84 | 89 |
if(pollServerTask != null && isPolling){ |
85 | 90 |
pollServerTask.cancel(true); |
86 | 91 |
} |
... | ... | |
88 | 93 |
} |
89 | 94 |
|
90 | 95 |
private void restoreState(Bundle state) { |
96 |
if(state != null && state.containsKey("noAskForConfirm")){ |
|
97 |
noAskForConfirm = state.getBoolean("noAskForConfirm"); |
|
98 |
} |
|
91 | 99 |
if(state != null && state.containsKey("wasPolling") && state.getBoolean("wasPolling") == true){ |
92 | 100 |
pollServerTask = new PollServerTask(); |
93 | 101 |
pollServerTask.execute((Void[]) null); |
... | ... | |
162 | 170 |
|
163 | 171 |
TextView status = (TextView) findViewById(R.id.view_server_status); |
164 | 172 |
|
173 |
if(noAskForConfirm == false){ |
|
174 |
if(status.getText().toString().contains("VERIFY_RESIZE")){ |
|
175 |
//show the confimresizeactivity |
|
176 |
noAskForConfirm = true; |
|
177 |
Intent viewIntent = new Intent(getApplicationContext(), ConfirmResizeActivity.class); |
|
178 |
viewIntent.putExtra("server", server); |
|
179 |
startActivity(viewIntent); |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
165 | 183 |
// show status and possibly the progress, with polling |
166 | 184 |
if (!"ACTIVE".equals(server.getStatus())) { |
167 | 185 |
status.setText(server.getStatus() + " - " + server.getProgress() + "%"); |
... | ... | |
331 | 349 |
public void setServer(Server server) { |
332 | 350 |
this.server = server; |
333 | 351 |
} |
352 |
|
|
353 |
//setup menu for when menu button is pressed |
|
354 |
public boolean onCreateOptionsMenu(Menu menu) { |
|
355 |
super.onCreateOptionsMenu(menu); |
|
356 |
MenuInflater inflater = getMenuInflater(); |
|
357 |
inflater.inflate(R.menu.view_server_activity_menu, menu); |
|
358 |
return true; |
|
359 |
} |
|
360 |
|
|
361 |
@Override |
|
362 |
//in options menu, when add account is selected go to add account activity |
|
363 |
public boolean onOptionsItemSelected(MenuItem item) { |
|
364 |
switch (item.getItemId()) { |
|
365 |
case R.id.refresh_server: |
|
366 |
loadServerData(); |
|
367 |
return true; |
|
368 |
} |
|
369 |
return false; |
|
370 |
} |
|
334 | 371 |
|
335 | 372 |
private void startServerError(String message, HttpBundle bundle){ |
336 | 373 |
Intent viewIntent = new Intent(getApplicationContext(), ServerErrorActivity.class); |
... | ... | |
339 | 376 |
viewIntent.putExtra("request", bundle.getCurlRequest()); |
340 | 377 |
startActivity(viewIntent); |
341 | 378 |
} |
342 |
|
|
343 |
private String prints(Object[] arr){ |
|
344 |
String result = ""; |
|
345 |
for(int i = 0; i < arr.length; i++){ |
|
346 |
result += arr[i] + " "; |
|
347 |
} |
|
348 |
return result; |
|
349 |
} |
|
350 | 379 |
|
351 | 380 |
@Override |
352 | 381 |
protected Dialog onCreateDialog(int id) { |
... | ... | |
399 | 428 |
}) |
400 | 429 |
.create(); |
401 | 430 |
case R.id.view_server_resize_button: |
402 |
Log.d("info", "the flavor names are " + prints(flavorNames)); |
|
403 | 431 |
return new AlertDialog.Builder(ViewServerActivity.this) |
404 | 432 |
.setItems(flavorNames, new ResizeClickListener()) |
405 | 433 |
.setIcon(R.drawable.alert_dialog_icon) |
Also available in: Unified diff