Revision 984acda7
b/res/layout/createserver.xml | ||
---|---|---|
4 | 4 |
android:layout_width="fill_parent" |
5 | 5 |
android:layout_height="fill_parent" |
6 | 6 |
> |
7 |
<RelativeLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/RelativeLayout1"> |
|
8 |
<TextView android:id="@+id/TextView1" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="Number of Servers" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginLeft="22dip" android:layout_width="wrap_content"></TextView> |
|
9 |
<TextView android:layout_toRightOf="@+id/TextView1" android:layout_alignBaseline="@+id/TextView1" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_alignParentRight="true" android:gravity="right" android:layout_marginRight="30dip" android:id="@+id/server_count_text" android:text="1 Server"></TextView> |
|
10 |
</RelativeLayout> |
|
11 |
<SeekBar android:layout_height="wrap_content" android:id="@+id/number_of_servers" android:max="9" android:layout_gravity="center" android:layout_width="fill_parent" android:layout_marginLeft="12dip" android:layout_marginRight="20dip" android:paddingRight="10dip" android:paddingLeft="15dip"></SeekBar> |
|
7 | 12 |
|
8 | 13 |
<TextView |
9 | 14 |
android:layout_width="fill_parent" |
b/src/com/rackspacecloud/android/AddServerActivity.java | ||
---|---|---|
18 | 18 |
import android.widget.Button; |
19 | 19 |
import android.widget.EditText; |
20 | 20 |
import android.widget.ProgressBar; |
21 |
import android.widget.SeekBar; |
|
22 |
import android.widget.SeekBar.OnSeekBarChangeListener; |
|
21 | 23 |
import android.widget.Spinner; |
22 | 24 |
import android.widget.TextView; |
23 | 25 |
import android.widget.AdapterView.OnItemSelectedListener; |
... | ... | |
42 | 44 |
private Spinner imageSpinner; |
43 | 45 |
private Spinner flavorSpinner; |
44 | 46 |
private Server server; |
47 |
private SeekBar numberBar; |
|
48 |
private TextView numberDisplay; |
|
45 | 49 |
|
46 | 50 |
/** Called when the activity is first created. */ |
47 | 51 |
@Override |
... | ... | |
52 | 56 |
((Button) findViewById(R.id.save_button)).setOnClickListener(this); |
53 | 57 |
loadImageSpinner(); |
54 | 58 |
loadFlavorSpinner(); |
59 |
loadServerCount(); |
|
60 |
} |
|
61 |
|
|
62 |
private void loadServerCount(){ |
|
63 |
numberDisplay = (TextView)findViewById(R.id.server_count_text); |
|
64 |
numberBar = (SeekBar)findViewById(R.id.number_of_servers); |
|
65 |
numberBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { |
|
66 |
|
|
67 |
@Override |
|
68 |
public void onStopTrackingTouch(SeekBar seekBar) { |
|
69 |
// TODO Auto-generated method stub |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public void onStartTrackingTouch(SeekBar seekBar) { |
|
75 |
// TODO Auto-generated method stub |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public void onProgressChanged(SeekBar seekBar, int progress, |
|
81 |
boolean fromUser) { |
|
82 |
// TODO Auto-generated method stub |
|
83 |
numberDisplay.setText(getCountText(progress)); |
|
84 |
} |
|
85 |
|
|
86 |
private String getCountText(int i){ |
|
87 |
if(i == 0){ |
|
88 |
return "1 Server"; |
|
89 |
} |
|
90 |
else{ |
|
91 |
//count starts at 0 |
|
92 |
return i+1 + " Servers"; |
|
93 |
} |
|
94 |
} |
|
95 |
}); |
|
96 |
|
|
55 | 97 |
} |
56 | 98 |
|
57 | 99 |
private void loadImageSpinner() { |
... | ... | |
157 | 199 |
@Override |
158 | 200 |
protected Server doInBackground(Void... arg0) { |
159 | 201 |
try { |
160 |
(new ServerManager()).create(server, getApplicationContext()); |
|
202 |
if(numberBar.getProgress() == 0){ |
|
203 |
(new ServerManager()).create(server, getApplicationContext()); |
|
204 |
} |
|
205 |
else{ |
|
206 |
for(int i = 0; i < numberBar.getProgress() + 1; i++){ |
|
207 |
server.setName(serverName.getText().toString() + Integer.toString(i+1)); |
|
208 |
(new ServerManager()).create(server, getApplicationContext()); |
|
209 |
} |
|
210 |
} |
|
161 | 211 |
} catch (CloudServersException e) { |
162 | 212 |
exception = e; |
163 | 213 |
} |
Also available in: Unified diff