|
|
@@ -6,6 +6,7 @@ import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.text.Editable;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.text.TextWatcher;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
@@ -19,7 +20,6 @@ import android.widget.Filter;
|
|
|
import android.widget.Filterable;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.TextView;
|
|
|
-import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -34,9 +34,11 @@ import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
+import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
import com.xzjmyk.pm.activity.view.SmoothCheckBox;
|
|
|
import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
@@ -55,7 +57,7 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
private String code;
|
|
|
@ViewInject(R.id.search_edit)
|
|
|
private ClearEditText search_edit;
|
|
|
-
|
|
|
+
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
|
|
|
private String cu_code;
|
|
|
@@ -69,13 +71,13 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
initData();
|
|
|
initListener();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void initView() {
|
|
|
ViewUtils.inject(this);
|
|
|
getSupportActionBar().setTitle("选择客户");
|
|
|
- if (getIntent()!=null){
|
|
|
- code=getIntent().getStringExtra("code");
|
|
|
-
|
|
|
+ if (getIntent() != null) {
|
|
|
+ code = getIntent().getStringExtra("code");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -126,15 +128,15 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
search_edit.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
- if(mAdapter==null){
|
|
|
- Toast.makeText(getApplication(),"网络异常,请稍后再试",Toast.LENGTH_SHORT);
|
|
|
- }else{
|
|
|
- if (!StringUtils.isEmpty(search_edit.getText().toString())) {
|
|
|
+ if (mAdapter == null) {
|
|
|
+ ToastUtil.showToast(ct, R.string.networks_out);
|
|
|
+ } else {
|
|
|
+ if (!TextUtils.isEmpty(search_edit.getText())) {
|
|
|
mAdapter.getFilter().filter(search_edit.getText().toString());
|
|
|
} else {
|
|
|
mAdapter.getFilter().filter("");
|
|
|
@@ -152,7 +154,7 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
|
|
|
private void initData() {
|
|
|
sendHttpResquest(Constants.HTTP_SUCCESS_INIT, code);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -165,15 +167,11 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
switch (item.getItemId()) {
|
|
|
case R.id.btn_save:
|
|
|
- if (!StringUtils.isEmpty(code)&&!StringUtils.isEmpty(cu_code)&&!StringUtils.isEmpty(cu_name))
|
|
|
- {
|
|
|
- LogUtil.prinlnLongMsg("Arison",code+"|"+cu_code+"|"+cu_name);
|
|
|
+ if (canSave()) {
|
|
|
+ LogUtil.prinlnLongMsg("Arison", code + "|" + cu_code + "|" + cu_name);
|
|
|
sendHttpResquest(2, code, cu_code, cu_name);
|
|
|
- }else{
|
|
|
- ToastMessage("缺少参数 bt_code,cu_code,cu_name!");
|
|
|
}
|
|
|
-
|
|
|
- break;
|
|
|
+ break;
|
|
|
case android.R.id.home:
|
|
|
onBackPressed();
|
|
|
break;
|
|
|
@@ -181,7 +179,18 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public class BussinessDetailAdapter extends BaseAdapter implements Filterable {
|
|
|
+ private boolean canSave() {
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ ToastUtil.showToast(ct, R.string.error_system_findunknow_error);
|
|
|
+ return false;
|
|
|
+ } else if (StringUtils.isEmpty(cu_code) || StringUtils.isEmpty(cu_name)) {
|
|
|
+ ToastUtil.showToast(ct, R.string.CRM_pleasePickClientFirst);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public class BussinessDetailAdapter extends BaseAdapter implements Filterable {
|
|
|
private Context ct;
|
|
|
private ArrayList<Business> mdata = new ArrayList<>();
|
|
|
private LayoutInflater inflater;
|
|
|
@@ -199,7 +208,7 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
- return mdata.size();
|
|
|
+ return ListUtils.getSize(mdata);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -225,7 +234,7 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
} else {
|
|
|
holder = (ViewHolder) convertView.getTag();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// holder.cb_left.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener() {
|
|
|
// @Override
|
|
|
// public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked) {
|
|
|
@@ -245,50 +254,50 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
holder.cb_left.setFocusable(false);
|
|
|
holder.cb_left.setEnabled(false);
|
|
|
holder.cb_left.setClickable(false);
|
|
|
- holder.code=mdata.get(position).getCode();
|
|
|
+ holder.code = mdata.get(position).getCode();
|
|
|
holder.cb_left.setChecked(mdata.get(position).isChecked(), mdata.get(position).isChecked());
|
|
|
-
|
|
|
- if (!StringUtils.isEmpty(searchkeys)){
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(searchkeys)) {
|
|
|
holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
|
|
|
- holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
+ holder.tv_business_leader.setText("负责人:" + mdata.get(position).getLeader());
|
|
|
// CommonUtil.textSpanForStyle(holder.tv_business_name, mdata.get(position).getName(),
|
|
|
// searchkeys, ct.getResources().getColor(R.color.yellow));
|
|
|
// CommonUtil.textSpanForStyle(holder.tv_business_leader, "负责人:"+mdata.get(position).getLeader(),
|
|
|
// searchkeys, ct.getResources().getColor(R.color.yellow));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
|
|
|
- holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
+ holder.tv_business_leader.setText("负责人:" + mdata.get(position).getLeader());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return convertView;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Filter getFilter() {
|
|
|
- return new Filter() {
|
|
|
+ return new Filter() {
|
|
|
@Override
|
|
|
protected FilterResults performFiltering(CharSequence constraint) {
|
|
|
//过滤数据
|
|
|
FilterResults searchResults = new FilterResults();
|
|
|
|
|
|
- if (constraint == null || constraint.length() == 0){
|
|
|
-
|
|
|
- searchResults.values=mData;
|
|
|
- searchResults.count=mData.size();
|
|
|
- }else{
|
|
|
- mdata=mData;
|
|
|
- ArrayList<Business> newArry=new ArrayList<Business>();
|
|
|
- for (int i=0;i<mdata.size();i++){
|
|
|
- Business model=mdata.get(i);
|
|
|
- if (model.getName().contains(constraint)||model.getLeader().contains(constraint)){
|
|
|
- newArry.add(model);
|
|
|
- }
|
|
|
+ if (constraint == null || constraint.length() == 0) {
|
|
|
+
|
|
|
+ searchResults.values = mData;
|
|
|
+ searchResults.count = mData.size();
|
|
|
+ } else {
|
|
|
+ mdata = mData;
|
|
|
+ ArrayList<Business> newArry = new ArrayList<Business>();
|
|
|
+ for (int i = 0; i < mdata.size(); i++) {
|
|
|
+ Business model = mdata.get(i);
|
|
|
+ if (model.getName().contains(constraint) || model.getLeader().contains(constraint)) {
|
|
|
+ newArry.add(model);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- searchResults.values=newArry;
|
|
|
- searchResults.count=newArry.size();
|
|
|
+ searchResults.values = newArry;
|
|
|
+ searchResults.count = newArry.size();
|
|
|
}
|
|
|
return searchResults;
|
|
|
}
|
|
|
@@ -296,8 +305,8 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
@Override
|
|
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
|
//装配数据
|
|
|
- mdata= (ArrayList<Business>) results.values;
|
|
|
- searchkeys=constraint.toString();
|
|
|
+ mdata = (ArrayList<Business>) results.values;
|
|
|
+ searchkeys = constraint.toString();
|
|
|
if (mAdapter.getCount() == 0) {
|
|
|
|
|
|
}
|
|
|
@@ -315,29 +324,29 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Handler mHandler=new Handler(){
|
|
|
+ private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
- switch (msg.what){
|
|
|
+ switch (msg.what) {
|
|
|
case Constants.HTTP_SUCCESS_INIT:
|
|
|
progressDialog.dismiss();
|
|
|
Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
- JSONArray jsonArray= JSON.parseObject(msg.getData().getString("result")).getJSONArray("customers");
|
|
|
- if (jsonArray!=null){
|
|
|
- for (int i = 0; i < jsonArray.size(); i++){
|
|
|
- JSONObject object=jsonArray.getJSONObject(i);
|
|
|
- Business model = new Business();
|
|
|
- model.setName(object.getString("CU_NAME"));
|
|
|
- model.setCode(object.getString("CU_CODE"));
|
|
|
- model.setLeader(object.getString("CU_CONTACT"));
|
|
|
- mData.add(model);
|
|
|
- }
|
|
|
- }
|
|
|
+ JSONArray jsonArray = JSON.parseObject(msg.getData().getString("result")).getJSONArray("customers");
|
|
|
+ if (jsonArray != null) {
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject object = jsonArray.getJSONObject(i);
|
|
|
+ Business model = new Business();
|
|
|
+ model.setName(object.getString("CU_NAME"));
|
|
|
+ model.setCode(object.getString("CU_CODE"));
|
|
|
+ model.setLeader(object.getString("CU_CONTACT"));
|
|
|
+ mData.add(model);
|
|
|
+ }
|
|
|
+ }
|
|
|
mAdapter = new BussinessDetailAdapter(ct, mData);
|
|
|
mlist.setAdapter(mAdapter);
|
|
|
- if (mAdapter.getCount()==0){
|
|
|
+ if (mAdapter.getCount() == 0) {
|
|
|
mEmptyLayout.showEmpty();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
break;
|
|
|
case 2:
|
|
|
@@ -350,13 +359,13 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
jumpToStateActivity();
|
|
|
finish();
|
|
|
}
|
|
|
- },3000);
|
|
|
-
|
|
|
+ }, 3000);
|
|
|
+
|
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
progressDialog.dismiss();
|
|
|
Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
- // ToastMessage(JSON.parseObject(msg.getData().getString("result")).getString("exceptionInfo"));
|
|
|
+ // ToastMessage(JSON.parseObject(msg.getData().getString("result")).getString("exceptionInfo"));
|
|
|
Crouton.makeText(BusinessSelectCustomerActivity.this, msg.getData().getString("result"), Style.ALERT).show();
|
|
|
break;
|
|
|
}
|
|
|
@@ -369,25 +378,25 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
startActivity(intent);
|
|
|
}
|
|
|
|
|
|
- private void sendHttpResquest(int what,String code){
|
|
|
+ private void sendHttpResquest(int what, String code) {
|
|
|
progressDialog.show();
|
|
|
- String url= Constants.getAppBaseUrl(ct)+"mobile/crm/getCustomerbySeller.action";
|
|
|
- Map<String,Object> params=new HashMap<>();
|
|
|
- params.put("sellercode", CommonUtil.getSharedPreferences(ct,"erp_username"));
|
|
|
- LinkedHashMap<String , Object> headers=new LinkedHashMap<>();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "mobile/crm/getCustomerbySeller.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("sellercode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, what, null, null, "post");
|
|
|
}
|
|
|
|
|
|
- private void sendHttpResquest(int what,String code,String cu_code,String cu_name){
|
|
|
+ private void sendHttpResquest(int what, String code, String cu_code, String cu_name) {
|
|
|
progressDialog.show();
|
|
|
- String url= Constants.getAppBaseUrl(ct)+"mobile/crm/updateBusinessChanceCust.action";
|
|
|
- Map<String,Object> params=new HashMap<>();
|
|
|
- params.put("sellercode", CommonUtil.getSharedPreferences(ct,"erp_username"));
|
|
|
- params.put("bc_code",code);
|
|
|
- params.put("cu_code",cu_code);
|
|
|
- params.put("cu_name",cu_name);
|
|
|
- LinkedHashMap<String , Object> headers=new LinkedHashMap<>();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "mobile/crm/updateBusinessChanceCust.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("sellercode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ params.put("bc_code", code);
|
|
|
+ params.put("cu_code", cu_code);
|
|
|
+ params.put("cu_name", cu_name);
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, what, null, null, "post");
|
|
|
}
|