Revision b722cab3 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; |
|
11 | 10 |
import android.content.Context; |
12 | 11 |
import android.content.DialogInterface; |
13 | 12 |
import android.content.Intent; |
... | ... | |
19 | 18 |
import android.view.MenuItem; |
20 | 19 |
import android.view.View; |
21 | 20 |
import android.view.ViewGroup; |
22 |
import android.view.WindowManager; |
|
23 |
import android.view.ViewGroup.LayoutParams; |
|
24 | 21 |
import android.widget.ArrayAdapter; |
25 | 22 |
import android.widget.ImageView; |
26 | 23 |
import android.widget.ListView; |
27 |
import android.widget.ProgressBar; |
|
28 | 24 |
import android.widget.TextView; |
29 | 25 |
|
30 | 26 |
import com.rackspace.cloud.servers.api.client.CloudServersException; |
... | ... | |
39 | 35 |
|
40 | 36 |
private Server[] servers; |
41 | 37 |
private Context context; |
42 |
ProgressDialog pDialog; |
|
43 | 38 |
|
44 | 39 |
@Override |
45 | 40 |
public void onCreate(Bundle savedInstanceState) { |
46 | 41 |
super.onCreate(savedInstanceState); |
47 | 42 |
context = getApplicationContext(); |
48 |
setContentView(R.layout.list_servers); |
|
49 | 43 |
restoreState(savedInstanceState); |
50 | 44 |
} |
51 | 45 |
|
... | ... | |
78 | 72 |
} |
79 | 73 |
|
80 | 74 |
private void loadServers() { |
81 |
// displayLoadingCell();
|
|
75 |
displayLoadingCell(); |
|
82 | 76 |
new LoadServersTask().execute((Void[]) null); |
83 | 77 |
} |
84 | 78 |
|
... | ... | |
105 | 99 |
} |
106 | 100 |
} |
107 | 101 |
|
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 |
} |
|
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 |
} |
|
127 | 110 |
|
128 | 111 |
private void displayNoServersCell() { |
129 | 112 |
String a[] = new String[1]; |
... | ... | |
153 | 136 |
|
154 | 137 |
|
155 | 138 |
private class LoadServersTask extends AsyncTask<Void, Void, ArrayList<Server>> { |
156 |
private CloudServersException exception; |
|
157 | 139 |
|
158 |
@Override |
|
159 |
protected void onPreExecute(){ |
|
160 |
showProgressDialog(); |
|
161 |
} |
|
140 |
private CloudServersException exception; |
|
162 | 141 |
|
163 | 142 |
@Override |
164 | 143 |
protected ArrayList<Server> doInBackground(Void... arg0) { |
... | ... | |
168 | 147 |
} catch (CloudServersException e) { |
169 | 148 |
exception = e; |
170 | 149 |
} |
171 |
pDialog.dismiss(); |
|
172 | 150 |
return servers; |
173 | 151 |
} |
174 | 152 |
|
Also available in: Unified diff