package com.bigdo.app; import org.json.JSONObject; import com.bigdo.common.Login; import com.bigdo.common.RConfig; import com.bigdo.common.RState; import com.bigdo.common.User; import com.bigdo.util.WSCheck; import com.bigdo.util.WSHelper; import android.annotation.SuppressLint; import android.app.Activity; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.method.ScrollingMovementMethod; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; public class Me_MyNeeds_Activity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.me_myneeds_activity); View activityTitle = (View) this.findViewById(R.id.bd_title_host); TextView bd_title_name = (TextView) activityTitle .findViewById(R.id.bd_title_name); bd_title_name.setText("我的需求"); TextView bd_title_operate = (TextView) activityTitle .findViewById(R.id.bd_title_operate); bd_title_operate.setText("提 交"); bd_title_operate.setVisibility(View.VISIBLE); bd_title_operate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { saveNeeds(); } }); ImageButton bd_title_back = (ImageButton) activityTitle .findViewById(R.id.bd_title_back); bd_title_back.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); EditText needs = (EditText) findViewById(R.id.needs); needs.setMovementMethod(ScrollingMovementMethod.getInstance()); } public void saveNeeds() { User user = Login.get(this); if (user != null) { EditText receiveObj = (EditText) findViewById(R.id.receive); EditText needsObj = (EditText) findViewById(R.id.needs); String receive = receiveObj.getText().toString(); String needs = needsObj.getText().toString(); if (receive == null || "".equals(receive.trim())) { receiveObj.setError("请输入收件人"); receiveObj.requestFocus(); showInfo("请输入收件人"); return; } if (needs == null || "".equals(needs.trim())) { needsObj.setError("请输入需求"); needsObj.requestFocus(); showInfo("请输入需求"); return; } JSONObject jparam = new JSONObject(); try { jparam.put("user", user.user); jparam.put("receive", receive); jparam.put("needs", needs); } catch (Exception e) { showInfo("准备请求参数出错."); return; } showProgress("提交中..."); String data = jparam.toString(); String url = RConfig.needs(this); WSHelper ws = new WSHelper(this, "", false, handler, url, "", WSHelper.getStringEntity(data), 0, 0, 0, 0, WSHelper.POST); ws.start(); Log.e("saveNeeds", url); Log.e("saveNeeds_data", data); } else { showInfo("请先登录."); } } @SuppressLint("HandlerLeak") protected Handler handler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.arg1 == RState.WSCall) { hiddenProgress(); if (WSCheck.Json(Me_MyNeeds_Activity.this, msg) != null) { messageBox("提交成功,我们会尽快查阅", new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { finish(); } }); } } } }; @Override public void onClearData() { // TODO Auto-generated method stub } @Override public void onVideoBroadcast(Intent intent) { // TODO Auto-generated method stub } }