|
|
@@ -80,11 +80,10 @@ public class SelectActivity extends BaseActivity {
|
|
|
String message = msg.getData().getString("result");
|
|
|
if (StringUtils.isEmpty(message)) return;
|
|
|
JsonValidator validator = new JsonValidator();
|
|
|
- if (!validator.validate(message))return;
|
|
|
+ if (!validator.validate(message)) return;
|
|
|
JSONObject object = JSON.parseObject(message);
|
|
|
if (object == null) return;
|
|
|
-
|
|
|
- if ("mobile/common/getCombo.action".equals(action)){//下拉接口解析
|
|
|
+ if ("mobile/common/getCombo.action".equals(action) || isSingle) {//下拉接口解析
|
|
|
if (!StringUtils.isEmpty(key)) {
|
|
|
if (StringUtils.isEmpty(showKey)) return;
|
|
|
if (object.containsKey(key)) {
|
|
|
@@ -98,7 +97,7 @@ public class SelectActivity extends BaseActivity {
|
|
|
SelectBean bean = null;
|
|
|
JSONObject chce = null;
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
|
- if (array.get(i) instanceof JSONObject){
|
|
|
+ if (array.get(i) instanceof JSONObject) {
|
|
|
chce = array.getJSONObject(i);
|
|
|
if (chce == null) continue;
|
|
|
bean = new SelectBean();
|
|
|
@@ -109,7 +108,7 @@ public class SelectActivity extends BaseActivity {
|
|
|
formBeaan.add(bean);
|
|
|
}
|
|
|
}
|
|
|
- if (array.get(i) instanceof String){
|
|
|
+ if (array.get(i) instanceof String) {
|
|
|
bean = new SelectBean();
|
|
|
bean.setName(array.get(i).toString());
|
|
|
bean.setObject(array.get(i));
|
|
|
@@ -119,30 +118,30 @@ public class SelectActivity extends BaseActivity {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {//当返回的没有不需要key值时候
|
|
|
}
|
|
|
- }else{//多选解析
|
|
|
-
|
|
|
- String dataStr=JSON.parseObject(message).getString("data");
|
|
|
- JSONArray datas=JSON.parseArray(dataStr);//values
|
|
|
+ } else {//多选解析
|
|
|
+
|
|
|
+ String dataStr = JSON.parseObject(message).getString("data");
|
|
|
+ JSONArray datas = JSON.parseArray(dataStr);//values
|
|
|
// System.out.println(datas.getJSONObject(0).getString("em_name"));
|
|
|
- JSONArray dbfinds= JSON.parseObject(message).getJSONArray("dbfinds");
|
|
|
- String fieldkey="";
|
|
|
- for(int i=0;i<dbfinds.size();i++){
|
|
|
- JSONObject item=dbfinds.getJSONObject(i);
|
|
|
- String key=item.getString("field");
|
|
|
- if(key.equals(showKey)){
|
|
|
+ JSONArray dbfinds = JSON.parseObject(message).getJSONArray("dbfinds");
|
|
|
+ String fieldkey = "";
|
|
|
+ for (int i = 0; i < dbfinds.size(); i++) {
|
|
|
+ JSONObject item = dbfinds.getJSONObject(i);
|
|
|
+ String key = item.getString("field");
|
|
|
+ if (key.equals(showKey)) {
|
|
|
// System.out.println(item.getString("dbGridField"));
|
|
|
- fieldkey=item.getString("dbGridField");
|
|
|
+ fieldkey = item.getString("dbGridField");
|
|
|
}
|
|
|
}
|
|
|
if (formBeaan == null) formBeaan = new ArrayList<>();
|
|
|
else formBeaan.clear();
|
|
|
SelectBean bean = null;
|
|
|
- for(int i=0;i<datas.size();i++){
|
|
|
- System.out.println("value"+i+":"+datas.getJSONObject(i).getString(fieldkey));
|
|
|
- bean= new SelectBean();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ System.out.println("value" + i + ":" + datas.getJSONObject(i).getString(fieldkey));
|
|
|
+ bean = new SelectBean();
|
|
|
bean.setId(id);
|
|
|
bean.setName(datas.getJSONObject(i).getString(fieldkey));
|
|
|
bean.setObject(datas.get(i));
|
|
|
@@ -160,7 +159,7 @@ public class SelectActivity extends BaseActivity {
|
|
|
adapter.notifyDataSetChanged();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
emptyLayout.showEmpty();
|
|
|
}
|
|
|
@@ -174,9 +173,10 @@ public class SelectActivity extends BaseActivity {
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
if (item.getItemId() == R.id.save) {
|
|
|
search_edit.setText("");
|
|
|
- selectOK();
|
|
|
- }
|
|
|
- return true;
|
|
|
+ selectOK();
|
|
|
+ return true;
|
|
|
+ } else
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
|
}
|
|
|
|
|
|
private void selectOK() {
|
|
|
@@ -184,15 +184,15 @@ public class SelectActivity extends BaseActivity {
|
|
|
finish();
|
|
|
return;
|
|
|
}
|
|
|
- ArrayList<SelectBean> formBeaan = (ArrayList)adapter.getFormBeaan();
|
|
|
- ArrayList<SelectBean> temps=new ArrayList<>();
|
|
|
- for (int i=0;i<formBeaan.size();i++){
|
|
|
- if (formBeaan.get(i).isClick()){
|
|
|
+ ArrayList<SelectBean> formBeaan = (ArrayList) adapter.getFormBeaan();
|
|
|
+ ArrayList<SelectBean> temps = new ArrayList<>();
|
|
|
+ for (int i = 0; i < formBeaan.size(); i++) {
|
|
|
+ if (formBeaan.get(i).isClick()) {
|
|
|
temps.add(formBeaan.get(i));
|
|
|
}
|
|
|
}
|
|
|
Intent intent = new Intent();
|
|
|
- intent.putParcelableArrayListExtra("data",temps);
|
|
|
+ intent.putParcelableArrayListExtra("data", temps);
|
|
|
intent.putExtra("id", id);
|
|
|
setResult(0x21, intent);
|
|
|
finish();
|
|
|
@@ -204,7 +204,7 @@ public class SelectActivity extends BaseActivity {
|
|
|
getMenuInflater().inflate(R.menu.menu_visit_save, menu);
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -266,22 +266,21 @@ public class SelectActivity extends BaseActivity {
|
|
|
setResult(0x20, intent);
|
|
|
finish();
|
|
|
} else {
|
|
|
- if (formBeaan.get(i).isClick()){
|
|
|
+ if (formBeaan.get(i).isClick()) {
|
|
|
formBeaan.get(i).setId(id);
|
|
|
formBeaan.get(i).setClick(false);
|
|
|
adapter.notifyDataSetChanged();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
formBeaan.get(i).setClick(true);
|
|
|
formBeaan.get(i).setId(id);
|
|
|
adapter.notifyDataSetChanged();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void initIntent() {
|
|
|
@@ -289,7 +288,7 @@ public class SelectActivity extends BaseActivity {
|
|
|
if (intent == null) return;
|
|
|
type = intent.getIntExtra("type", -1);
|
|
|
title = intent.getStringExtra("title");
|
|
|
- id=intent.getIntExtra("id",0);
|
|
|
+ id = intent.getIntExtra("id", 0);
|
|
|
isSingle = intent.getBooleanExtra("isSingle", true);
|
|
|
int reid = intent.getIntExtra("reid", -1);
|
|
|
if (reid != -1)
|
|
|
@@ -373,8 +372,12 @@ public class SelectActivity extends BaseActivity {
|
|
|
chche = formBeaan.get(i);
|
|
|
holer.name_tv.setText(StringUtils.isEmpty(chche.getName()) ? "" : chche.getName());
|
|
|
holer.select_scb.setChecked(chche.isClick());
|
|
|
- holer.select_scb.setFocusable(false);
|
|
|
- holer.select_scb.setClickable(false);
|
|
|
+ if (isSingle) {
|
|
|
+ holer.select_scb.setVisibility(View.GONE);
|
|
|
+ } else {
|
|
|
+ holer.select_scb.setFocusable(false);
|
|
|
+ holer.select_scb.setClickable(false);
|
|
|
+ }
|
|
|
return view;
|
|
|
}
|
|
|
|