|
|
@@ -35,6 +35,7 @@ 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.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
import com.xzjmyk.pm.activity.view.SmoothCheckBox;
|
|
|
import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
@@ -53,6 +54,8 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
private String code;
|
|
|
@ViewInject(R.id.search_edit)
|
|
|
private ClearEditText search_edit;
|
|
|
+
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
|
|
|
private String cu_code;
|
|
|
private String cu_name;
|
|
|
@@ -75,6 +78,11 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
private void initListener() {
|
|
|
+
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mlist.getRefreshableView());
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
mlist.setMode(PullToRefreshBase.Mode.DISABLED);
|
|
|
mlist.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
@Override
|
|
|
@@ -93,13 +101,16 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
BusinessSelectCustomerActivity.BussinessDetailAdapter.ViewHolder holder = (BussinessDetailAdapter.ViewHolder) view.getTag();
|
|
|
cu_code = holder.code;
|
|
|
cu_name = holder.tv_business_name.getText().toString();
|
|
|
- final boolean flag = !mData.get(position - 1).isChecked;
|
|
|
+ final boolean flag = !mAdapter.getMdata().get(position - 1).isChecked;
|
|
|
Log.i(TAG, "onClick:" + position + " check:" + !flag);
|
|
|
+ for (Business model : mAdapter.getMdata()) {
|
|
|
+ model.setIsChecked(false);
|
|
|
+ }
|
|
|
+ //把源数据清空
|
|
|
for (Business model : mData) {
|
|
|
model.setIsChecked(false);
|
|
|
}
|
|
|
-
|
|
|
- mData.get(position - 1).setIsChecked(flag);
|
|
|
+ mAdapter.getMdata().get(position - 1).setIsChecked(flag);
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
@@ -117,7 +128,11 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
-
|
|
|
+ if (!StringUtils.isEmpty(search_edit.getText().toString())) {
|
|
|
+ mAdapter.getFilter().filter(search_edit.getText().toString());
|
|
|
+ } else {
|
|
|
+ mAdapter.getFilter().filter("");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -162,6 +177,11 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
private Context ct;
|
|
|
private ArrayList<Business> mdata = new ArrayList<>();
|
|
|
private LayoutInflater inflater;
|
|
|
+ private String searchkeys;
|
|
|
+
|
|
|
+ public ArrayList<Business> getMdata() {
|
|
|
+ return mdata;
|
|
|
+ }
|
|
|
|
|
|
public BussinessDetailAdapter(Context ct, ArrayList<Business> data) {
|
|
|
this.ct = ct;
|
|
|
@@ -218,15 +238,64 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
holder.cb_left.setEnabled(false);
|
|
|
holder.cb_left.setClickable(false);
|
|
|
holder.code=mdata.get(position).getCode();
|
|
|
- holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
holder.cb_left.setChecked(mdata.get(position).isChecked(), mdata.get(position).isChecked());
|
|
|
- holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(searchkeys)){
|
|
|
+ // holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
+
|
|
|
+ //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{
|
|
|
+ holder.tv_business_name.setText(mdata.get(position).getName());
|
|
|
+
|
|
|
+ holder.tv_business_leader.setText("负责人:"+mdata.get(position).getLeader());
|
|
|
+ }
|
|
|
+
|
|
|
return convertView;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Filter getFilter() {
|
|
|
- return null;
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ searchResults.values=newArry;
|
|
|
+ searchResults.count=newArry.size();
|
|
|
+ }
|
|
|
+ return searchResults;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
|
+ //装配数据
|
|
|
+ mdata= (ArrayList<Business>) results.values;
|
|
|
+ searchkeys=constraint.toString();
|
|
|
+ if (mAdapter.getCount() == 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -258,6 +327,10 @@ public class BusinessSelectCustomerActivity extends BaseActivity {
|
|
|
}
|
|
|
mAdapter = new BussinessDetailAdapter(ct, mData);
|
|
|
mlist.setAdapter(mAdapter);
|
|
|
+ if (mAdapter.getCount()==0){
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+
|
|
|
+ }
|
|
|
break;
|
|
|
case 2:
|
|
|
progressDialog.dismiss();
|