|
@@ -6,6 +6,7 @@ import android.os.Handler;
|
|
|
import android.os.Message;
|
|
import android.os.Message;
|
|
|
import android.support.v7.app.ActionBar;
|
|
import android.support.v7.app.ActionBar;
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
|
|
+import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
import android.view.KeyEvent;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
@@ -15,8 +16,10 @@ import android.view.inputmethod.EditorInfo;
|
|
|
import android.widget.AdapterView;
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
|
|
+import android.widget.ListView;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.iflytek.cloud.RecognizerResult;
|
|
import com.iflytek.cloud.RecognizerResult;
|
|
|
import com.iflytek.cloud.SpeechConstant;
|
|
import com.iflytek.cloud.SpeechConstant;
|
|
@@ -38,6 +41,7 @@ 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.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
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.LogUtil;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
|
|
|
|
@@ -45,6 +49,11 @@ import org.json.JSONArray;
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.io.ObjectInputStream;
|
|
|
|
|
+import java.io.ObjectOutputStream;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.LinkedHashMap;
|
|
@@ -76,21 +85,24 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
private TextView mExactOptionConfirmTv;
|
|
private TextView mExactOptionConfirmTv;
|
|
|
private View mFuzzyViewBg, mExactViewBg;
|
|
private View mFuzzyViewBg, mExactViewBg;
|
|
|
private Animation mInAnimation, mOutAnimation;
|
|
private Animation mInAnimation, mOutAnimation;
|
|
|
- private int mPageIndex = 1, mPagesize = 20;
|
|
|
|
|
|
|
+ private int mPageIndex = 1, mPagesize = 10;
|
|
|
private List<HistoricalRecordBean> mHistoricalRecordBeans;
|
|
private List<HistoricalRecordBean> mHistoricalRecordBeans;
|
|
|
private HistoricalRecordAdapter mHistoricalRecordAdapter;
|
|
private HistoricalRecordAdapter mHistoricalRecordAdapter;
|
|
|
private String mSearchField = "";
|
|
private String mSearchField = "";
|
|
|
- private List<SchemeConditionBean> mAllSchemeConditions, mAppSchemeConditions;
|
|
|
|
|
|
|
+ private List<SchemeConditionBean> mAllSchemeConditions, mAppSchemeConditions, mfuzzySchemeConditionBeans, mResetSchemeConditionBeans;
|
|
|
private DataInquirySchemeConditionAdapter mDataInquirySchemeConditionAdapter;
|
|
private DataInquirySchemeConditionAdapter mDataInquirySchemeConditionAdapter;
|
|
|
private List<DataInquiryFlexBean> mDataInquiryFlexBeans;
|
|
private List<DataInquiryFlexBean> mDataInquiryFlexBeans;
|
|
|
private DataInquiryFlexAdapter mDataInquiryFlexAdapter;
|
|
private DataInquiryFlexAdapter mDataInquiryFlexAdapter;
|
|
|
private List<DataInquiryFlexBean.RowBean.RowChildBean> mAllRowChildBeans;
|
|
private List<DataInquiryFlexBean.RowBean.RowChildBean> mAllRowChildBeans;
|
|
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
switch (msg.what) {
|
|
|
case GET_QUERY_CRITERIA:
|
|
case GET_QUERY_CRITERIA:
|
|
|
|
|
+ if (mDataListView.isRefreshing())
|
|
|
|
|
+ mDataListView.onRefreshComplete();
|
|
|
String result = msg.getData().getString("result");
|
|
String result = msg.getData().getString("result");
|
|
|
if (result != null) {
|
|
if (result != null) {
|
|
|
LogUtil.prinlnLongMsg("querycriteria", msg.getData().getString("result"));
|
|
LogUtil.prinlnLongMsg("querycriteria", msg.getData().getString("result"));
|
|
@@ -98,6 +110,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
JSONObject resultObject = new JSONObject(result);
|
|
JSONObject resultObject = new JSONObject(result);
|
|
|
JSONArray dataArray = resultObject.optJSONArray("data");
|
|
JSONArray dataArray = resultObject.optJSONArray("data");
|
|
|
if (dataArray != null) {
|
|
if (dataArray != null) {
|
|
|
|
|
+ String fuzzyHint = "";
|
|
|
for (int i = 0; i < dataArray.length(); i++) {
|
|
for (int i = 0; i < dataArray.length(); i++) {
|
|
|
JSONObject dataObject = dataArray.optJSONObject(i);
|
|
JSONObject dataObject = dataArray.optJSONObject(i);
|
|
|
if (dataObject != null) {
|
|
if (dataObject != null) {
|
|
@@ -109,6 +122,11 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
String caption = optStringNotNull(dataObject, "caption");
|
|
String caption = optStringNotNull(dataObject, "caption");
|
|
|
String defaultValue = optStringNotNull(dataObject, "defaultValue");
|
|
String defaultValue = optStringNotNull(dataObject, "defaultValue");
|
|
|
String type = optStringNotNull(dataObject, "type");
|
|
String type = optStringNotNull(dataObject, "type");
|
|
|
|
|
+
|
|
|
|
|
+ if (appCondition && "S".equals(type)) {
|
|
|
|
|
+ fuzzyHint = fuzzyHint + caption + "/";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (!dataObject.isNull("properties")) {
|
|
if (!dataObject.isNull("properties")) {
|
|
|
JSONArray properties = dataObject.optJSONArray("properties");
|
|
JSONArray properties = dataObject.optJSONArray("properties");
|
|
|
if (properties != null) {
|
|
if (properties != null) {
|
|
@@ -142,7 +160,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
properties.add(property);
|
|
properties.add(property);
|
|
|
}
|
|
}
|
|
|
- } else if ("CBG".equals(type) || "C".equals(type) || "R".equals(type)) {
|
|
|
|
|
|
|
+ } else if ("CBG".equals(type) || "EC".equals(type) || "C".equals(type) || "R".equals(type)) {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
schemeConditionBean.setProperties(properties);
|
|
schemeConditionBean.setProperties(properties);
|
|
@@ -160,10 +178,29 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
|
|
|
|
|
if (schemeConditionBean.isAppCondition()) {
|
|
if (schemeConditionBean.isAppCondition()) {
|
|
|
mAppSchemeConditions.add(schemeConditionBean);
|
|
mAppSchemeConditions.add(schemeConditionBean);
|
|
|
|
|
+ if ("S".equals(type)) {
|
|
|
|
|
+ mfuzzySchemeConditionBeans.add(schemeConditionBean);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ mResetSchemeConditionBeans = deepCopy(mAppSchemeConditions);
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
mDataInquirySchemeConditionAdapter.notifyDataSetChanged();
|
|
mDataInquirySchemeConditionAdapter.notifyDataSetChanged();
|
|
|
|
|
+
|
|
|
|
|
+ if (fuzzyHint.length() > 0) {
|
|
|
|
|
+ fuzzyHint = fuzzyHint.substring(0, fuzzyHint.length() - 1);
|
|
|
|
|
+ mSearchEditText.setHint(fuzzyHint);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mSearchEditText.setHint("搜索");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -173,10 +210,13 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
getSchemeData();
|
|
getSchemeData();
|
|
|
break;
|
|
break;
|
|
|
case GET_DATA_RESULT:
|
|
case GET_DATA_RESULT:
|
|
|
|
|
+ if (mDataListView.isRefreshing())
|
|
|
|
|
+ mDataListView.onRefreshComplete();
|
|
|
progressDialog.dismiss();
|
|
progressDialog.dismiss();
|
|
|
result = msg.getData().getString("result");
|
|
result = msg.getData().getString("result");
|
|
|
if (result != null) {
|
|
if (result != null) {
|
|
|
- mDataInquiryFlexBeans.clear();
|
|
|
|
|
|
|
+ if (mPageIndex == 1)
|
|
|
|
|
+ mDataInquiryFlexBeans.clear();
|
|
|
LogUtil.prinlnLongMsg("schemedata", msg.getData().getString("result"));
|
|
LogUtil.prinlnLongMsg("schemedata", msg.getData().getString("result"));
|
|
|
try {
|
|
try {
|
|
|
JSONObject resultObject = new JSONObject(result);
|
|
JSONObject resultObject = new JSONObject(result);
|
|
@@ -236,54 +276,65 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
longChildBeans.add(rowChildBean);
|
|
longChildBeans.add(rowChildBean);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- for (int k = 0; k < longChildBeans.size(); k++) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ for (int k = 0; k < (shortChildBeans.size() / 2); k++) {
|
|
|
DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
|
|
|
|
|
List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
- childBeans.add(longChildBeans.get(k));
|
|
|
|
|
|
|
+ childBeans.add(shortChildBeans.get(k * 2));
|
|
|
|
|
+ childBeans.add(shortChildBeans.get((k * 2) + 1));
|
|
|
|
|
|
|
|
rowBean.setRowChildBeans(childBeans);
|
|
rowBean.setRowChildBeans(childBeans);
|
|
|
|
|
|
|
|
rowBeans.add(rowBean);
|
|
rowBeans.add(rowBean);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- for (int k = 0; k < (shortChildBeans.size() / 2); k++) {
|
|
|
|
|
|
|
+ if ((shortChildBeans.size() % 2) != 0) {
|
|
|
DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
|
|
|
|
|
List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
- childBeans.add(shortChildBeans.get(k * 2));
|
|
|
|
|
- childBeans.add(shortChildBeans.get((k * 2) + 1));
|
|
|
|
|
|
|
+ childBeans.add(shortChildBeans.get(shortChildBeans.size() - 1));
|
|
|
|
|
|
|
|
rowBean.setRowChildBeans(childBeans);
|
|
rowBean.setRowChildBeans(childBeans);
|
|
|
|
|
|
|
|
rowBeans.add(rowBean);
|
|
rowBeans.add(rowBean);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ((shortChildBeans.size() % 2) != 0) {
|
|
|
|
|
|
|
+ for (int k = 0; k < longChildBeans.size(); k++) {
|
|
|
DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
|
|
|
|
|
List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
- childBeans.add(shortChildBeans.get(shortChildBeans.size() - 1));
|
|
|
|
|
|
|
+ childBeans.add(longChildBeans.get(k));
|
|
|
|
|
|
|
|
rowBean.setRowChildBeans(childBeans);
|
|
rowBean.setRowChildBeans(childBeans);
|
|
|
|
|
|
|
|
rowBeans.add(rowBean);
|
|
rowBeans.add(rowBean);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
dataInquiryFlexBean.setRowBeans(rowBeans);
|
|
dataInquiryFlexBean.setRowBeans(rowBeans);
|
|
|
|
|
|
|
|
mDataInquiryFlexBeans.add(dataInquiryFlexBean);
|
|
mDataInquiryFlexBeans.add(dataInquiryFlexBean);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
} catch (JSONException e) {
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
|
|
+ if (mDataListView.isRefreshing())
|
|
|
|
|
+ mDataListView.onRefreshComplete();
|
|
|
progressDialog.dismiss();
|
|
progressDialog.dismiss();
|
|
|
ToastMessage(msg.getData().getString("result"));
|
|
ToastMessage(msg.getData().getString("result"));
|
|
|
|
|
+ if (mPageIndex > 1) {
|
|
|
|
|
+ mPageIndex--;
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -315,16 +366,22 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mHistoricalRecordAdapter.notifyDataSetChanged();
|
|
mHistoricalRecordAdapter.notifyDataSetChanged();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (mQueryScheme != null) {
|
|
|
|
|
- progressDialog.show();
|
|
|
|
|
- String url = Constants.getAppBaseUrl(this) + "mobile/qry/schemeCondition.action";
|
|
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
|
|
- params.put("caller", mQueryScheme.getCaller());
|
|
|
|
|
- params.put("id", mQueryScheme.getSchemeId());
|
|
|
|
|
- LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
|
|
- headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
|
|
- ViewUtil.httpSendRequest(this, url, params, mHandler, headers, GET_QUERY_CRITERIA, null, null, "post");
|
|
|
|
|
|
|
+ if (!CommonUtil.isNetWorkConnected(this)) {
|
|
|
|
|
+ mEmptyLayout.setErrorMessage(getString(R.string.networks_out));
|
|
|
|
|
+ mEmptyLayout.showError();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (mQueryScheme != null) {
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ String url = Constants.getAppBaseUrl(this) + "mobile/qry/schemeCondition.action";
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+ params.put("caller", mQueryScheme.getCaller());
|
|
|
|
|
+ params.put("id", mQueryScheme.getSchemeId());
|
|
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
|
|
+ ViewUtil.httpSendRequest(this, url, params, mHandler, headers, GET_QUERY_CRITERIA, null, null, "post");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initViews() {
|
|
private void initViews() {
|
|
@@ -338,6 +395,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
bar.setCustomView(view);
|
|
bar.setCustomView(view);
|
|
|
|
|
|
|
|
mDataListView = (PullToRefreshListView) findViewById(R.id.data_inquiry_list_ptlv);
|
|
mDataListView = (PullToRefreshListView) findViewById(R.id.data_inquiry_list_ptlv);
|
|
|
|
|
+ mDataListView.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
mFuzzyWholeLl = (LinearLayout) findViewById(R.id.data_inquiry_list_fuzzy_ll);
|
|
mFuzzyWholeLl = (LinearLayout) findViewById(R.id.data_inquiry_list_fuzzy_ll);
|
|
|
mFuzzyHistoryLl = (LinearLayout) findViewById(R.id.data_inquiry_list_history_ll);
|
|
mFuzzyHistoryLl = (LinearLayout) findViewById(R.id.data_inquiry_list_history_ll);
|
|
|
mHistoryClearTv = (TextView) findViewById(R.id.data_inquiry_history_clear_tv);
|
|
mHistoryClearTv = (TextView) findViewById(R.id.data_inquiry_history_clear_tv);
|
|
@@ -353,11 +411,19 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mHistoricalRecordBeans = new ArrayList<>();
|
|
mHistoricalRecordBeans = new ArrayList<>();
|
|
|
mAllSchemeConditions = new ArrayList<>();
|
|
mAllSchemeConditions = new ArrayList<>();
|
|
|
mAppSchemeConditions = new ArrayList<>();
|
|
mAppSchemeConditions = new ArrayList<>();
|
|
|
|
|
+ mfuzzySchemeConditionBeans = new ArrayList<>();
|
|
|
|
|
+ mResetSchemeConditionBeans = new ArrayList<>();
|
|
|
mDataInquiryFlexBeans = new ArrayList<>();
|
|
mDataInquiryFlexBeans = new ArrayList<>();
|
|
|
mAllRowChildBeans = new ArrayList<>();
|
|
mAllRowChildBeans = new ArrayList<>();
|
|
|
mInAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_search_popin);
|
|
mInAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_search_popin);
|
|
|
mOutAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_search_popout);
|
|
mOutAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_search_popout);
|
|
|
|
|
|
|
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mDataListView.getRefreshableView());
|
|
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
|
|
+ mEmptyLayout.setEmptyMessage("没有符合条件的数据");
|
|
|
|
|
+
|
|
|
mDataInquirySchemeConditionAdapter = new DataInquirySchemeConditionAdapter(this, mAppSchemeConditions);
|
|
mDataInquirySchemeConditionAdapter = new DataInquirySchemeConditionAdapter(this, mAppSchemeConditions);
|
|
|
mExactOptionLv.setAdapter(mDataInquirySchemeConditionAdapter);
|
|
mExactOptionLv.setAdapter(mDataInquirySchemeConditionAdapter);
|
|
|
|
|
|
|
@@ -384,10 +450,36 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
|
|
|
|
|
mSearchEditText.setOnEditorActionListener(this);
|
|
mSearchEditText.setOnEditorActionListener(this);
|
|
|
|
|
|
|
|
|
|
+ mDataListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
|
|
+ if (CommonUtil.isNetWorkConnected(DataInquiryListActivity.this)) {
|
|
|
|
|
+ mPageIndex = 1;
|
|
|
|
|
+ getSchemeData();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mEmptyLayout.setErrorMessage(getString(R.string.networks_out));
|
|
|
|
|
+ mEmptyLayout.showError();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
|
|
+ if (!CommonUtil.isNetWorkConnected(DataInquiryListActivity.this)) {
|
|
|
|
|
+ mEmptyLayout.setErrorMessage(getString(R.string.networks_out));
|
|
|
|
|
+ mEmptyLayout.showError();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mPageIndex++;
|
|
|
|
|
+ getSchemeData();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
mSearchEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
mSearchEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
|
|
if (hasFocus) {
|
|
if (hasFocus) {
|
|
|
|
|
+ if (mExactWholeLl.getVisibility() == View.VISIBLE)
|
|
|
|
|
+ mExactWholeLl.setVisibility(View.GONE);
|
|
|
if (mHistoricalRecordAdapter.getObjects().size() > 0) {
|
|
if (mHistoricalRecordAdapter.getObjects().size() > 0) {
|
|
|
if (mFuzzyWholeLl.getVisibility() == View.GONE) {
|
|
if (mFuzzyWholeLl.getVisibility() == View.GONE) {
|
|
|
mFuzzyHistoryLl.startAnimation(mInAnimation);
|
|
mFuzzyHistoryLl.startAnimation(mInAnimation);
|
|
@@ -395,8 +487,6 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- mExactWholeLl.setVisibility(View.GONE);
|
|
|
|
|
} else {
|
|
} else {
|
|
|
if (mFuzzyWholeLl.getVisibility() == View.VISIBLE)
|
|
if (mFuzzyWholeLl.getVisibility() == View.VISIBLE)
|
|
|
mFuzzyWholeLl.setVisibility(View.GONE);
|
|
mFuzzyWholeLl.setVisibility(View.GONE);
|
|
@@ -430,6 +520,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mSearchEditText.clearFocus();
|
|
mSearchEditText.clearFocus();
|
|
|
mExactWholeLl.setVisibility(View.GONE);
|
|
mExactWholeLl.setVisibility(View.GONE);
|
|
|
mFuzzyWholeLl.setVisibility(View.GONE);
|
|
mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
+ CommonUtil.closeKeybord(mSearchEditText, DataInquiryListActivity.this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -444,10 +535,25 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
HistoricalRecordBean historicalRecordBean = mHistoricalRecordAdapter.getObjects().get(position);
|
|
HistoricalRecordBean historicalRecordBean = mHistoricalRecordAdapter.getObjects().get(position);
|
|
|
mSearchEditText.setText(historicalRecordBean.getSearchField());
|
|
mSearchEditText.setText(historicalRecordBean.getSearchField());
|
|
|
mSearchField = historicalRecordBean.getSearchField();
|
|
mSearchField = historicalRecordBean.getSearchField();
|
|
|
- mSearchEditText.clearFocus();
|
|
|
|
|
- mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
- progressDialog.show();
|
|
|
|
|
- getSchemeData();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!TextUtils.isEmpty(mSearchField)) {
|
|
|
|
|
+ mCondition = "";
|
|
|
|
|
+ for (int i = 0; i < mfuzzySchemeConditionBeans.size(); i++) {
|
|
|
|
|
+ mCondition = mCondition + "(" + mfuzzySchemeConditionBeans.get(i).getField()
|
|
|
|
|
+ + " like \'%" + mSearchField + "%\') and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (mCondition.length() >= 5) {
|
|
|
|
|
+ mCondition = mCondition.substring(0, mCondition.length() - 5);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Log.d("fuzzyCondition", mCondition);
|
|
|
|
|
+
|
|
|
|
|
+ mPageIndex = 1;
|
|
|
|
|
+ mSearchEditText.clearFocus();
|
|
|
|
|
+ mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ getSchemeData();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -456,12 +562,11 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
switch (v.getId()) {
|
|
switch (v.getId()) {
|
|
|
case R.id.data_inquiry_filter_iv:
|
|
case R.id.data_inquiry_filter_iv:
|
|
|
|
|
+ if (mFuzzyWholeLl.getVisibility() == View.VISIBLE) {
|
|
|
|
|
+ mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
+ }
|
|
|
|
|
+ mSearchEditText.clearFocus();
|
|
|
if (mAppSchemeConditions.size() > 0) {
|
|
if (mAppSchemeConditions.size() > 0) {
|
|
|
-
|
|
|
|
|
- mSearchEditText.clearFocus();
|
|
|
|
|
- if (mFuzzyWholeLl.getVisibility() == View.VISIBLE) {
|
|
|
|
|
- mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
- }
|
|
|
|
|
if (mExactWholeLl.getVisibility() == View.VISIBLE) {
|
|
if (mExactWholeLl.getVisibility() == View.VISIBLE) {
|
|
|
mExactOptionLl.startAnimation(mOutAnimation);
|
|
mExactOptionLl.startAnimation(mOutAnimation);
|
|
|
} else {
|
|
} else {
|
|
@@ -485,8 +590,78 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mExactWholeLl.setVisibility(View.GONE);
|
|
mExactWholeLl.setVisibility(View.GONE);
|
|
|
break;
|
|
break;
|
|
|
case R.id.data_inquiry_list_option_reset_tv:
|
|
case R.id.data_inquiry_list_option_reset_tv:
|
|
|
|
|
+ mAppSchemeConditions.clear();
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<SchemeConditionBean> conditionBeans = deepCopy(mResetSchemeConditionBeans);
|
|
|
|
|
+ mAppSchemeConditions.addAll(conditionBeans);
|
|
|
|
|
+ mDataInquirySchemeConditionAdapter.notifyDataSetChanged();
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case R.id.data_inquiry_list_option_confirm_tv:
|
|
case R.id.data_inquiry_list_option_confirm_tv:
|
|
|
|
|
+ mCondition = "";
|
|
|
|
|
+ for (int i = 0; i < mAppSchemeConditions.size(); i++) {
|
|
|
|
|
+ SchemeConditionBean schemeConditionBean = mAppSchemeConditions.get(i);
|
|
|
|
|
+ if ("S".equals(schemeConditionBean.getType()) && schemeConditionBean.getProperties().size() == 1) {
|
|
|
|
|
+ if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(0).getDisplay())) {
|
|
|
|
|
+ mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
|
|
+ + " = \'" + schemeConditionBean.getProperties().get(0).getDisplay() + "\')"
|
|
|
|
|
+ + " and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if ("N".equals(schemeConditionBean.getType()) && schemeConditionBean.getProperties().size() == 2) {
|
|
|
|
|
+ if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(0).getDisplay())
|
|
|
|
|
+ && !TextUtils.isEmpty(schemeConditionBean.getProperties().get(1).getDisplay())) {
|
|
|
|
|
+ mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
|
|
+ + " >= " + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
|
|
+ + " and " + schemeConditionBean.getField()
|
|
|
|
|
+ + " <= " + schemeConditionBean.getProperties().get(1).getDisplay() + ") and ";
|
|
|
|
|
+
|
|
|
|
|
+ } else if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(0).getDisplay())) {
|
|
|
|
|
+ mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
|
|
+ + " >= " + schemeConditionBean.getProperties().get(0).getDisplay() + ") and ";
|
|
|
|
|
+ } else if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(1).getDisplay())) {
|
|
|
|
|
+ mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
|
|
+ + " <= " + schemeConditionBean.getProperties().get(1).getDisplay() + ") and ";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } else if (("D".equals(schemeConditionBean.getType()) || "CD".equals(schemeConditionBean.getType())) && schemeConditionBean.getProperties().size() == 2) {
|
|
|
|
|
+ mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
|
|
+ + " >= to_date(\'" + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
|
|
+ + "\',\'yyyy-MM-dd\') and " + schemeConditionBean.getField()
|
|
|
|
|
+ + " <= to_date(\'" + schemeConditionBean.getProperties().get(1).getDisplay()
|
|
|
|
|
+ + "\',\'yyyy-MM-dd\')) and ";
|
|
|
|
|
+ } else if ("CBG".equals(schemeConditionBean.getType()) || "C".equals(schemeConditionBean.getType())
|
|
|
|
|
+ || "R".equals(schemeConditionBean.getType()) || "EC".equals(schemeConditionBean.getType())) {
|
|
|
|
|
+ String gridCondition = "";
|
|
|
|
|
+ int selectedCount = 0;
|
|
|
|
|
+ for (int j = 0; j < schemeConditionBean.getProperties().size(); j++) {
|
|
|
|
|
+ if (schemeConditionBean.getProperties().get(j).isState()) {
|
|
|
|
|
+ selectedCount++;
|
|
|
|
|
+ gridCondition = gridCondition + schemeConditionBean.getField() + " = \'"
|
|
|
|
|
+ + schemeConditionBean.getProperties().get(j).getValue() + "\' or ";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (selectedCount > 0) {
|
|
|
|
|
+ gridCondition = gridCondition.substring(0, gridCondition.length() - 4);
|
|
|
|
|
+
|
|
|
|
|
+ mCondition = mCondition + "(" + gridCondition + ") and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mCondition.length() >= 5) {
|
|
|
|
|
+ mCondition = mCondition.substring(0, mCondition.length() - 5);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Log.d("exactCondition", mCondition);
|
|
|
|
|
+
|
|
|
|
|
+ mPageIndex = 1;
|
|
|
|
|
+ mExactWholeLl.setVisibility(View.GONE);
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ getSchemeData();
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -518,15 +693,28 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
if (actionId == EditorInfo.IME_ACTION_SEARCH
|
|
if (actionId == EditorInfo.IME_ACTION_SEARCH
|
|
|
|| actionId == EditorInfo.IME_ACTION_SEND
|
|
|| actionId == EditorInfo.IME_ACTION_SEND
|
|
|
|| (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|| (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
- // TODO: 2017/8/18 condition
|
|
|
|
|
String searchField = mSearchEditText.getText().toString().trim();
|
|
String searchField = mSearchEditText.getText().toString().trim();
|
|
|
if (!TextUtils.isEmpty(searchField)) {
|
|
if (!TextUtils.isEmpty(searchField)) {
|
|
|
- mSearchField = searchField;
|
|
|
|
|
- mSearchEditText.clearFocus();
|
|
|
|
|
- mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
- progressDialog.show();
|
|
|
|
|
- getSchemeData();
|
|
|
|
|
|
|
+ mCondition = "";
|
|
|
|
|
+ for (int i = 0; i < mfuzzySchemeConditionBeans.size(); i++) {
|
|
|
|
|
+ mCondition = mCondition + "(" + mfuzzySchemeConditionBeans.get(i).getField()
|
|
|
|
|
+ + " like \'%" + searchField + "%\') and ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (mCondition.length() >= 5) {
|
|
|
|
|
+ mCondition = mCondition.substring(0, mCondition.length() - 5);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Log.d("fuzzyCondition", mCondition);
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mCondition = "1 = 1";
|
|
|
}
|
|
}
|
|
|
|
|
+ mPageIndex = 1;
|
|
|
|
|
+ mSearchField = searchField;
|
|
|
|
|
+ mSearchEditText.clearFocus();
|
|
|
|
|
+ mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ getSchemeData();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
@@ -553,11 +741,23 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static long optLongNotNull(JSONObject json, String key) {
|
|
|
|
|
|
|
+ public long optLongNotNull(JSONObject json, String key) {
|
|
|
if (json.isNull(key)) {
|
|
if (json.isNull(key)) {
|
|
|
return 0;
|
|
return 0;
|
|
|
} else {
|
|
} else {
|
|
|
return json.optLong(key, 0);
|
|
return json.optLong(key, 0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public <T> List<T> deepCopy(List<T> src) throws IOException, ClassNotFoundException {
|
|
|
|
|
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
|
|
|
|
+ ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
|
|
|
|
+ out.writeObject(src);
|
|
|
|
|
+
|
|
|
|
|
+ ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
|
|
|
|
|
+ ObjectInputStream in = new ObjectInputStream(byteIn);
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
|
+ List<T> dest = (List<T>) in.readObject();
|
|
|
|
|
+ return dest;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|