Revision e7534f91
b/src/com/rackspacecloud/android/ListAccountsActivity.java | ||
---|---|---|
46 | 46 |
private final String FILENAME = "accounts.data"; |
47 | 47 |
private Intent tabViewIntent; |
48 | 48 |
private boolean authenticating; |
49 |
ProgressDialog dialog; |
|
50 |
Context context; |
|
49 |
private ProgressDialog dialog;
|
|
50 |
private Context context;
|
|
51 | 51 |
|
52 | 52 |
public void onCreate(Bundle savedInstanceState) { |
53 | 53 |
super.onCreate(savedInstanceState); |
54 |
restoreState(savedInstanceState); |
|
54 |
onRestoreInstanceState(savedInstanceState); |
|
55 |
//restoreState(savedInstanceState); |
|
55 | 56 |
registerForContextMenu(getListView()); |
56 | 57 |
context = getApplicationContext(); |
57 | 58 |
tabViewIntent = new Intent(this, TabViewActivity.class); |
58 | 59 |
} |
59 |
|
|
60 |
|
|
60 | 61 |
@Override |
61 | 62 |
protected void onSaveInstanceState(Bundle outState) { |
62 | 63 |
super.onSaveInstanceState(outState); |
64 |
Log.d("info", "captin the acounnt activity state has been saved"); |
|
65 |
Log.d("info", "captin it is " + Boolean.toString(authenticating) + "that the app is authing"); |
|
63 | 66 |
outState.putBoolean("authenticating", authenticating); |
67 |
//need to set authenticating back to true because it is set to false |
|
68 |
//in hideDialog() |
|
69 |
if(authenticating){ |
|
70 |
hideDialog(); |
|
71 |
authenticating = true; |
|
72 |
} |
|
64 | 73 |
writeAccounts(); |
65 | 74 |
} |
66 | 75 |
|
67 |
private void restoreState(Bundle state) { |
|
76 |
@Override |
|
77 |
protected void onRestoreInstanceState(Bundle state) { |
|
68 | 78 |
if (state != null && state.containsKey("authenticating") && state.getBoolean("authenticating")) { |
69 |
showActivityIndicators();
|
|
79 |
showDialog();
|
|
70 | 80 |
} else { |
71 |
hideActivityIndicators();
|
|
81 |
hideDialog();
|
|
72 | 82 |
} |
73 | 83 |
if (state != null && state.containsKey("accounts")) { |
74 | 84 |
accounts = readAccounts(); |
... | ... | |
83 | 93 |
} |
84 | 94 |
} |
85 | 95 |
|
96 |
@Override |
|
97 |
protected void onStart(){ |
|
98 |
super.onStart(); |
|
99 |
Log.d("info", "captin onStop called"); |
|
100 |
if(authenticating){ |
|
101 |
showDialog(); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
protected void onStop(){ |
|
107 |
super.onStop(); |
|
108 |
Log.d("info", "captin onStart called"); |
|
109 |
if(authenticating){ |
|
110 |
hideDialog(); |
|
111 |
authenticating = true; |
|
112 |
} |
|
113 |
} |
|
114 |
|
|
86 | 115 |
private void loadAccounts() { |
87 | 116 |
if(accounts != null) |
88 | 117 |
Log.d("loadAccounts", "captin the lenght is: " + accounts.size()); |
... | ... | |
166 | 195 |
|
167 | 196 |
protected void onListItemClick(ListView l, View v, int position, long id) { |
168 | 197 |
if (accounts != null && accounts.size() > 0) { |
169 |
setActivityIndicatorsVisibility(View.VISIBLE, v); |
|
198 |
//setActivityIndicatorsVisibility(View.VISIBLE, v);
|
|
170 | 199 |
Account.setAccount(accounts.get(position)); |
171 | 200 |
login(); |
172 | 201 |
} |
... | ... | |
175 | 204 |
public void login() { |
176 | 205 |
//showActivityIndicators(); |
177 | 206 |
//setLoginPreferences(); |
178 |
dialog = ProgressDialog.show(ListAccountsActivity.this, "", "Authenticating...", true); |
|
179 | 207 |
new AuthenticateTask().execute((Void[]) null); |
180 | 208 |
} |
181 | 209 |
|
... | ... | |
281 | 309 |
loadAccounts(); |
282 | 310 |
} |
283 | 311 |
} |
284 |
|
|
312 |
/* |
|
285 | 313 |
private void setActivityIndicatorsVisibility(int visibility) { |
286 | 314 |
//FINISH THIS TO LET USER KNOW PROGRAM IS STILL WORKING |
287 | 315 |
|
... | ... | |
299 | 327 |
//pb.setVisibility(visibility); |
300 | 328 |
//tv.setVisibility(visibility); |
301 | 329 |
} |
330 |
*/ |
|
302 | 331 |
|
303 |
private void showActivityIndicators() { |
|
304 |
setActivityIndicatorsVisibility(View.VISIBLE); |
|
332 |
private void showDialog() { |
|
333 |
authenticating = true; |
|
334 |
dialog = ProgressDialog.show(ListAccountsActivity.this, "", "Authenticating...", true); |
|
305 | 335 |
} |
306 | 336 |
|
307 |
private void hideActivityIndicators() { |
|
308 |
setActivityIndicatorsVisibility(View.INVISIBLE); |
|
337 |
private void hideDialog() { |
|
338 |
if(dialog != null){ |
|
339 |
dialog.dismiss(); |
|
340 |
} |
|
341 |
authenticating = false; |
|
309 | 342 |
} |
310 |
|
|
343 |
|
|
311 | 344 |
private class AuthenticateTask extends AsyncTask<Void, Void, Boolean> { |
312 | 345 |
|
313 | 346 |
@Override |
347 |
protected void onPreExecute(){ |
|
348 |
showDialog(); |
|
349 |
} |
|
350 |
|
|
351 |
@Override |
|
314 | 352 |
protected Boolean doInBackground(Void... arg0) { |
315 |
|
|
316 |
authenticating = true; |
|
317 | 353 |
return new Boolean(Authentication.authenticate(context)); |
318 | 354 |
//return true; |
319 | 355 |
} |
320 | 356 |
|
321 | 357 |
@Override |
322 | 358 |
protected void onPostExecute(Boolean result) { |
323 |
authenticating = false; |
|
324 | 359 |
if (result.booleanValue()) { |
325 | 360 |
//startActivity(tabViewIntent); |
326 |
new LoadImagesTask().execute((Void[]) null);
|
|
361 |
new LoadImagesTask().execute((Void[]) null); |
|
327 | 362 |
} else { |
328 |
dialog.dismiss();
|
|
363 |
hideDialog();
|
|
329 | 364 |
showAlert("Login Failure", "Authentication failed. Please check your User Name and API Key."); |
330 | 365 |
} |
331 | 366 |
} |
... | ... | |
335 | 370 |
|
336 | 371 |
@Override |
337 | 372 |
protected ArrayList<Flavor> doInBackground(Void... arg0) { |
338 |
Log.d("auth", "task2"); |
|
339 | 373 |
return (new FlavorManager()).createList(true, context); |
340 | 374 |
} |
341 | 375 |
|
... | ... | |
348 | 382 |
flavorMap.put(flavor.getId(), flavor); |
349 | 383 |
} |
350 | 384 |
Flavor.setFlavors(flavorMap); |
351 |
dialog.dismiss();
|
|
385 |
hideDialog();
|
|
352 | 386 |
startActivity(tabViewIntent); |
353 | 387 |
} else { |
354 |
dialog.dismiss();
|
|
388 |
hideDialog();
|
|
355 | 389 |
showAlert("Login Failure", "There was a problem loading server flavors. Please try again."); |
356 | 390 |
} |
357 |
hideActivityIndicators(); |
|
358 | 391 |
} |
359 | 392 |
} |
360 | 393 |
|
... | ... | |
362 | 395 |
|
363 | 396 |
@Override |
364 | 397 |
protected ArrayList<Image> doInBackground(Void... arg0) { |
365 |
Log.d("auth", "task3"); |
|
366 | 398 |
return (new ImageManager()).createList(true, context); |
367 | 399 |
} |
368 | 400 |
|
... | ... | |
378 | 410 |
new LoadFlavorsTask().execute((Void[]) null); |
379 | 411 |
//startActivity(tabViewIntent); |
380 | 412 |
} else { |
381 |
dialog.dismiss();
|
|
413 |
hideDialog();
|
|
382 | 414 |
showAlert("Login Failure", "There was a problem loading server images. Please try again."); |
383 | 415 |
} |
384 |
hideActivityIndicators(); |
|
385 | 416 |
} |
386 | 417 |
} |
387 | 418 |
|
... | ... | |
394 | 425 |
return; |
395 | 426 |
} }); |
396 | 427 |
alert.show(); |
397 |
hideActivityIndicators(); |
|
398 | 428 |
} |
399 | 429 |
|
400 | 430 |
|
b/src/com/rackspacecloud/android/ListContainerActivity.java | ||
---|---|---|
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
private void restoreState(Bundle state) { |
59 |
if (state != null && state.containsKey("container")) { |
|
59 |
if (state != null && state.containsKey("container") && state.getSerializable("container") != null) {
|
|
60 | 60 |
containers = (Container[]) state.getSerializable("container"); |
61 | 61 |
if (containers.length == 0) { |
62 | 62 |
displayNoServersCell(); |
... | ... | |
234 | 234 |
// again |
235 | 235 |
return true; |
236 | 236 |
case R.id.refresh: |
237 |
containers = null; |
|
237 | 238 |
loadContainers(); |
238 | 239 |
return true; |
239 | 240 |
} |
b/src/com/rackspacecloud/android/ListServersActivity.java | ||
---|---|---|
12 | 12 |
import android.content.Intent; |
13 | 13 |
import android.os.AsyncTask; |
14 | 14 |
import android.os.Bundle; |
15 |
import android.util.Log; |
|
15 | 16 |
import android.view.LayoutInflater; |
16 | 17 |
import android.view.Menu; |
17 | 18 |
import android.view.MenuInflater; |
... | ... | |
34 | 35 |
public class ListServersActivity extends ListActivity { |
35 | 36 |
|
36 | 37 |
private Server[] servers; |
37 |
Context context; |
|
38 |
private Context context;
|
|
38 | 39 |
|
39 | 40 |
@Override |
40 | 41 |
public void onCreate(Bundle savedInstanceState) { |
... | ... | |
50 | 51 |
} |
51 | 52 |
|
52 | 53 |
private void restoreState(Bundle state) { |
53 |
if (state != null && state.containsKey("servers")) { |
|
54 |
if (state != null && state.containsKey("servers") && state.getSerializable("servers") != null) {
|
|
54 | 55 |
servers = (Server[]) state.getSerializable("servers"); |
55 | 56 |
if (servers.length == 0) { |
56 | 57 |
displayNoServersCell(); |
... | ... | |
139 | 140 |
|
140 | 141 |
private CloudServersException exception; |
141 | 142 |
|
143 |
@Override |
|
144 |
protected void onPreExecute(){ |
|
145 |
Log.d("info", "captin load called"); |
|
146 |
} |
|
147 |
|
|
142 | 148 |
@Override |
143 | 149 |
protected ArrayList<Server> doInBackground(Void... arg0) { |
144 | 150 |
ArrayList<Server> servers = null; |
... | ... | |
174 | 180 |
startActivityForResult(new Intent(this, AddServerActivity.class), 56); // arbitrary number; never used again |
175 | 181 |
return true; |
176 | 182 |
case R.id.refresh: |
183 |
servers = null; |
|
177 | 184 |
loadServers(); |
178 | 185 |
return true; |
179 | 186 |
} |
b/src/com/rackspacecloud/android/ViewServerActivity.java | ||
---|---|---|
91 | 91 |
loadFlavors(); |
92 | 92 |
loadImages(); |
93 | 93 |
} |
94 |
|
|
94 |
/* |
|
95 | 95 |
private void loadImage() { |
96 | 96 |
// hate to do this, but devices run out of memory after a few rotations |
97 | 97 |
// because the background images are so large |
98 |
//if (!imageLoaded) {
|
|
98 |
if (!imageLoaded) { |
|
99 | 99 |
ImageView osLogo = (ImageView) findViewById(R.id.view_server_os_logo); |
100 | 100 |
osLogo.setAlpha(100); |
101 | 101 |
osLogo.setImageResource(server.getImage().logoResourceId()); |
102 |
// imageLoaded = true;
|
|
103 |
//}
|
|
102 |
imageLoaded = true; |
|
103 |
} |
|
104 | 104 |
|
105 | 105 |
} |
106 |
|
|
106 |
*/ |
|
107 | 107 |
private void loadServerData() { |
108 | 108 |
TextView name = (TextView) findViewById(R.id.view_server_name); |
109 | 109 |
name.setText(server.getName()); |
... | ... | |
157 | 157 |
ipAddressesLoaded = true; |
158 | 158 |
} |
159 | 159 |
|
160 |
loadImage(); |
|
160 |
//loadImage();
|
|
161 | 161 |
} |
162 | 162 |
|
163 | 163 |
private void loadFlavors() { |
Also available in: Unified diff