 
package com.lianxin.pubqq.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lianxin.pubqq.R;
import com.lianxin.panqq.edit.EditOpenLevelDialog;
import com.lianxin.panqq.client.AskClient;
import com.lianxin.panqq.client.EditClient;
import com.lianxin.panqq.client.callback.askCallBack;
import com.lianxin.panqq.common.BaseActivity;
import com.lianxin.panqq.common.GloableParams;
import com.lianxin.panqq.common.Utils;
import com.lianxin.panqq.list.utils.AddressUtils;
import com.lianxin.panqq.list.utils.CityUtils;
import com.lianxin.panqq.list.utils.CollegeUtils;
import com.lianxin.panqq.list.utils.DepartUtils;
import com.lianxin.panqq.list.utils.FriendUtils;
import com.lianxin.panqq.common.utils.KeywordUtils;
import com.lianxin.panqq.common.utils.OpenLevelUtils;
import com.lianxin.panqq.common.DefineUser;
import com.lianxin.panqq.picker.AddressPickerDialog;
import com.lianxin.panqq.picker.CityPickerDialog;
import com.lianxin.panqq.picker.DeptPickerDialog;
import com.lianxin.panqq.picker.GradePickerDialog;
import com.lianxin.panqq.picker.ImagePickerDialog;
import com.lianxin.panqq.picker.KeyPickerDialog;
import com.lianxin.panqq.list.utils.GroupManger;
import com.lianxin.panqq.utils.ImagesUtils;
import com.lianxin.panqq.common.bean.AskInfo;
import com.lianxin.panqq.common.bean.GroupInfo;
//新建群组界面
public class NewGroupActivity extends BaseActivity implements OnClickListener {
	
	private TextView txt_title,txt_right;
	private ImageView img_back, img_right; 
	private ImageView img_photo;  //用户头像
	private TextView txt_groupid; //用户id
	private EditText txt_groupname;  //用户名
	private EditText txt_editreason;  //用户名	
	private TextView txt_enyear;   //用户地区
	private TextView txt_type;   //用户职业
	private TextView txt_number;   //用户签名
	private TextView txt_openlevel;  //用户在哪动态
	private TextView cap_type, cap_enyear;	
	private TextView cap_groupid, cap_groupname;
	private Button btn_askcreate;
	private Button btn_paycreate;
	private Button btn_admincreate;	
	private RelativeLayout lay_image;	
	private RelativeLayout lay_groupname;
	private RelativeLayout lay_type;  
	private RelativeLayout lay_enyear;
	private RelativeLayout lay_openlevel;
	
	private int nGroupId = 10100;//用户唯一id
	private String strGroupName = "";
	private int groupType = DefineUser.TYPE_CROWD;		
	private int nImage = 10;
	private String strMessage = "";	
	int nType = 0x100;
	int nEnyear = 2000;
	private int iLevel = 2;
	
	public static final int REQUEST_CODE_ADD_TO_CONTACT = 226;
	public static final int REQUEST_CODE_ADD_TO_BLACKLIST = 225;
	private ProgressDialog progressDialog;
	
	private LinearLayout lay_right;
//	private TextView ta_tv;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_newgroup);
		
		initControl();
		initView();
		initData();
		setListener();			
	}

	protected void initControl() {
		txt_title = (TextView) findViewById(R.id.txt_title);
		//txt_title.setText("用户查找");
		img_back = (ImageView) findViewById(R.id.img_back);
		img_back.setVisibility(View.VISIBLE);	
		txt_groupid = (TextView)findViewById(R.id.tv_groupid);
		txt_groupname = (EditText)findViewById(R.id.tv_groupname);		
		img_photo = (ImageView)findViewById(R.id.iv_image);
	//	txt_nickname = (TextView)findViewById(R.id.tv_user_nickname);
		txt_type = (TextView)findViewById(R.id.tv_type);
		txt_enyear = (TextView)findViewById(R.id.tv_enyear);
		txt_number = (TextView)findViewById(R.id.tv_number1);
		txt_openlevel = (TextView)findViewById(R.id.tv_openlevel);
		cap_groupid = (TextView) findViewById(R.id.tv_groupid_cap);			
		cap_groupname = (TextView) findViewById(R.id.tv_groupname_cap);
		cap_type = (TextView) findViewById(R.id.tv_type_cap);			
		cap_enyear = (TextView) findViewById(R.id.tv_enyear_cap);
		lay_image = (RelativeLayout) findViewById(R.id.rl_group_pic);		
		lay_groupname = (RelativeLayout) findViewById(R.id.rl_groupname);
		lay_type = (RelativeLayout) findViewById(R.id.rl_type);
		lay_enyear = (RelativeLayout) findViewById(R.id.rl_enyear);
		lay_openlevel = (RelativeLayout) findViewById(R.id.rl_openlevel);	
		txt_editreason = (EditText)findViewById(R.id.tv_editreason);		
	//	btn_satrtchat = (Button)findViewById(R.id.btn_startchat);
		btn_askcreate = (Button)findViewById(R.id.btn_askcreate);
		btn_paycreate = (Button)findViewById(R.id.btn_paycreate);
		btn_admincreate = (Button)findViewById(R.id.btn_admincreate);
		
		lay_right = (LinearLayout)findViewById(R.id.layout_right);
		txt_right = (TextView)findViewById(R.id.tv_right);
	}

	protected void initView() {
		nGroupId = getIntent().getIntExtra("Info_GroupId", 10010);
		strGroupName = getIntent().getStringExtra("Info_GroupName");
		groupType = getIntent().getIntExtra("Info_GroupType", 3);	
		setCaption();		
		setHint();	
	
	}
	
	protected void initData() {

		txt_openlevel.setText(OpenLevelUtils.getOpenLevelText(iLevel));		
	}	

	protected void setCaption() {
		switch (groupType) {
		case DefineUser.TYPE_FRIEND:
			txt_title.setText("分类");
			cap_groupid.setText("分类ID");
			cap_groupname.setText("分类名称");
			cap_type.setText("关  键  字");
			cap_enyear.setText("兴趣地域");	
			break;		
		case DefineUser.TYPE_CROWD:
			txt_title.setText("创建群");
			cap_groupid.setText("群ID");
			cap_groupname.setText("群名称");
			cap_type.setText("关  键  字");
			cap_enyear.setText("兴趣地域");			
			break;
		case DefineUser.TYPE_MYCLASS:
			txt_title.setText("创建班");
			cap_groupid.setText("班ID");
			cap_groupname.setText("班名称");
			cap_type.setText("所属院系");
			cap_enyear.setText("入学年份");	
			break;
		case DefineUser.TYPE_DEPART:
			txt_title.setText("创建部门");
			cap_groupid.setText("部门ID");
			cap_groupname.setText("部门名称");
			cap_type.setText("所属父项");
			cap_enyear.setText("主管部门");	
			break;		
		case DefineUser.TYPE_PARTY:
			txt_title.setText("创建会议室");
			cap_groupid.setText("会议ID");
			cap_groupname.setText("会议名称");
			cap_type.setText("所属父项");
			cap_enyear.setText("主管部门");	
			break;
		case DefineUser.TYPE_GROUP:
			txt_title.setText("创建俱乐部");
			cap_groupid.setText("输入部ID");
			cap_groupname.setText("输入部名");
			cap_type.setText("所属省份");
			cap_enyear.setText("所在城市");	
			break;
		case DefineUser.TYPE_CITY:
			txt_title.setText("创建地域");
			cap_groupid.setText("地域ID");
			cap_groupname.setText("地域名称");
			cap_type.setText("所属省份");
			cap_enyear.setText("所在城市");	
			break;		
	
		default:
			txt_title.setText("创建群");
			cap_groupid.setText("群ID");
			cap_groupname.setText("输入群名称");
			cap_type.setText("关  键  字");
			cap_enyear.setText("兴趣地域");				
			break;
		}			
	}	

	protected void setHint() {
		SpannableString s1,s2,s3,s4;		
		switch (groupType) {
		case DefineUser.TYPE_FRIEND:

			break;		
		case DefineUser.TYPE_CROWD:
			txt_groupid.setText("群ID由服务器决定");			
			s1 = new SpannableString("请输入群名称");//这里输入自己想要的提示文字
			txt_groupname.setHint(s1);
			s2 = new SpannableString("请选择关键字");//这里输入自己想要的提示文字
			txt_type.setHint(s2);
			s3 = new SpannableString("请选择兴趣地域");//这里输入自己想要的提示文字
			txt_enyear.setHint(s3);	
			s4 = new SpannableString("请选择开放级别");//这里输入自己想要的提示文字
			txt_openlevel.setHint(s4);			
			break;
		case DefineUser.TYPE_MYCLASS:	
			txt_groupid.setText("班ID由服务器决定");			
			s1 = new SpannableString("请输入班名称");//这里输入自己想要的提示文字
			txt_groupname.setHint(s1);
			s2 = new SpannableString("请选择所属院系");//这里输入自己想要的提示文字
			txt_type.setHint(s2);
			s3 = new SpannableString("请选择入学年份");//这里输入自己想要的提示文字
			txt_enyear.setHint(s3);	
			s4 = new SpannableString("请选择开放级别");//这里输入自己想要的提示文字
			txt_openlevel.setHint(s4);				
			break;
		case DefineUser.TYPE_DEPART:
			txt_groupid.setText("部门ID由服务器决定");			
			s1 = new SpannableString("请输入部门名称");//这里输入自己想要的提示文字
			txt_groupname.setHint(s1);
			s2 = new SpannableString("请选择所属父项");//这里输入自己想要的提示文字
			txt_type.setHint(s2);
			s3 = new SpannableString("请选择主管部门");//这里输入自己想要的提示文字
			txt_enyear.setHint(s3);	
			s4 = new SpannableString("请选择开放级别");//这里输入自己想要的提示文字
			txt_openlevel.setHint(s4);				
			break;		
		case DefineUser.TYPE_PARTY:
			txt_groupid.setText("会议室ID由服务器决定");			
			s1 = new SpannableString("请输入会议室名称");//这里输入自己想要的提示文字
			txt_groupname.setHint(s1);
			s2 = new SpannableString("请选择所属父项");//这里输入自己想要的提示文字
			txt_type.setHint(s2);
			s3 = new SpannableString("请选择主管部门");//这里输入自己想要的提示文字
			txt_enyear.setHint(s3);	
			s4 = new SpannableString("请选择开放级别");//这里输入自己想要的提示文字
			txt_openlevel.setHint(s4);				
			break;
		case DefineUser.TYPE_GROUP:
			txt_groupid.setText("俱乐部ID由服务器决定");			
			s1 = new SpannableString("请输入俱乐部名称");//这里输入自己想要的提示文字
			txt_groupname.setHint(s1);
			s2 = new SpannableString("请选择所属省份");//这里输入自己想要的提示文字
			txt_type.setHint(s2);
			s3 = new SpannableString("请选择所在城市");//这里输入自己想要的提示文字
			txt_enyear.setHint(s3);	
			s4 = new SpannableString("请选择开放级别");//这里输入自己想要的提示文字
			txt_openlevel.setHint(s4);				
			break;
		case DefineUser.TYPE_CITY:
			txt_groupid.setText("地域ID由服务器决定");			
			s1 = new SpannableString("请输入地域名称");//这里输入自己想要的提示文字
			txt_groupname.setHint(s1);
			s2 = new SpannableString("请选择所属省份");//这里输入自己想要的提示文字
			txt_type.setHint(s2);
			s3 = new SpannableString("请选择所在城市");//这里输入自己想要的提示文字
			txt_enyear.setHint(s3);	
			s4 = new SpannableString("请选择开放级别");//这里输入自己想要的提示文字
			txt_openlevel.setHint(s4);				
			break;		
	
		default:
			txt_title.setText("群资料");
			cap_groupid.setText("群ID");
			cap_groupname.setText("输入群名称");
			cap_type.setText("关  键  字");
			cap_enyear.setText("兴趣地域");				
			break;
		}			
	}	
	
	protected void setListener() {
		img_back.setOnClickListener(this);		
		lay_right.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {

			}
		});
	//	btn_satrtchat.setOnClickListener(this);
		btn_askcreate.setOnClickListener(this); 
		btn_paycreate.setOnClickListener(this);
		btn_admincreate.setOnClickListener(this);	
		lay_image.setOnClickListener(this);			
		lay_type.setOnClickListener(this); 
		lay_enyear.setOnClickListener(this); 
		lay_openlevel.setOnClickListener(this); 
 		
	}	
		
	@Override
	public void onClick(View arg0) {
		int id = arg0.getId();
		if (id == R.id.img_back) {
			Utils.finish(NewGroupActivity.this);
			//finish();
			//finish(NewGroupActivity.this);
		} else if (id == R.id.btn_askcreate) {
			if (checkValid(0) == 0) {
				AskInfo uinfo = new AskInfo(strGroupName, nImage, nType, nEnyear);
				uinfo.message = strMessage;
				createGroup(uinfo);
			}
		} else if (id == R.id.btn_paycreate) {
			if (checkValid(0) == 0) {
				AskInfo uinfo = new AskInfo(strGroupName, nImage, nType, nEnyear);
				uinfo.message = strMessage;
				createGroup(uinfo);
			}
		} else if (id == R.id.btn_admincreate) {
			if (checkValid(1) == 0) {
				GroupInfo uinfo = new GroupInfo(strGroupName, nImage, nType, nEnyear);
				uinfo.level = 2;
				uinfo.index = 10;
				uinfo.openlevel = iLevel;
				newGroup(uinfo);
			}
		} else if (id == R.id.rl_openlevel) {
			new EditOpenLevelDialog(NewGroupActivity.this, iLevel,
					new EditOpenLevelDialog.OnSetListener() {
						@Override
						public void onSelect(int level) {
							iLevel = level;
							txt_openlevel.setText(OpenLevelUtils.getOpenLevelText(iLevel));
						}
					}).show();
		} else if (id == R.id.rl_type) {//年龄范围
			Select_Type();
		} else if (id == R.id.rl_enyear) {//修改城市
			Select_Enyear();
		} else if (id == R.id.rl_group_pic) {//修改头像
			change_image();
		}
	} 
	
	protected void Select_Type() {
		switch (groupType) {
		case DefineUser.TYPE_FRIEND:
			change_keyword();
			break;		
		case DefineUser.TYPE_CROWD:
			change_keyword();		
			break;
		case DefineUser.TYPE_MYCLASS:
			change_grade();					
			break;
		case DefineUser.TYPE_DEPART:
			change_depart();
			break;		
		case DefineUser.TYPE_PARTY:
			change_depart();
			break;
		case DefineUser.TYPE_GROUP:
			change_city();	
			break;
		case DefineUser.TYPE_CITY:
			change_city();
			break;			
		default:
			change_keyword();		
			break;
		}  		
	}	

	protected void Select_Enyear() {
		switch (groupType) {
		case DefineUser.TYPE_FRIEND:
			change_address();
			break;		
		case DefineUser.TYPE_CROWD:
			change_address();		
			break;
		case DefineUser.TYPE_MYCLASS:
			change_grade();					
			break;
		case DefineUser.TYPE_DEPART:
			change_depart();
			break;		
		case DefineUser.TYPE_PARTY:
			change_depart();
			break;
		case DefineUser.TYPE_GROUP:
			change_city();	
			break;
		case DefineUser.TYPE_CITY:
			change_city();
			break;			
		default:
			change_address();		
			break;
		}  		
	}	
		
	public void change_address() {
		new AddressPickerDialog(NewGroupActivity.this,
				AddressPickerDialog.THEME_HOLO_LIGHT,2,false,
				new AddressPickerDialog.OnAddressSetListener() {
					@Override
					public void onAddressSelect(int address) {
						nEnyear = address;
						txt_enyear.setText(AddressUtils.getAddress(address));						
						String textString = "" + address;
						Utils.showLongToast(NewGroupActivity.this, textString);
					}
				}).show();
	}

	public void change_city() {
		new CityPickerDialog(NewGroupActivity.this,
				CityPickerDialog.THEME_HOLO_LIGHT,16,false,
				new CityPickerDialog.OnCitySetListener() {
					@Override
					//public void onCitySelect(int province,int city) {					
					public void onCitySelect(int city) {
						nType = city;
						txt_type.setText(CityUtils.getCityTypeName(city));						
						txt_enyear.setText(CityUtils.getCityName(city));						
						String textString = "" + city;
						Utils.showLongToast(NewGroupActivity.this, textString);
					}
				}).show();
	}	
	
	public void change_depart() {
		new DeptPickerDialog(NewGroupActivity.this,
				DeptPickerDialog.THEME_HOLO_LIGHT,15,false,
				new DeptPickerDialog.OnDeptSetListener() {
					@Override
					public void onDeptSelect(int address) {
						nType = address;
						txt_type.setText(DepartUtils.getDepartName(address));						
						txt_enyear.setText(DepartUtils.getDepartTypeName(address));						
						String textString = "" + address;
						Utils.showLongToast(NewGroupActivity.this, textString);
					}
				}).show();
	}

	public void change_grade() {
		new GradePickerDialog(NewGroupActivity.this,
				GradePickerDialog.THEME_HOLO_LIGHT,24,nEnyear,
				new GradePickerDialog.OnGradeSetListener() {
					@Override
					public void onGradeSelect(int minage,int maxage) {
						nType = minage;
						nEnyear = maxage;	
						txt_type.setText(CollegeUtils.getCollege(nType));	
						txt_enyear.setText("" + nEnyear);							
						String textString = "" + minage+"-" + maxage;
				//		txt_age.setText(""+ageMin+"-"+ageMax);						
						Utils.showLongToast(NewGroupActivity.this, textString);
					}
				}).show();
	}	
	
	public void change_keyword() {
		new KeyPickerDialog(NewGroupActivity.this,
				KeyPickerDialog.THEME_HOLO_LIGHT,0x100,
				new KeyPickerDialog.OnKeySetListener() {
					@Override
					public void onKeySelect(int keyword) {
						String textString = KeywordUtils.getKeyword(keyword);
						nType = keyword;
						txt_type.setText(KeywordUtils.getKeyword(keyword));						
						Utils.showLongToast(NewGroupActivity.this, textString);
					}
				}).show();
	}
	public void change_image(){
		 
		new ImagePickerDialog(this,
				ImagePickerDialog.THEME_HOLO_LIGHT,
				new ImagePickerDialog.OnImageSetListener() {
					@Override
					public void onImageSelect(int imageid) {
						nImage = imageid;
					//	img_user.setImageResource(ImagesUtils.images[imageid]);
				        img_photo.setImageResource(ImagesUtils.images[nImage]);						
					}
				}).show();	
	}
	
	private int checkValid(int nMode) {
		strGroupName = txt_groupname.getText().toString().trim();
		strMessage = txt_editreason.getText().toString().trim();

		if (TextUtils.isEmpty(strGroupName)){
		//	Utils.showShortToast(NewGroupActivity.this, "请填写用户名！");
			String str = "请填写群组名！";			
			switch (groupType) {
			case DefineUser.TYPE_FRIEND:
				break;		
			case DefineUser.TYPE_CROWD:
				str = "请填写群组名！";		
				break;
			case DefineUser.TYPE_MYCLASS:
				str = "请填写班级名！";				
				break;
			case DefineUser.TYPE_DEPART:
				str = "请填写部门名！";
				break;		
			case DefineUser.TYPE_PARTY:
				str = "请填写会议室名！";
				break;
			case DefineUser.TYPE_GROUP:
				str = "请填写俱乐部名！";	
				break;
			case DefineUser.TYPE_CITY:
				str = "请填写地域名！";
				break;			
			default:
			}
			Utils.showShortToast(NewGroupActivity.this, str);			
			txt_groupname.requestFocus();			
            return 1;
	    }
		if (strGroupName.length() < 3){
			Utils.showShortToast(NewGroupActivity.this, "群组名至少要3个英文字符或者两个汉字！");	
			txt_groupname.requestFocus();			
            return 2;
	    }
		if (nType <= 0){
			String str = "请选择所属部门！";
			switch (groupType) {
			case DefineUser.TYPE_FRIEND:
				break;		
			case DefineUser.TYPE_CROWD:
				str = "请选择关键字！";		
				break;
			case DefineUser.TYPE_MYCLASS:
				str = "请选择所属院系！";				
				break;
			case DefineUser.TYPE_DEPART:
				str = "请选择所属部门！";
				break;		
			case DefineUser.TYPE_PARTY:
				str = "请选择所属部门！";
				break;
			case DefineUser.TYPE_GROUP:
				str = "请选择所属地区！";	
				break;
			case DefineUser.TYPE_CITY:
				str = "请选择所属地区！";
				break;			
			default:
			}
			Utils.showShortToast(NewGroupActivity.this, str);				
			txt_type.requestFocus();			
            return 3;
	    }
		if (nEnyear <= 0){
			String str = "请选择所属部门！";
			switch (groupType) {
			case DefineUser.TYPE_FRIEND:
				break;		
			case DefineUser.TYPE_CROWD:
				str = "请选择兴趣地域！";		
				break;
			case DefineUser.TYPE_MYCLASS:
				str = "请选择所属院系！";				
				break;
			case DefineUser.TYPE_DEPART:
				nEnyear = nType;
				break;		
			case DefineUser.TYPE_PARTY:
				nEnyear = nType;
				break;
			case DefineUser.TYPE_GROUP:
				nEnyear = nType;	
				break;
			case DefineUser.TYPE_CITY:
				nEnyear = nType;
				break;			
			default:
			}
			if(nEnyear <= 0){
			    Utils.showShortToast(NewGroupActivity.this, str);				
			    txt_enyear.requestFocus();			
                return 4;
			}
	    }
		if (nMode <= 0 && TextUtils.isEmpty(strMessage)){

			Utils.showShortToast(NewGroupActivity.this, "请填写申请理由!");				
			txt_editreason.requestFocus();			
            return 3;
	    }		
        return 0;
	}
	/**
	 * onActivityResult
	 */
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (resultCode == RESULT_OK) { // 清空消息
			if (requestCode == REQUEST_CODE_ADD_TO_CONTACT) { // 加好友
				//EMMessage deleteMsg = (EMMessage) adapter.getItem(data.getIntExtra("position", -1)); 
				String sendstr = data.getStringExtra("edittext");

	//			addContact(userId,sendstr);
			}else if(requestCode == REQUEST_CODE_ADD_TO_BLACKLIST){
	
			}
		}
	}

	public void createGroup(AskInfo uinfo){
		int nDestid = uinfo.destid;
		if(nDestid == GloableParams.m_szUserId){//判断是否是自己
		//	startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "不能添加自己"));
		//	return;
		}	
		if(FriendUtils.getFriendList(nDestid)>0){//判断是否已经是好友
		//	startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "此用户已是你的好友"));
		//	return;
		}
		if(TextUtils.isEmpty(GloableParams.m_szServerIp)){//判断是否已经登录服务器
			Utils.showLongToast(NewGroupActivity.this, "你还没有登录服务器!");
			return;
		}		
	//	getLoadingDialog("正在发送请求...").show();		
		AskClient.AskCreateGroup(groupType,uinfo,new askCallBack(){	
			@Override
			public void onSuccess(int statusCode, String message) {
	//			getLoadingDialog("正在发送请求...").dismiss();	
				final String str = message;
				runOnUiThread(new Runnable() {
					public void run() {
						Utils.showLongToast(NewGroupActivity.this, str);
					}
				});				
			}
			@Override
			public void onFailure(int statusCode,  String message) {
				getLoadingDialog("正在发送请求...").dismiss();
				final String str = message;
				runOnUiThread(new Runnable() {
					public void run() {
						Utils.showLongToast(NewGroupActivity.this, str);
					}
				});	
			}
		});	 
	}		

	public void newGroup(GroupInfo uinfo){

		if(TextUtils.isEmpty(GloableParams.m_szServerIp)){//判断是否已经登录服务器
			Utils.showLongToast(NewGroupActivity.this, "你还没有登录服务器!");
			return;
		}	
		if(GroupManger.getMyAdminPower( )<=0){//判断自己是否是系统管理员
			Utils.showLongToast(NewGroupActivity.this, "你不是系统管理员，无权创建!");
			return;			
		}		
		getLoadingDialog("正在发送请求...").show();	
		boolean isStart =
		EditClient.newGroup(groupType,uinfo,new askCallBack(){	
			@Override
			public void onSuccess(int statusCode, String message) {
				getLoadingDialog("正在发送请求...").dismiss();	
				final String str = message;
				runOnUiThread(new Runnable() {
					public void run() {
						Utils.showLongToast(NewGroupActivity.this, str);
					}
				});				
			}
			@Override
			public void onFailure(int statusCode,  String message) {
				getLoadingDialog("正在发送请求...").dismiss();
				final String str = message;
				runOnUiThread(new Runnable() {
					public void run() {
						Utils.showLongToast(NewGroupActivity.this, str);
					}
				});	
			}
		});	
		if(!isStart){//没有投递成功
			getLoadingDialog("正在发送请求...").dismiss();			
			Utils.showLongToast(NewGroupActivity.this, "系统忙，稍后再试!");
			return;			
		}		
	}		

	/**
	 * 返回
	 * 
	 * @param view
	 */
	public void back(View view) {
		//finish();
		Utils.finish(NewGroupActivity.this);		
	}
	

}
