|
|
@@ -0,0 +1,669 @@
|
|
|
+package com.xzjmyk.pm.activity.ui.erp.activity.message;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.support.v7.app.ActionBar;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.TextWatcher;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.BaseAdapter;
|
|
|
+import android.widget.Filter;
|
|
|
+import android.widget.Filterable;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
+import com.iflytek.cloud.speech.RecognizerResult;
|
|
|
+import com.iflytek.cloud.speech.SpeechError;
|
|
|
+import com.iflytek.cloud.ui.RecognizerDialogListener;
|
|
|
+import com.lidroid.xutils.ViewUtils;
|
|
|
+import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
+import com.xzjmyk.pm.activity.MyApplication;
|
|
|
+import com.xzjmyk.pm.activity.R;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.JsonParser;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.VoiceToWord;
|
|
|
+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.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.DateFormatUtil;
|
|
|
+import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
+import com.xzjmyk.pm.activity.wxapi.ApiConfig;
|
|
|
+import com.xzjmyk.pm.activity.wxapi.ApiUtils;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class ProcessB2BActivity extends BaseActivity implements View.OnClickListener ,RecognizerDialogListener {
|
|
|
+
|
|
|
+
|
|
|
+ @ViewInject(R.id.edt_search)
|
|
|
+ ClearEditText mEditText;
|
|
|
+ @ViewInject(R.id.voice_search_iv)
|
|
|
+ private ImageView voice_search;
|
|
|
+ @ViewInject(R.id.lv_process)
|
|
|
+ PullToRefreshListView mList;
|
|
|
+
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+
|
|
|
+ @ViewInject(R.id.tv_process_me)
|
|
|
+ private TextView tv_process_me;
|
|
|
+ @ViewInject(R.id.tv_process_already)
|
|
|
+ private TextView tv_process_already;
|
|
|
+ @ViewInject(R.id.tv_process_un)
|
|
|
+ private TextView tv_process_un;
|
|
|
+
|
|
|
+ @ViewInject(R.id.back)
|
|
|
+ private ImageView iv_back;
|
|
|
+
|
|
|
+ private ProcessAdapter mAdapter;
|
|
|
+ private JSONArray array = new JSONArray();
|
|
|
+
|
|
|
+ private int tab_type = 1;
|
|
|
+ private int page = 1;
|
|
|
+ private final int SUSSCESS_un = 1;
|
|
|
+ private final int SUSSCESS_already = 2;
|
|
|
+ private final int SUSSCESS_me = 3;
|
|
|
+ private int exceptionCount=0;//
|
|
|
+
|
|
|
+
|
|
|
+ private Handler mHandler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ if (StringUtils.isEmpty(result)) return;
|
|
|
+ mList.onRefreshComplete();
|
|
|
+ switch (msg.what) {
|
|
|
+ case SUSSCESS_un:
|
|
|
+
|
|
|
+ JSONArray itemArray = JSON.parseObject(result).getJSONArray("data");
|
|
|
+ if (page == 1) array.clear();
|
|
|
+ array.addAll(itemArray);
|
|
|
+ array = CommonUtil.sortJsonArray(array);//排序
|
|
|
+
|
|
|
+ if (mAdapter == null) {
|
|
|
+ mAdapter = new ProcessAdapter(ct, array);
|
|
|
+ mList.setAdapter(mAdapter);
|
|
|
+ } else {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ if (array.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ if (currentId!=0){
|
|
|
+ mList.getRefreshableView().setSelection(currentId);
|
|
|
+ }
|
|
|
+ ToastMessage("数据加载完成");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ break;
|
|
|
+ case SUSSCESS_already:
|
|
|
+ itemArray = JSON.parseObject(result).getJSONArray("data");
|
|
|
+ // if (page == 1)
|
|
|
+ array.clear();
|
|
|
+ array.addAll(itemArray);
|
|
|
+ if (mAdapter == null) {
|
|
|
+ mAdapter = new ProcessAdapter(ct, array);
|
|
|
+ mList.setAdapter(mAdapter);
|
|
|
+ } else {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ if (array.size() == 0) {
|
|
|
+
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ if (currentId!=0){
|
|
|
+ mList.getRefreshableView().setSelection(currentId);
|
|
|
+ }
|
|
|
+ ToastMessage("数据加载完成");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ break;
|
|
|
+ case SUSSCESS_me:
|
|
|
+ itemArray = JSON.parseObject(result).getJSONArray("data");
|
|
|
+ // if (page == 1)
|
|
|
+ array.clear();
|
|
|
+ array.addAll(itemArray);
|
|
|
+ if (mAdapter == null) {
|
|
|
+ mAdapter = new ProcessAdapter(ct, array);
|
|
|
+ mList.setAdapter(mAdapter);
|
|
|
+ } else {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ if (array.size() == 0) {
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }
|
|
|
+ if (currentId!=0){
|
|
|
+ mList.getRefreshableView().setSelection(currentId);
|
|
|
+ }
|
|
|
+ ToastMessage("数据加载完成");
|
|
|
+ progressDialog.dismiss();
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ LogUtil.d(TAG, result);
|
|
|
+ exceptionCount++;
|
|
|
+ try {
|
|
|
+ if (exceptionCount<=3){
|
|
|
+ ToastMessage(result);
|
|
|
+ ViewUtil.ct = ct;
|
|
|
+ ViewUtil.LoginERPTask(ct, mHandler, 0x16);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 0x16:
|
|
|
+ try {
|
|
|
+ initData();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.APP_NOTNETWORK:
|
|
|
+ progressDialog.dismiss();
|
|
|
+ ToastMessage("网络未连接!");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ private int currentId;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.activity_process_msg);
|
|
|
+ ViewUtils.inject(this);
|
|
|
+ initView();
|
|
|
+ initData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initData() {
|
|
|
+ if (CommonUtil.isNetWorkConnected(mContext)){
|
|
|
+ loadProcessToDo(page);
|
|
|
+ }else{
|
|
|
+ mEmptyLayout.setErrorMessage("网络未连接!");
|
|
|
+ mEmptyLayout.showError();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initView() {
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mList.getRefreshableView());
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+// mEmptyLayout.showLoading();
|
|
|
+
|
|
|
+ View view = LayoutInflater.from(ct).inflate(R.layout.process_header, null);
|
|
|
+ ActionBar bar = this.getSupportActionBar();
|
|
|
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
|
+ tv_process_already = (TextView) view.findViewById(R.id.tv_process_already);
|
|
|
+ tv_process_un = (TextView) view.findViewById(R.id.tv_process_un);
|
|
|
+ tv_process_me = (TextView) view.findViewById(R.id.tv_process_me);
|
|
|
+ iv_back = (ImageView) view.findViewById(R.id.back);
|
|
|
+ bar.setCustomView(view);
|
|
|
+ tv_process_already.setOnClickListener(this);
|
|
|
+ tv_process_me.setOnClickListener(this);
|
|
|
+ tv_process_un.setOnClickListener(this);
|
|
|
+ tv_process_un.setSelected(true);
|
|
|
+ iv_back.setOnClickListener(this);
|
|
|
+ mList.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ mList.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
+ @Override
|
|
|
+ public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
+ page = 1;
|
|
|
+ switch (tab_type) {
|
|
|
+ case 1:
|
|
|
+ loadProcessToDo(page);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ loadProcesstoAlreadyDo(page);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ loadProcessAlreadyLaunch(page);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
+ page++;
|
|
|
+ switch (tab_type) {
|
|
|
+ case 1:
|
|
|
+ loadProcessToDo(page);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ loadProcesstoAlreadyDo(page);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ loadProcessAlreadyLaunch(page);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ ProcessAdapter.ViewModel model = (ProcessAdapter.ViewModel) view.getTag();
|
|
|
+ currentId=position;
|
|
|
+ LogUtil.d(TAG,position+"");
|
|
|
+ String title = "";
|
|
|
+ String url = "";
|
|
|
+ switch (tab_type) {
|
|
|
+ case 1:
|
|
|
+ title = "待审批";
|
|
|
+ if ("transferprocess".equals(model.typecode)||"process".equals(model.typecode) || "".equals(model.typecode)) {
|
|
|
+ url = "jsps/mobile/process.jsp?nodeId=" + model.JP_NODEID;
|
|
|
+ } else if ("procand".equals(model.typecode)) {
|
|
|
+ url = "jsps/mobile/jprocand.jsp?nodeId=" + model.JP_NODEID;
|
|
|
+ } else if ("unprocess".equals(model.typecode)) {
|
|
|
+ url = "jsps/mobile/process.jsp?nodeId=" + model.JP_NODEID + "%26_do=1";
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ title = "已审批";
|
|
|
+ url = "jsps/mobile/process.jsp?nodeId=" + model.JP_NODEID + "%26_do=1";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ title = "我发起的";
|
|
|
+ url = "jsps/mobile/process.jsp?nodeId=" + model.JP_NODEID + "%26_do=1";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ String master = model.master == null ? CommonUtil.getSharedPreferences(ct, "erp_master") : model.master;
|
|
|
+ CommonUtil.loadWebView(ct, url, title, master, null, null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mEditText.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) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ if (mAdapter == null) {
|
|
|
+ //Toast.makeText(getApplication(), "系统内部错误", Toast.LENGTH_SHORT).show();
|
|
|
+ } else {
|
|
|
+ if (!StringUtils.isEmpty(mEditText.getText().toString())) {
|
|
|
+ mAdapter.getFilter().filter(mEditText.getText().toString());
|
|
|
+ } else {
|
|
|
+ mAdapter.getFilter().filter("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ final VoiceToWord voice = new VoiceToWord(MyApplication.getInstance(),"534e3fe2");
|
|
|
+ voice.setRecognizerDialogListener(this); //自己调用自己
|
|
|
+ voice_search.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ voice.GetWordFromVoice();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()) {
|
|
|
+ case R.id.tv_process_un:
|
|
|
+ progressDialog.show();
|
|
|
+ page = 1;
|
|
|
+ tab_type = 1;
|
|
|
+ mAdapter = null;
|
|
|
+ tv_process_un.setSelected(true);
|
|
|
+ tv_process_already.setSelected(false);
|
|
|
+ tv_process_me.setSelected(false);
|
|
|
+ mList.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
|
|
+ loadProcessToDo(page);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case R.id.tv_process_already:
|
|
|
+ progressDialog.show();
|
|
|
+ page = 1;
|
|
|
+ tab_type = 2;
|
|
|
+ mAdapter = null;
|
|
|
+ mList.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ tv_process_un.setSelected(false);
|
|
|
+ tv_process_already.setSelected(true);
|
|
|
+ tv_process_me.setSelected(false);
|
|
|
+ loadProcesstoAlreadyDo(page);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case R.id.tv_process_me:
|
|
|
+ progressDialog.show();
|
|
|
+ page = 1;
|
|
|
+ tab_type = 3;
|
|
|
+ mAdapter = null;
|
|
|
+ mList.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ tv_process_un.setSelected(false);
|
|
|
+ tv_process_already.setSelected(false);
|
|
|
+ tv_process_me.setSelected(true);
|
|
|
+ loadProcessAlreadyLaunch(page);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case R.id.back:
|
|
|
+ onBackPressed();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void loadProcessToDo(int page) {
|
|
|
+// progressDialog.show();
|
|
|
+ String url = ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getAuditTodo;
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("emuu", CommonUtil.getSharedPreferences(MyApplication.getInstance(),""));
|
|
|
+ params.put("enuu", CommonUtil.getSharedPreferences(MyApplication.getInstance(),""));
|
|
|
+ params.put("count", "10");
|
|
|
+ params.put("page", "1");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, SUSSCESS_un, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void loadProcesstoAlreadyDo(int page) {
|
|
|
+ // progressDialog.show();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/process/alreadyDo.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("count", String.valueOf(page*30));
|
|
|
+ params.put("page", 1);
|
|
|
+ params.put("isMobile","1");
|
|
|
+ params.put("_do", "1");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, SUSSCESS_already, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void loadProcessAlreadyLaunch(int page) {
|
|
|
+ // progressDialog.show();
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/process/alreadyLaunch.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("count", String.valueOf(page*30));
|
|
|
+ params.put("page", 1);
|
|
|
+ params.put("isMobile","1");
|
|
|
+ params.put("_do", "1");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, SUSSCESS_me, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ mList.setRefreshing(true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResult(RecognizerResult recognizerResult, boolean b) {
|
|
|
+ String text = JsonParser.parseIatResult(recognizerResult.getResultString());
|
|
|
+ mEditText.setText(mEditText.getText().toString() + CommonUtil.getPlaintext(text));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SpeechError speechError) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ProcessAdapter extends BaseAdapter implements Filterable {
|
|
|
+
|
|
|
+ private Context ct;
|
|
|
+ private LayoutInflater inflater;
|
|
|
+ private JSONArray jsonArray;
|
|
|
+
|
|
|
+ ProcessAdapter(Context ct, JSONArray array) {
|
|
|
+ this.ct = ct;
|
|
|
+ this.jsonArray = array;
|
|
|
+ this.inflater = LayoutInflater.from(ct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return jsonArray == null ? 0 : jsonArray.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ ViewModel model = null;
|
|
|
+ if (convertView == null) {
|
|
|
+ convertView = inflater.inflate(R.layout.item_process_state, parent, false);
|
|
|
+ model = new ViewModel();
|
|
|
+ model.name = (TextView) convertView.findViewById(R.id.tv_name);
|
|
|
+ model.date = (TextView) convertView.findViewById(R.id.tv_date);
|
|
|
+ model.status = (TextView) convertView.findViewById(R.id.tv_status);
|
|
|
+ convertView.setTag(model);
|
|
|
+ } else {
|
|
|
+ model = (ViewModel) convertView.getTag();
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (tab_type) {
|
|
|
+ case 1:
|
|
|
+ //JP_LAUNCHERNAME
|
|
|
+ //JP_NAME
|
|
|
+ //JP_STATUS
|
|
|
+ //JP_LAUNCHTIME
|
|
|
+ String jp_launchername = jsonArray.getJSONObject(position).getString("JP_LAUNCHERNAME");
|
|
|
+ String jp_name = jsonArray.getJSONObject(position).getString("JP_NAME");
|
|
|
+ String JP_NODEID = jsonArray.getJSONObject(position).getString("JP_NODEID");
|
|
|
+ if (!StringUtils.isEmpty(jp_name)) jp_name = jp_name.replace("流程", "");
|
|
|
+ Long jp_launchtime = jsonArray.getJSONObject(position).getLong("JP_LAUNCHTIME");
|
|
|
+ String jp_status = jsonArray.getJSONObject(position).getString("JP_STATUS");
|
|
|
+ String jp_typecode = jsonArray.getJSONObject(position).getString("TYPECODE");
|
|
|
+ String jp_master=jsonArray.getJSONObject(position).getString("CURRENTMASTER");
|
|
|
+
|
|
|
+
|
|
|
+ model.name.setText(jp_launchername + "的" + jp_name);
|
|
|
+ if (jp_launchtime != null) {
|
|
|
+ model.date.setText(DateFormatUtil.getStrDate4Date(new Date(jp_launchtime), "yyyy-MM-dd HH:mm"));
|
|
|
+ } else {
|
|
|
+ model.date.setText("");
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ model.status.setText(jp_status);
|
|
|
+ model.JP_NODEID = JP_NODEID;
|
|
|
+ model.typecode = jp_typecode;
|
|
|
+ model.master=jp_master;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //JN_DEALMANNAME
|
|
|
+ //JP_NAME
|
|
|
+ //JN_DEALTIME
|
|
|
+ //JN_DEALRESULT
|
|
|
+ String jn_dealmanname = jsonArray.getJSONObject(position).getString("JP_LAUNCHERNAME");
|
|
|
+ jp_name = jsonArray.getJSONObject(position).getString("JP_NAME");
|
|
|
+ JP_NODEID = jsonArray.getJSONObject(position).getString("JP_NODEID");
|
|
|
+ if (!StringUtils.isEmpty(jp_name)) jp_name = jp_name.replace("流程", "");
|
|
|
+ String jn_dealtime = jsonArray.getJSONObject(position).getString("JN_DEALTIME");//JP_LAUNCHTIME
|
|
|
+ String jn_dealresult = jsonArray.getJSONObject(position).getString("JN_DEALRESULT");
|
|
|
+
|
|
|
+ model.name.setText(jn_dealmanname + "的" + jp_name);
|
|
|
+ model.date.setText(jn_dealtime);
|
|
|
+ if (!StringUtils.isEmpty(jn_dealresult)) {
|
|
|
+ if ("不同意".equals(jn_dealresult)) {
|
|
|
+ CommonUtil.textSpanForStyle(model.status, "已审批(" + jn_dealresult + ")",
|
|
|
+ jn_dealresult, mContext.getResources().getColor(R.color.red));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ CommonUtil.textSpanForStyle(model.status, "已审批(" + jn_dealresult + ")",
|
|
|
+ jn_dealresult, mContext.getResources().getColor(R.color.light_gray));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.JP_NODEID = JP_NODEID;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ //JP_CODEVALUE
|
|
|
+ //JP_NODEDEALMANNAME
|
|
|
+ //JP_STATUS
|
|
|
+ //JP_LAUNCHTIME
|
|
|
+ //JP_NODEDEALMANNAME
|
|
|
+ if (jsonArray.getJSONObject(position) != null) {
|
|
|
+ Long time = jsonArray.getJSONObject(position).getLong("JP_LAUNCHTIME");
|
|
|
+ String name = jsonArray.getJSONObject(position).getString("JP_NAME");
|
|
|
+ String code = jsonArray.getJSONObject(position).getString("JP_CODEVALUE");
|
|
|
+ String status = jsonArray.getJSONObject(position).getString("JP_STATUS");
|
|
|
+ String nodename = jsonArray.getJSONObject(position).getString("JP_NODEDEALMANNAME");
|
|
|
+ JP_NODEID = jsonArray.getJSONObject(position).getString("JP_NODEID");
|
|
|
+ String codename= jsonArray.getJSONObject(position).getString("JP_NODENAME");
|
|
|
+ if (!StringUtils.isEmpty(status)) {
|
|
|
+ if (status.equals("待审批")) {
|
|
|
+ status = "等待" + nodename +"("+codename+ ")审批";
|
|
|
+ }if (status.equals("未通过")){
|
|
|
+ status="未通过" + nodename + "("+codename+")审批";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ status=" ";
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(name)) name = name.substring(0, name.length() - 2);
|
|
|
+ model.name.setText(name + "-" + code);
|
|
|
+ if (time != null) {
|
|
|
+ model.date.setText(DateFormatUtil.getStrDate4Date(new Date(time), "yyyy-MM-dd HH:mm"));
|
|
|
+ } else {
|
|
|
+ model.date.setText("");
|
|
|
+ }
|
|
|
+ if (status.contains("未通过")) {
|
|
|
+// CommonUtil.textSpanForStyle(model.status, status,
|
|
|
+// status, mContext.getResources().getColor(R.color.red));
|
|
|
+ model.status.setTextColor(mContext.getResources().getColor(R.color.red));
|
|
|
+ model.status.setText(status);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ model.status.setTextColor(mContext.getResources().getColor(R.color.light_gray));
|
|
|
+ model.status.setText(status);
|
|
|
+ }
|
|
|
+ model.JP_NODEID = JP_NODEID;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Filter getFilter() {
|
|
|
+ return new Filter() {
|
|
|
+ @Override
|
|
|
+ protected FilterResults performFiltering(CharSequence constraint) {
|
|
|
+ FilterResults searchResults = new FilterResults();
|
|
|
+ if (constraint == null || constraint.length() == 0) {
|
|
|
+ searchResults.values = array;
|
|
|
+ searchResults.count = array.size();
|
|
|
+ } else {
|
|
|
+ JSONArray newArry = new JSONArray();
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+ Log.i("Arison", "performFiltering:" + jsonObject.toString());
|
|
|
+ String cu_name = "";
|
|
|
+ String time = "";
|
|
|
+ String status = "";
|
|
|
+ String nodename = "";
|
|
|
+ String jn_dealresult = "";
|
|
|
+ String jp_launchername = "";
|
|
|
+ String code = "";
|
|
|
+ switch (tab_type) {
|
|
|
+ case 1:
|
|
|
+ cu_name = jsonObject.getString("JP_NAME") == null ? "" : jsonObject.getString("JP_NAME");
|
|
|
+ long temp_long = jsonObject.getLong("JP_LAUNCHTIME") == null ? 0 : jsonObject.getLong("JP_LAUNCHTIME");
|
|
|
+ time = DateFormatUtil.getStrDate4Date(new Date(temp_long), "yyyy-MM-dd HH:mm");
|
|
|
+ status = jsonObject.getString("JP_STATUS") == null ? "" : jsonObject.getString("JP_STATUS");
|
|
|
+ jp_launchername = jsonObject.getString("JP_LAUNCHERNAME") == null ? "" : jsonObject.getString("JP_LAUNCHERNAME");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ cu_name = jsonObject.getString("JP_NAME") == null ? "" : jsonObject.getString("JP_NAME");
|
|
|
+ time = jsonObject.getString("JN_DEALTIME") == null ? "" : jsonObject.getString("JN_DEALTIME");
|
|
|
+ jn_dealresult = jsonObject.getString("JN_DEALRESULT") == null ? "" : jsonObject.getString("JN_DEALRESULT");
|
|
|
+ jp_launchername = jsonObject.getString("JP_LAUNCHERNAME") == null ? "" : jsonObject.getString("JP_LAUNCHERNAME");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ cu_name = jsonObject.getString("JP_NAME") == null ? "" : jsonObject.getString("JP_NAME");
|
|
|
+ temp_long = jsonObject.getLong("JP_LAUNCHTIME") == null ? 0 : jsonObject.getLong("JP_LAUNCHTIME");
|
|
|
+ time = DateFormatUtil.getStrDate4Date(new Date(temp_long), "yyyy-MM-dd HH:mm");
|
|
|
+ status = jsonObject.getString("JP_STATUS") == null ? "" : jsonObject.getString("JP_STATUS");
|
|
|
+ nodename = jsonObject.getString("JP_NODEDEALMANNAME") == null ? "" : jsonObject.getString("JP_NODEDEALMANNAME");
|
|
|
+ code = jsonObject.getString("JP_CODEVALUE") == null ? "" : jsonObject.getString("JP_CODEVALUE");
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (cu_name.contains(constraint)
|
|
|
+ || time.contains(constraint)
|
|
|
+ || status.contains(constraint)
|
|
|
+ || jn_dealresult.contains(constraint)
|
|
|
+ || jp_launchername.contains(constraint)
|
|
|
+ || nodename.contains(constraint)
|
|
|
+ || code.contains(constraint)) {
|
|
|
+ newArry.add(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ searchResults.values = newArry;
|
|
|
+ searchResults.count = newArry.size();
|
|
|
+ }
|
|
|
+ return searchResults;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
|
+ //装配数据
|
|
|
+ jsonArray = (JSONArray) results.values;
|
|
|
+ if (mAdapter.getCount() == 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ class ViewModel {
|
|
|
+ TextView name;
|
|
|
+ TextView date;
|
|
|
+ TextView status;
|
|
|
+ String JP_NODEID;
|
|
|
+ String typecode;
|
|
|
+ String master;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|