Revision ecbad159 src/com/rackspace/cloud/android/PithosGroupsActivity.java

b/src/com/rackspace/cloud/android/PithosGroupsActivity.java
223 223

  
224 224
	
225 225
	private void showNew(){
226
		final CharSequence[] items = {"New Group"};
227
		AlertDialog.Builder builder = new AlertDialog.Builder(PithosGroupsActivity.this);
228
		builder.setTitle("Create ...");
229
		builder.setItems(items, new DialogInterface.OnClickListener() {
230
		    public void onClick(DialogInterface dialog, int item) {
231
		        switch(item){
232
		        case 0:
233
		        	final AlertDialog.Builder alert = new AlertDialog.Builder(PithosGroupsActivity.this);
234
		        	alert.setTitle("New Group");
235
		    		final EditText input = new EditText(PithosGroupsActivity.this);
236
		    		alert.setView(input);
237
		    		alert.setPositiveButton("Create", new DialogInterface.OnClickListener() {
238
		    			public void onClick(DialogInterface dialog, int whichButton) {
239
		    				String value = input.getText().toString().trim();
240
		    				Map<String,String> headers = new HashMap<String,String>();
241
		    				headers.put("X-Account-Group-"+value, Account.getAccount().getUsername()+",");
242
		    				HttpBundle bundel;
243
							try {
244
								bundel = new ContainerObjectManager(getApplicationContext()).updateObject(null, null, null, "application/json", headers);
245
								refresh();
246
							} catch (CloudServersException e) {
247
								// TODO Auto-generated catch block
248
								e.printStackTrace();
249
							}
250
		    				((GroupsListView) findViewById(R.id.groupsListView)).getGroupsAdapter().notifyDataSetChanged();
251
		    				
252
		    			}
253
		    		});
254

  
255
		    		alert.setNegativeButton("Cancel",
256
		    				new DialogInterface.OnClickListener() {
257
		    					public void onClick(DialogInterface dialog, int whichButton) {
258
		    						dialog.cancel();
259
		    					}
260
		    				});
261
		    		alert.show();
262
		        	break;
263
		        default:
264
		        	break;
265
		        }
266
		    }
226
		final AlertDialog.Builder alert = new AlertDialog.Builder(PithosGroupsActivity.this);
227
		alert.setTitle("New Group");
228
		final EditText input = new EditText(PithosGroupsActivity.this);
229
		alert.setView(input);
230
		alert.setPositiveButton("Create", new DialogInterface.OnClickListener() {
231
			public void onClick(DialogInterface dialog, int whichButton) {
232
				String value = input.getText().toString().trim();
233
				Map<String,String> headers = new HashMap<String,String>();
234
				headers.put("X-Account-Group-"+value, Account.getAccount().getUsername()+",");
235
				HttpBundle bundel;
236
				try {
237
					bundel = new ContainerObjectManager(getApplicationContext()).updateObject(null, null, null, "application/json", headers);
238
					refresh();
239
				} catch (CloudServersException e) {
240
					// TODO Auto-generated catch block
241
					e.printStackTrace();
242
				}
243
				((GroupsListView) findViewById(R.id.groupsListView)).getGroupsAdapter().notifyDataSetChanged();
244
				
245
			}
246
		});
247
			
248
		alert.setNegativeButton("Cancel",
249
				new DialogInterface.OnClickListener() {
250
			public void onClick(DialogInterface dialog, int whichButton) {
251
				dialog.cancel();
252
			}
267 253
		});
268
		AlertDialog alert = builder.create();
269 254
		alert.show();
255
		        	
270 256
	}
271 257
	
272 258
	protected void refresh(){

Also available in: Unified diff