Revision ea001570 src/com/rackspacecloud/android/ListContainerActivity.java
b/src/com/rackspacecloud/android/ListContainerActivity.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import android.app.AlertDialog; |
6 | 6 |
import android.app.ListActivity; |
7 |
import android.app.ProgressDialog; |
|
7 | 8 |
import android.content.Context; |
8 | 9 |
import android.content.DialogInterface; |
9 | 10 |
import android.content.Intent; |
... | ... | |
16 | 17 |
import android.view.MenuItem; |
17 | 18 |
import android.view.View; |
18 | 19 |
import android.view.ViewGroup; |
20 |
import android.view.WindowManager; |
|
21 |
import android.view.ViewGroup.LayoutParams; |
|
19 | 22 |
import android.widget.ArrayAdapter; |
20 | 23 |
import android.widget.ListView; |
24 |
import android.widget.ProgressBar; |
|
21 | 25 |
import android.widget.TextView; |
22 | 26 |
|
23 | 27 |
import com.rackspace.cloud.files.api.client.Container; |
... | ... | |
43 | 47 |
public int kbConver = 1024; |
44 | 48 |
private Context context; |
45 | 49 |
private boolean loading; |
50 |
ProgressDialog pDialog; |
|
46 | 51 |
|
47 | 52 |
@Override |
48 | 53 |
public void onCreate(Bundle savedInstanceState) { |
49 | 54 |
super.onCreate(savedInstanceState); |
50 | 55 |
context = getApplicationContext(); |
56 |
setContentView(R.layout.list_containers); |
|
51 | 57 |
restoreState(savedInstanceState); |
52 | 58 |
} |
53 | 59 |
|
... | ... | |
62 | 68 |
if (state != null && state.containsKey("container") && state.getSerializable("container") != null) { |
63 | 69 |
containers = (Container[]) state.getSerializable("container"); |
64 | 70 |
if (containers.length == 0) { |
65 |
displayNoServersCell();
|
|
71 |
displayNoContainersCell();
|
|
66 | 72 |
} else { |
67 | 73 |
getListView().setDividerHeight(1); // restore divider lines |
68 | 74 |
setListAdapter(new FileAdapter()); |
... | ... | |
82 | 88 |
} |
83 | 89 |
|
84 | 90 |
private void loadContainers() { |
85 |
displayLoadingCell();
|
|
91 |
showProgressDialog();
|
|
86 | 92 |
new LoadContainersTask().execute((Void[]) null); |
87 | 93 |
} |
88 | 94 |
|
89 | 95 |
private void setContainerList() { |
90 | 96 |
if (containerNames.length == 0) { |
91 |
displayNoServersCell();
|
|
97 |
displayNoContainersCell();
|
|
92 | 98 |
} else { |
93 | 99 |
getListView().setDividerHeight(1); // restore divider lines |
94 | 100 |
setListAdapter(new FileAdapter()); |
95 | 101 |
} |
96 | 102 |
} |
97 | 103 |
|
98 |
private void displayLoadingCell() { |
|
99 |
String a[] = new String[1]; |
|
100 |
a[0] = "Loading..."; |
|
101 |
setListAdapter(new ArrayAdapter<String>(this, R.layout.loadingcell, |
|
102 |
R.id.loading_label, a)); |
|
103 |
getListView().setTextFilterEnabled(true); |
|
104 |
getListView().setDividerHeight(0); // hide the dividers so it won't look |
|
105 |
// like a list row |
|
106 |
getListView().setItemsCanFocus(false); |
|
107 |
} |
|
108 |
|
|
109 |
private void displayNoServersCell() {
|
|
104 |
// private void displayLoadingCell() {
|
|
105 |
// String a[] = new String[1];
|
|
106 |
// a[0] = "Loading...";
|
|
107 |
// setListAdapter(new ArrayAdapter<String>(this, R.layout.loadingcell,
|
|
108 |
// R.id.loading_label, a));
|
|
109 |
// getListView().setTextFilterEnabled(true);
|
|
110 |
// getListView().setDividerHeight(0); // hide the dividers so it won't look
|
|
111 |
// // like a list row
|
|
112 |
// getListView().setItemsCanFocus(false);
|
|
113 |
// }
|
|
114 |
|
|
115 |
private void displayNoContainersCell() {
|
|
110 | 116 |
String a[] = new String[1]; |
111 | 117 |
a[0] = "No Files"; |
112 | 118 |
setListAdapter(new ArrayAdapter<String>(this, |
... | ... | |
116 | 122 |
// like a list row |
117 | 123 |
getListView().setItemsCanFocus(false); |
118 | 124 |
} |
125 |
|
|
126 |
protected void showProgressDialog() { |
|
127 |
pDialog = new ProgressDialog(this, R.style.NewDialog); |
|
128 |
// // Set blur to background |
|
129 |
WindowManager.LayoutParams lp = pDialog.getWindow().getAttributes(); |
|
130 |
lp.dimAmount = 0.0f; |
|
131 |
pDialog.getWindow().setAttributes(lp); |
|
132 |
pDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
|
133 |
pDialog.show(); |
|
134 |
pDialog.setContentView(new ProgressBar(this), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); |
|
135 |
} |
|
119 | 136 |
|
120 | 137 |
private void showAlert(String title, String message) { |
121 | 138 |
// Can't create handler inside thread that has not called |
... | ... | |
185 | 202 |
|
186 | 203 |
@Override |
187 | 204 |
protected void onPreExecute(){ |
205 |
showProgressDialog(); |
|
188 | 206 |
loading = true; |
189 | 207 |
} |
190 | 208 |
|
... | ... | |
203 | 221 |
@Override |
204 | 222 |
protected void onPostExecute(ArrayList<Container> result) { |
205 | 223 |
Log.v("listcontainerActivity", "onPostExecute loadCDNcontainerTask"); |
224 |
pDialog.dismiss(); |
|
206 | 225 |
if (exception != null) { |
207 | 226 |
showAlert("Error", exception.getMessage()); |
208 | 227 |
} |
Also available in: Unified diff