Revision eb3b3154 src/com/rackspacecloud/android/ListServersActivity.java
b/src/com/rackspacecloud/android/ListServersActivity.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import android.app.AlertDialog; |
9 | 9 |
import android.app.ListActivity; |
10 |
import android.app.ProgressDialog; |
|
10 | 11 |
import android.content.Context; |
11 | 12 |
import android.content.DialogInterface; |
12 | 13 |
import android.content.Intent; |
... | ... | |
18 | 19 |
import android.view.MenuItem; |
19 | 20 |
import android.view.View; |
20 | 21 |
import android.view.ViewGroup; |
22 |
import android.view.WindowManager; |
|
23 |
import android.view.ViewGroup.LayoutParams; |
|
21 | 24 |
import android.widget.ArrayAdapter; |
22 | 25 |
import android.widget.ImageView; |
23 | 26 |
import android.widget.ListView; |
27 |
import android.widget.ProgressBar; |
|
24 | 28 |
import android.widget.TextView; |
25 | 29 |
|
26 | 30 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
... | ... | |
35 | 39 |
|
36 | 40 |
private Server[] servers; |
37 | 41 |
private Context context; |
42 |
ProgressDialog pDialog; |
|
38 | 43 |
|
39 | 44 |
@Override |
40 | 45 |
public void onCreate(Bundle savedInstanceState) { |
41 | 46 |
super.onCreate(savedInstanceState); |
42 | 47 |
context = getApplicationContext(); |
48 |
setContentView(R.layout.list_servers); |
|
43 | 49 |
restoreState(savedInstanceState); |
44 | 50 |
} |
45 | 51 |
|
... | ... | |
72 | 78 |
} |
73 | 79 |
|
74 | 80 |
private void loadServers() { |
75 |
displayLoadingCell(); |
|
81 |
// displayLoadingCell();
|
|
76 | 82 |
new LoadServersTask().execute((Void[]) null); |
77 | 83 |
} |
78 | 84 |
|
... | ... | |
99 | 105 |
} |
100 | 106 |
} |
101 | 107 |
|
102 |
private void displayLoadingCell() { |
|
103 |
String a[] = new String[1]; |
|
104 |
a[0] = "Loading..."; |
|
105 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.loadingcell, R.id.loading_label, a)); |
|
106 |
getListView().setTextFilterEnabled(true); |
|
107 |
getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
|
108 |
getListView().setItemsCanFocus(false); |
|
109 |
} |
|
108 |
// private void displayLoadingCell() { |
|
109 |
// String a[] = new String[1]; |
|
110 |
// a[0] = "Loading..."; |
|
111 |
// setListAdapter(new ArrayAdapter<String>(this, R.layout.loadingcell, R.id.loading_label, a)); |
|
112 |
// getListView().setTextFilterEnabled(true); |
|
113 |
// getListView().setDividerHeight(0); // hide the dividers so it won't look like a list row |
|
114 |
// getListView().setItemsCanFocus(false); |
|
115 |
// } |
|
116 |
|
|
117 |
protected void showProgressDialog() { |
|
118 |
pDialog = new ProgressDialog(this, R.style.NewDialog); |
|
119 |
// // Set blur to background |
|
120 |
WindowManager.LayoutParams lp = pDialog.getWindow().getAttributes(); |
|
121 |
lp.dimAmount = 0.0f; |
|
122 |
pDialog.getWindow().setAttributes(lp); |
|
123 |
pDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
|
124 |
pDialog.show(); |
|
125 |
pDialog.setContentView(new ProgressBar(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); |
|
126 |
} |
|
110 | 127 |
|
111 | 128 |
private void displayNoServersCell() { |
112 | 129 |
String a[] = new String[1]; |
... | ... | |
136 | 153 |
|
137 | 154 |
|
138 | 155 |
private class LoadServersTask extends AsyncTask<Void, Void, ArrayList<Server>> { |
139 |
|
|
140 | 156 |
private CloudServersException exception; |
141 | 157 |
|
158 |
@Override |
|
159 |
protected void onPreExecute(){ |
|
160 |
showProgressDialog(); |
|
161 |
} |
|
162 |
|
|
142 | 163 |
@Override |
143 | 164 |
protected ArrayList<Server> doInBackground(Void... arg0) { |
144 | 165 |
ArrayList<Server> servers = null; |
... | ... | |
147 | 168 |
} catch (CloudServersException e) { |
148 | 169 |
exception = e; |
149 | 170 |
} |
171 |
pDialog.dismiss(); |
|
150 | 172 |
return servers; |
151 | 173 |
} |
152 | 174 |
|
Also available in: Unified diff